{"sys":{"type":"Array"},"total":2578,"skip":0,"limit":100,"items":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3AwvmovrZGbWL7ZreuE5GZ","type":"Entry","createdAt":"2026-04-02T14:49:46.770Z","updatedAt":"2026-04-02T14:49:46.770Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":113,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How Topcoder AI Reviewer Works","slug":"how-topcoder-ai-reviewer-works","type":"Article","trackCategory":["Topcoder","Development"],"tags":["AI ","Review","Development"],"creationDate":"2026-04-01","readTime":"5 min","content":"__AI Reviewer is an Automated AI-powered quality gate for Topcoder challenge submissions using scorecard-driven evaluation.__\n\nIf you wish to understand more on how the AI Reviewers is affecting different roles such as members, copilots, reviewers, check out the [AI Reviewers Member Help Guide article](https://www.topcoder.com/thrive/articles/ai-reviewers-member-help-guide).\n\n### Overview\n\nThe TC-AI-Reviewer automates evaluation of Topcoder challenge submissions against structured scorecards. Built on the [Mastra](https://mastra.ai/) AI workflow framework, it provides:\n\n1. __Challenge Context Loading__ — Fetches/generates unified challenge context (requirements, tech stack, submission guidelines) via TC API  \n2. __Workspace Analysis__ — Recursively scans submission files with intelligent exclusion patterns (node_modules, build artifacts, etc.)  \n3. __Deterministic Pre-checks__ — Identifies empty files, hidden files, build artifacts, project markers, and validates patch files  \n4. __Triage Gate__ — Fast rejection of fundamentally inadequate submissions (empty, tiny, missing manifests, invalid patches)  \n5. __AI-Powered Audit__ — Skills-driven evaluation agent analyzes submissions against scorecard questions  \n6. __Structured Output__ — Zod-validated answers with evidence citations, requirement mapping, and verdicts  \n7. __Score Computation__ — Weighted scoring with answer-verdict consistency enforcement and coverage policies  \n8. __TC API Integration__ — Posts results back to Topcoder platform with token usage metrics  \n\n### Architecture\n\n#### High-level Flow\n![Architecture JSON](//images.ctfassets.net/piwi0eufbb2g/3UDWcwoskHHP2DQUVAuZUG/4702293ea6138032e40643f38bb7fe5c/Architecture_JSON.png)\n\n#### Workflows\n\n| Workflow | Description |\n|----------|------------|\n| `submissionQualityGateWorkflow` | Main orchestrator: file tree → pre-checks → triage → AI audit → scoring |\n| `submissionWorkspaceFileTreeWorkflow` | Recursively builds workspace file tree with content indexing |\n| `runPrecheckWorkflow` | Deterministic pre-checks + triage gate for fast rejection |\n\n#### Agent\n\nThe __Submission Auditor Agent__ (`submission-auditor-agent`) is a skills-driven AI agent that:\n\n- Loads challenge context from workspace files  \n- Evaluates question applicability before scoring  \n- Uses workspace tools (readFile, listFiles, searchFiles) to gather evidence  \n- Produces structured JSON answers per scorecard question  \n- Follows strict protocols for verdict consistency and evidence grounding  \n\n### Skills Protocol\n\nThe agent uses a skills-driven evaluation protocol:\n\n1. `challenge-context-loading` — Load challenge requirements  \n2. `question-applicability` — Determine if questions apply to this challenge  \n3. `requirement-evaluation` — Ground evaluation in actual requirements  \n4. `red-flag-detection` — Quick-reject checklist for critical issues  \n5. `file-inspection` — Workspace file reading protocol  \n6. `scale-scoring` — 1–5 rubric for SCALE questions  \n7. `depth-analysis` — Implementation depth evaluation  \n8. `scorecard-response` — Structured output format  \n9. `strictness-enforcement` — Final self-check  \n\n### Scorers\n\nBuilt-in evaluation scorers for quality assurance:\n\n| Scorer | Purpose |\n|--------|--------|\n| `answerRelevancyScorer` | Measures answer relevance to questions |\n| `promptAlignmentScorer` | Checks alignment with prompt instructions |\n| `toolCallAccuracyScorer` | Validates correct tool usage |\n| `hallucinationScorer` | Detects unsupported claims |\n| `scorecardCompletenessScorer` | Ensures all questions are answered |\n| `evidenceGroundingScorer` | Verifies evidence citations exist |\n| `verdictConsistencyScorer` | Checks answer-verdict alignment |\n| `skillProtocolComplianceScorer` | Validates protocol field population |\n\n### Required Environment Variables\n\n| Variable | Purpose |\n|----------|--------|\n| `AI_WORKFLOW_DETAILS_PATH` | Path to JSON file defining workflow + scorecard |\n| `CHALLENGE_ID` | Challenge identifier |\n| `WORKSPACE_PATH` | Path to workspace directory containing submission files |\n| `TC_API_BASE_URL` | Topcoder API base URL |\n| `TC_API_TOKEN` | Authentication token for TC API |\n| `SUBMISSION_ID` | (Optional) Submission identifier |\n| `TC_RUN_ID` | (Optional) Run ID for posting results back to TC API |\n| `LLM_PROVIDER_NAME` | (Optional) LLM provider: TC-Ollama or WiproAI (default) |\n| `LLM_MODEL_NAME` | (Optional) Model name (default: gpt-5-chat) |\n| `OLLAMA_HOST` | (Optional) Ollama base URL (default: http://127.0.0.1:11434) |\n| `OLLAMA_NUM_CTX` | (Optional) Override context window size (default: 32000) |\n| `LOCAL_DEV` | (Optional) Enable storage, observability, and scorers |\n| `WORKFLOW_RUN_TIMEOUT_MS` | (Optional) Workflow timeout (default: 900000ms / 15min) |\n\n### Example `.env`\n![Example AI Review](//images.ctfassets.net/piwi0eufbb2g/6TBPtzn3cyPmqkmWH29o6U/19c32fc426b3d93182c1c06c89338351/Example_AI_Review.png)\n\n### Scoring System\n\n#### Question Types\n\n| Type | Answer Field | Scoring |\n|------|-------------|--------|\n| __YES_NO__ | `yesNoAnswer: boolean` | true=100%, false=0% |\n| __SCALE__ | `scaleAnswer: number` | Normalized to 0–100% based on scaleMin/scaleMax |\n| __TEST_CASE__ | `testCasePass: boolean` | true=100%, false=0% |\n\n#### Weighted Score Formula\n![Score Formula](//images.ctfassets.net/piwi0eufbb2g/2ijrp3A2xEmTBtd1kL8IIY/50be38d9d5e455ee8e9f26d5a2455071/Score_Formula.png)\n\n#### Verdicts\n- `PASS` — Question criteria fully met  \n- `FAIL` — Question criteria not met  \n- `WARN` — Partial compliance or concerns  \n- `N_A` — Question not applicable to this submission  \n\n#### Post-Processing Policies\n\nThe scoring engine applies automatic corrections:\n\n1. __Answer-Verdict Consistency__ — Fixes contradictions (e.g., `yesNoAnswer=false` with verdict=`PASS`)  \n2. __Evidence Coverage Policy__ — Hard-fail if <50% of content questions have grounded evidence \n3. __Requirement Mapping Consistency__ — Resolves conflicting status across questions  \n4. __Implementation Depth Scrutiny__ — Adjusts high scores when evidence indicates shallow implementation  \n\n### Output Artifact\n`quality-gate-report.json` structure:\n\n```\n{\n  \"status\": \"success\",\n  \"result\": {\n    \"scorecardId\": \"...\",\n    \"scorecardName\": \"...\",\n    \"totalScore\": 87.32,\n    \"maxScore\": 100,\n    \"minimumPassingScore\": 75,\n    \"passed\": true,\n    \"overallVerdict\": \"PASS\",\n    \"overallSummary\": \"...\",\n    \"tokenUsage\": {\n      \"calls\": [...],\n      \"summary\": { \"inputTokens\": 0, \"outputTokens\": 0, \"totalTokens\": 0 }\n    },\n    \"preCheckSignals\": { ... },\n    \"groups\": [\n      {\n        \"groupId\": \"...\",\n        \"groupName\": \"...\",\n        \"weight\": 100,\n        \"score\": 87.32,\n        \"sections\": [\n          {\n            \"sectionId\": \"...\",\n            \"sectionName\": \"...\",\n            \"weight\": 100,\n            \"score\": 87.32,\n            \"questionAnswers\": [\n              {\n                \"questionId\": \"UUID\",\n                \"applicable\": true,\n                \"verdict\": \"PASS\",\n                \"evidence\": \"...\",\n                \"reasoning\": \"...\",\n                \"decision\": \"...\",\n                \"yesNoAnswer\": true,\n                \"fileInspections\": [...],\n                \"requirementMapping\": [...],\n                \"evidenceCitations\": [...]\n              }\n            ]\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### Pre-check Signals\n- `totalFiles`, `totalDirectories`, `totalSizeBytes`  \n- `emptyFiles` — Zero-byte files  \n- `hiddenFiles` — Dotfiles and OS metadata  \n- `buildArtifacts` — node_modules, dist, pycache, etc.  \n- `projectMarkers` — package.json, pom.xml, requirements.txt, etc.  \n- `extensionDistribution` — File type breakdown  \n- `patchFiles` — Analysis of .patch/.diff files  \n- `submissionTypeAnalysis` — Whether patch or full codebase is expected  \n\n#### Triage Red Flags\n\n| Flag | Severity | Trigger |\n|------|----------|--------|\n| __EMPTY_SUBMISSION__ | critical | No files |\n| __NO_SOURCE_CODE__ | critical | No recognized source files |\n| __TINY_SUBMISSION__ | critical | <3 source files or <3KB |\n| __MOSTLY_BUILD_ARTIFACTS__ | critical | 80% files are build outputs |\n| __MISSING_NODE_MANIFEST__ | critical | Node.js required but no package.json |\n| __MISSING_PYTHON_MANIFEST__ | critical | Python required but no requirements.txt |\n| __MISSING_JVM_MANIFEST__ | critical | JVM required but no pom.xml/build.gradle |\n| __INVALID_PATCH_FORMAT__ | critical | Patch file not valid unified diff |\n| __TRIVIAL_PATCH__ | critical | Patch has <10 lines changed |\n| __PATCH_PLACEHOLDER_CONTENT__ | critical | Patch contains {...} or \"implement me\" |\n\n### Project Structure\n![Project Structure](//images.ctfassets.net/piwi0eufbb2g/b3bUqCYXdqQMsn5tRKMsV/7b8f5dafbeddc809c14f32dcdc11b859/Project_Structure.png)\n\n### Extending LLM Providers\n\n1. Add provider file in `src/utils/providers/`  \n2. Implement the AI SDK interface with deterministic seeding support  \n3. Export from `src/utils/providers/model-factory.ts`  \n4. Add case to `createModel()` switch statement  \n\n```\ncase 'MyProvider':\n    return myProvider.chatModel(model);\n ```\n\n### Quick Start\n\n__Prerequisites__\n- Node.js ```>=``` 22.13.0  \n- pnpm ```>=``` 10.28.0  \n\n__Install Dependencies__\n`pnpm install`\n\n__Run Quality Gate__\n`pnpm start`\n\n__Development Server (Mastra Studio)__\n`pnpm dev\n#Then open http://localhost:3000/studio`\n\n__Check Results__\n`cat quality-gate-report.json | jq '.result | {score: .totalScore, verdict: .overallVerdict, passed: .passed}'\n`\n\n### Available Scripts\n\n| Script | Description |\n|--------|------------|\n| `pnpm start` | Run the quality gate workflow CLI |\n| `pnpm dev` | Start Mastra development server with hot reload |\n| `pnpm build` | Build the project |\n| `pnpm start:server` | Start Mastra production server |\n| `pnpm studio` | Open Mastra Studio UI |\n| `pnpm test` | Run scorer tests |\n| `pnpm test:scorers` | Run scorer tests (explicit) |\n| `pnpm lint` | Run ESLint |\n| `pnpm lint:fix` | Fix ESLint issues |\n| `pnpm format` | Format code with Prettier |\n| `pnpm format:check` | Check code formatting |\n\n### Logs\n\n```https://git.topcoder-dev.com/TC-AI-Workflows/TC-AI-Submission-Screener/actions/runs/{runId}```\n\n### Tech Stack\n- __Runtime:__ Node.js 22+  \n- __Framework:__ [Mastra](https://mastra.ai/) v1.13+ — AI workflow orchestration  \n- __LLM Providers:__ Wipro AI SDK (default), TC-Ollama  \n- __Storage:__ LibSQL (local development only)  \n- __Validation:__ Zod v4  \n- __Observability:__ @mastra/observability (local development)  \n- __Language:__ TypeScript 5.9+  ","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yO45g1yJfxerGOktJVufM","type":"Asset","createdAt":"2022-10-18T14:37:19.496Z","updatedAt":"2023-09-15T21:03:26.749Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"Being a Successful Topcoder Freelancer","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7yO45g1yJfxerGOktJVufM/a283509c9e75aeb72730662fb1bc989a/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"41l1dYBbokrTSUwfAOIo9Y","type":"Entry","createdAt":"2026-03-31T22:08:28.567Z","updatedAt":"2026-03-31T22:28:44.299Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":78,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"AI Reviewers – Member Help Guide","slug":"ai-reviewers-member-help-guide","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sofL39d1uWshUiu27kL21","type":"Entry","createdAt":"2019-10-24T21:25:43.778Z","updatedAt":"2019-10-24T21:25:43.778Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Development","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"krziWcdrBi43HXkh0VYWr","type":"Entry","createdAt":"2019-08-27T06:12:20.665Z","updatedAt":"2019-08-27T06:12:20.665Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Topcoder-Centric","trackParent":"Development"}}],"tags":["Ai","Review","Development"],"creationDate":"2026-03-31","readTime":"5 min","content":"### 1. Introduction\nWe are introducing AI Reviewers at Topcoder for development challenges. You can see them in the [Review App](https://review.topcoder.com/) for future challenges. If you are not familiar with the Review App, check out [this article](https://www.topcoder.com/thrive/articles/the-new-topcoder-review-flow).\n\nAI Reviewers introduce an automated pre-screening step into the challenge workflow, helping assess submissions early by providing scores, feedback, and quality signals. This enables competitors to improve their submissions during the submission phase and helps streamline what progresses to manual review.\n\nWhile AI influences the flow of submissions, __human oversight remains in place__ through reviewers and copilots, ensuring that decisions can be reviewed and adjusted where needed.\n\n### 2. What This Means for Each User\nAI Reviewers introduce new interactions across the challenge workflow.\nLet’s look at what this means for each user type.\n\n#### 2.1 For Competitors (Submitters)\nAfter you submit, your submission is queued for AI Review. Results are generated __shortly after submission__, though timing may vary depending on system load.\n\n__What You Will See__\n- AI Review __status__ (e.g., pending, completed)\n- Once completed:\n  - __Aggregated Score__ (determines Pass / Fail)\n  - __Pass / Fail status__\n  - __Individual scores__ from one or more AI workflows\n  - __Individual weights__ for each AI workflows\n  - __Review dates__ for each AI workflows\n\n##### AI Review Summary View\n\n![review 1](//images.ctfassets.net/piwi0eufbb2g/3gdgNYz0DA9AePdL2uEhzr/321fe5b05a02974fcb8f658fabe55329/review_1.webp)\n\nIn the summary view, you can:\n- See the __aggregated score and final status (Pass/Fail)__\n- View scores from individual AI workflows\n- Hover over the __info icon next to the aggregated score__ to understand how it is calculated (it uses the weight of each AI workflow)\n\n__Some AI Workflows will be gated (marked with the thunder icon), meaning that if that review doesn’t pass minimum score, the entire submission will fail, regardless of the overall AI Workflow score. They are critical for your submission to pass review.__\n\n__Note__: You can only appeal to a submission that was failed by a human review, not by an AI Workflow. \n\n##### Detailed Feedback View\n\n![review 2](//images.ctfassets.net/piwi0eufbb2g/3XAE1cUX9REEog6UmTFk2A/93be1486e4926b59f10f18e6a4c6d842/review_2.webp)\n\nBy clicking on an __individual workflow score__, you can:\n- View __detailed feedback and comments__\n- Understand specific issues or improvement areas identified by that workflow\n\n__What You Should Do__\n- Review the AI feedback carefully\n- Use the insights to __improve your submission__\n\n__Important__\n- If your submission is marked as Fail, it will not move to the manual review phase (the standard review conducted by human reviewers).\n- However, you can __update and resubmit__ as long as the submission phase is still open\n- Even if your submission __Passes__, you can continue to refine and resubmit for a better outcome\n\n#### 2.2 For Reviewers\nDuring the review phase, AI Review results are available to help you prioritize and evaluate submissions.\n\n![review 3](//images.ctfassets.net/piwi0eufbb2g/5Dc2O1BMFuYhkoWVvjv4mh/965dc359cb996d3525180249a194f8cc/review_3.webp)\n\n__What You Will See__\n- Submissions that have __passed AI Review__ and are available for manual review\n- Submissions that are __locked__ due to failing AI Review and are not available for manual review\n- For each submission:\n  - AI Review aggregated score and Pass/Fail status\n  - AI workflow-level scores\n  - Detailed AI feedback\n  - \n\n#### Reviewing AI-Passed Submissions\n\nFor submissions that have passed AI Review:\n- You can proceed with normal manual evaluation\n- AI feedback is available to help guide your review\n\n__What You Should Do__\n- Use AI feedback as a starting point, not a conclusion\n- Perform a complete manual assessment\n- Assign scores based on your judgment\n\n__Important:__ Please evaluate each submission using your own expertise and judgment—without relying on external AI tools. You are fully responsible for ensuring the quality of the outcomes in this challenge.\n\n#### Handling Locked Submissions\n\n![review 4](//images.ctfassets.net/piwi0eufbb2g/yeatSNwOIZDcndLCA6tLP/587b1627fccef4c8d92216291bcd73c8/review_4.webp)\n\nSubmissions that fail AI Review are locked and do not move to manual review by default. However, as a reviewer, you can escalate a locked submission if you believe it deserves further evaluation.\n\n#### Escalation Flow\n\n![review 5](//images.ctfassets.net/piwi0eufbb2g/56ZYegbh2Af37Q0bWH2d8Z/f749b7cc514b7bac0842581877dac601/review_5.webp)\n\nFor locked submissions, you can initiate an escalation by clicking the __escalate icon next to the submission__.\n\nWhen you escalate a locked submission:\n\n- The request is sent to the copilot for review\n- The copilot will:\n  - Approve → Submission is unlocked and becomes available for manual review\n  - Reject → Submission remains locked\n\nIf a locked submission is __unlocked__, all reviewers are __notified via email__, ensuring it is picked up for manual evaluation.\n\n##### What You Should Do\n- Focus primarily on AI-passed submissions for evaluation\n- Review locked submissions selectively\n- Escalate only when:\n  - The AI decision appears incorrect\n  - The submission shows potential despite failing\n\n#### 2.3 For Copilots\n\nDuring the review phase, copilots have oversight of AI-reviewed submissions and control over which locked submissions can proceed to manual review.\n\n##### What You Will See\n![review 6](//images.ctfassets.net/piwi0eufbb2g/7pRntoLm2Pc1eOXHWbmy8J/68a198e5569982172c52018c823f0f05/review_6.webp)\n\n- Submissions that pass AI Review and human review\n- Submissions that are __locked__ due to failing AI Review\n- __Escalation requests__ raised by reviewers if any\n- For each submission:\n  - AI Review aggregated score and Pass/Fail status\n  - AI workflow-level scores\n  - Detailed AI feedback (via drill-down)\n\n##### Reviewing Escalations\n\nEscalated submissions are indicated by a __verify icon next to the locked submission__.\n\n- Click the __verify icon__ to view the escalation request\n- Review the __submission details and AI feedback__\n\nWhen a reviewer escalates a locked submission, you can:\n\n- __Approve__ → Submission is __unlocked, and all the reviewers will get an email notification__ and then submission moves to manual review\n- __Reject__ → Submission remains locked\n\n![review 7](//images.ctfassets.net/piwi0eufbb2g/s8yUcdGpsc4ZlsgeR5chb/c140feedb4ded42449e584fd57b2e9d2/review_7.webp)\n\n##### Directly Unlocking Submissions\n\n![review 8](//images.ctfassets.net/piwi0eufbb2g/4q4EWQ7O0Ta66JwwXSygpz/3151490a73e2aa80d0a184b79c4de457/review_8.webp)\n\nIn addition to handling escalations, you can directly unlock submissions.\n\n- Click the __unlock icon next to a locked submission__ to unlock it\n- The submission will then move to the __manual review phase__\n\nThis allows you to act proactively if you identify submissions that should be reviewed further.\n\n##### What You Should Do\n- Review escalations carefully before approving\n- Use AI feedback as __supporting input__, not the sole decision factor\n\nUnlock submissions when:\n- The AI decision appears incorrect\n- The submission shows sufficient merit for manual evaluation\n\n__Important:__ Please evaluate each submission using your own expertise and judgment - without relying on external AI tools.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yO45g1yJfxerGOktJVufM","type":"Asset","createdAt":"2022-10-18T14:37:19.496Z","updatedAt":"2023-09-15T21:03:26.749Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"Being a Successful Topcoder Freelancer","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7yO45g1yJfxerGOktJVufM/a283509c9e75aeb72730662fb1bc989a/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"555vJGIKA2wfhZRTLl39Pt","type":"Entry","createdAt":"2020-04-20T12:41:38.832Z","updatedAt":"2026-03-18T00:28:23.594Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":53,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 716","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java"],"creationDate":"2017-07-10T00:00:00.000Z","readTime":"20 min","content":"# Single Round Match 716 Editorials\n\nSRM 716 Editorials are now published. We are still awaiting the submission to the Div I Hard problem. Thanks to [survival07](https://profiles.topcoder.com/survival07), [Vetteru](https://profiles.topcoder.com/Vetteru) and [Shizhouxing](https://profiles.topcoder.com/Shizhouxing) for contributing to the SRM 716 Editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n## Permutiple\nSRM 716 Round 1 - Division II, Level One \n-  by [survival07](https://profiles.topcoder.com/survival07)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14628)\n\nTuhin07\nProblem statement: Rearrange the digits of a number (x) without leading zeros such that new number y is a multiple of x and x != y. Check whether it’s possible.\nMathematical form of y = x * C. What is the range of C here. It can’t be 1. In that case y would become equal to x. C can’t be 10 as it would add an extra digit ‘0’ to x. So range of C is [2, 3, …, 9]\nSo the idea is to multiply x by all possible values of C one at a time and then check if the product y has the same number of counts for each digit (0-9) as x.\nAnother idea would be generating all possible permutations for digits of x and then check if any permutation is a multiple of x. In that case it needs to ensure that permutation doesn’t have leading zeros.\n\nHere is the C++ code:\n\n```\n[cpp]\n\nclass Permutiple {\npublic:\nstring isPossible(int x) {\nstring p = \"Possible\";\nstring imp = \"Impossible\";\nint i,j;\n//count_x[i] is the counter number for digit i in number x\nint count_x[10];\nint a = x;\nmemset((count_x),(0),sizeof(count_x)); //initialize x's counter array to zero's\nwhile(a){\ncount_x[a%10]++;\na /= 10;\n}\nforl(i,2,10){\nint y = x*i;\n//count_y[i] is the counter number for digit i in number y\nint count_y[10];\nmemset((count_y),(0),sizeof(count_y)); //initialize array to zero's\nwhile(y){\ncount_y[y%10]++;\ny /= 10;\n}\nbool ok=true;\nforl(j,0,10){\nif(count_x[j] != count_y[j]){ //check if digit j has equal counter in both x and y\nok=false;\nbreak;\n}\n}\nif(ok) //return 'Possible' if both counter arrays are same\nreturn p;\n}\nreturn imp; //Otherwise 'Impossible'\n}\n};\n\n[/cpp]\n```\n\n## ConstructLCSEasy\nSRM 716 Round 1 - Division II, Level Two \n- by [survival07](https://profiles.topcoder.com/survival07)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14624)\n\nTuhin07\nImportant constraint in this problem is: ab ≤ bc ≤ ca\nIf the LCS length of two strings A and B is x, then the length of both A and B is at least x. Because LCS can’t be larger than the smallest (based on length) input string. Let’s denote length of string A as L(A).\n\nSo, from parameter ab we can say: L(A), L(B) ≥ ab\nFrom parameter bc: L(B), L(C) ≥ bc\nFrom parameter ca: L(A), L(C) ≥ ca\n\nHere is the thing – if a variable x is greater than or equal to both y and z and y ≥ z, we can definitely draw a conclusion that x ≥ y. No need to consider z.\nConsidering the above constraints on L(A) we see L(A) ≥ ca and ab. But ca ≥ ab. So L(A) must be greater than or equal to ca. Similarly, L(B) ≥ bc and L(C) ≥ ca. From these derived constraints it’s quite intuitive to build strings A, B and C. Following picture will illustrate the process of building strings.\n\n![SRM716 1](//images.ctfassets.net/piwi0eufbb2g/7AdIBuWb5vlb8HYVko9wGF/fabdb146b6e1a25b792f258739770f8d/SRM716_1.webp)\nHere we see that f(A,B) [LCS of A and B] = ab as there are ab 1’s in B and ab ≤ ca.\nF(B,C) = bc because string C includes B and L(B) = bc. Number of 1’s in C = ab+ (ca-ab) = ca which makes f(C,A) = ca. Simultaneously swapping all 1’s to 0’s and all 0’s to 1’s in string A, B and C will build a different solution. Here is the C++ code:\n\n```\n[cpp]\n\nclass ConstructLCSEasy {\npublic:\nstring construct(int ab, int bc, int ca) {\nstring A = string(ca,'1');\nstring B = string(ab,'1') + string(bc-ab,'0');\nstring C = B + string(ca-ab, '1');\nreturn A + \" \" + B + \" \" + C;\n}\n};\n\n[/cpp]\n``` \n\n## JumpDistancesOnTreeEasy\nSRM 716 Round 1 - Division II, Level Three \n-by [Vetteru](https://profiles.topcoder.com/Vetteru)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14626)\n\nThe solution of this problem consists of 3 parts such as initialize, evaluate and update.\nIn initialize section (void init(int[] p) in my code), we have to initialize some variable and calculate minimum distances of all pairs.\n\nTo calculate minimum distances, I used Warshall–Floyd Algorithm.\nIn evaluate section (boolean next(int dist) in my code), we have to evaluate the next step is possible or impossible.\nIf a node that is S[i] (i = current index) distance away from reachable nodes exists, the step is possible. otherwise, impossible.\nIn update section (void update(int dist) in my code), we have to update reachable nodes.\nNew reachable node is a node that is n distance (any combination of previous used distances) away from current reachable nodes.\n\nExample of the solution:\ndistance set S = [2, 4]\n\n![SRM716 2](//images.ctfassets.net/piwi0eufbb2g/zT858AekBYzZ7eDLPckzB/54499ccbbfc409f360a155292476f77c/SRM716_2.webp)\n\ninitialize : Initialize variables and calculate distance of all pairs.\nevaluation : First, we are at '0' and a given distance is 2. We can reach '3' and '4'. So the evaluation returns possible.\n\nupdate : Current reachable node is only '0'. So we add all nodes that distance is multiple of 2.\nNote that given distance is a form of set, so we can use that distances many times.\nIn this time '3', '4' (distance : 2), '6' (distance : 4) are reachable.\nSo at the end of this section, reachable nodes will be ['0', '3', '4', '6'].\nevaluation : In this time, we can be at ['0', '3', '4', '6'] and a given distance is 4.\n'0' is 4 distance away from '6'. So this evaluation also returns possible.\nupdate : In this update section, No new reachable nodes found.\nfinish : Every queries are done correctly and the answer is \"POSSIBLE\".\n\n__Complexity__:\nn := the number of vertexes\ns := the size of set of distances\ninitialize : Time - O(n^3), Space - O(n^2)\n- Warshall–Floyd Algorithm's cost\n- initialize 2D array that hold all distances of all paris.\nevaluate : Time - O(n^2), Space - O(1)\n- In worst case, we have to check all distances of all pairs.\n- No memory required.\nupdate : Time - O(n^2), Space - O(n)\n- In worst case, we have to check all distances of all pairs.\n- Need a list that hold reachable nodes.\ntotal : Time - O(n^3) or O(s x n^2), Space - O(n^2)\n- We call initialize only one time, evaluate s times, and update s times.\nIn this problem, s and n is same size (1 <= s, n <= 50). So the time complexity is O(n^3) or O(s x n^2).\n- Space complexity is O(n^2). A 2D array that hold all distances of all paris is that.\n\n```\n[java]\n\nimport java.util.HashSet;\nimport java.util.Set;\npublic class JumpDistancesOnTreeEasy {\nprivate static final int INF = 1<<25;\nprivate int size;\nprivate int[][] distances;\nprivate Set<Integer> selectableDist;\nprivate Set<Integer> selectableNode;\npublic String isPossible(int[] p, int[] S) {\ninit(p);\nfor (int s : S) {\nboolean isPossible = next(s);\nif (!isPossible) {\nreturn \"Impossible\";\n}\nupdate(s);\n}\nreturn \"Possible\";\n}\nprivate void init(int[] p) {\nsize = p.length + 1;\ndistances = new int[size][size];\nfor (int i = 0; i < size; i++)\nfor (int j = 0; j < size; j++)\ndistances[i][j] = i == j ? 0 : INF;\nfor (int i = 0; i < p.length; i++) {\ndistances[i+1][p[i]] = distances[p[i]][i+1] = 1;\n}\nfor (int k = 0; k < size; k++)\nfor (int i = 0; i < size; i++)\nfor (int j = 0; j < size; j++)\ndistances[i][j] = Math.min(distances[i][j], distances[i][k] + distances[k][j]);\nselectableDist = new HashSet<>();\nselectableNode = new HashSet<>();\nselectableNode.add(0);\n}\nprivate boolean next(int dist) {\nfor (int node : selectableNode) {\nfor (int i = 0; i < size; i++) {\nif (distances[node][i] == dist) {\nreturn true;\n}\n}\n}\nreturn false;\n}\nprivate void update(int dist) {\nselectableDist.add(dist);\nwhile (true) {\nSet<Integer> additionalNode = new HashSet<>();\nfor (int node : selectableNode) {\nfor (int i = 0; i < size; i++) {\nif (selectableDist.contains(distances[node][i]) && !selectableNode.contains(i)) {\nadditionalNode.add(i);\n}\n}\n}\nif (additionalNode.isEmpty()) {\nbreak;\n}\nselectableNode.addAll(additionalNode);\n}\n}\n}\n\n[/java]\n```\n\n## ConstructLCS\n\nSRM 716 Round 1 - Division I, Level One \n- by [Shizhouxing](https://profiles.topcoder.com/Shizhouxing)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14623)\n\nIf ab<=bc<=ca, we can easily construct a solution in the following way:\n( a ) A has ab ones and follows by ca-ab zeros.\n( b ) B has bc ones.\n( c ) C has bc ones and follows by ca-ab zeros.\n\nYou can validate that the LCS’s between A and B, B and C, C and A are exactly ab,bc,ca respectively.\n\nNow if ab, bc, ca given don’t satisfy ab<=bc<=ca, we can rearrange the order of A,B,C when solving the problem. For example, if ab>bc, we can make the order of strings become C,B,A. Now the LCS’s between the 1st string and the 2nd string, 2nd string and the 3rd string, 3rd string and 1st string are bc,ab,ca respectively. In this way, we’ve swapped ab and bc actually. We can do similar things for ab and ca, bc and ca. Hence we can always change the problem into the one where ab<=bc<=ca.\n\nCode\n```\n[cpp]\n\n#include <string>\nusing namespace std;\nclass ConstructLCS {\npublic:\nvoid solve(int ab, int bc, int ca, string& a, string& b, string& c)\n{\nif (ab > bc)\nreturn solve(bc, ab, ca, c, b, a);\nif (ab > ca)\nreturn solve(ca, bc, ab, a, c, b);\nif (bc > ca)\nreturn solve(ab, ca, bc, b, a, c);\na = b = c = \"\";\nfor (int k = 0; k < ab; k++)\na += '1';\nfor (int k = 0; k < bc; k++)\nb += '1', c += '1';\nfor (int k = 0; k < ca - ab; k++)\na += '0', c += '0';\n}\nstring construct(int ab, int bc, int ca)\n{\nstring a, b, c;\nsolve(ab, bc, ca, a, b, c);\nreturn a + \" \" + b + \" \" + c;\n}\n};\n\n[/cpp]\n``` \n\n## JumpDistancesOnTree\nSRM 716 Round 1 - Division I, Level Two  \n- by [Shizhouxing](https://profiles.topcoder.com/Shizhouxing)\n\n[Problem Details\n](https://archive.topcoder.com/ProblemStatement/pm/14625)\n\nWe can first get distances between any two nodes by DFS starting from each node.\n\nNow let’s consider which nodes can be chosen by Rabbit Hanako during her trip. First she must choose node 0 as she starts from city 0. Then if she has chosen node u, for another node v, if the distance between u and v is in set S, she can go to city v right after visiting u and then go back to u. So node v can also be chosen. In this way, we get all nodes that can be chosen. We may use BFS to implement it.\n\nNext we should check whether each element in S can appear as a distance between two nodes during the trip. We need check that for each element in S, whether there are two nodes that can be chosen and the distance between them are exactly this element in S. If all elements in S satisfy the condition, it’s possible to have a required trip, otherwise it’s impossible.\n\nCode\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\nint dis[2500][2500], ok[2500], valid[2500], n;\nvector<int> E[2500];\nqueue<int> Q;\nvoid dfs(int u, int fa, int* dis) {\nif (fa == -1) dis[u] = 0;\nelse dis[u] = dis[fa] + 1;\nfor (auto v:E[u])\nif (v != fa)\ndfs(v, u, dis);\n}\nclass JumpDistancesOnTree\n{\npublic:\nstring isPossible(vector <int> p, vector <int> S)\n{\nmemset(valid, 0, sizeof(valid));\nmemset(ok, 0, sizeof(ok));\nfor (int i = 0; i < S.size(); ++i) valid[S[i]] = true;\nn = p.size() + 1;\nfor (int i = 0; i < n; ++i) E[i].clear();\nfor (int i = 0; i < p.size(); ++i) E[p[i]].push_back(i + 1), E[i + 1].push_back(p[i]);\nfor (int i = 0; i < n; ++i)\ndfs(i, -1, dis[i]);\nok[0] = true;\nQ.push(0);\nwhile (Q.size()) {\nint u = Q.front(); Q.pop();\nfor (int v = 0; v < n; ++v)\nif (valid[dis[u][v]]) {\nvalid[dis[u][v]] = 2;\nif (!ok[v]) {\nok[v] = true;\nQ.push(v);\n}\n}\n}\nfor (int i = 0; i < S.size(); ++i)\nif (valid[S[i]] < 2) return \"Impossible\";\nreturn \"Possible\";\n}\n};\n\n[/cpp]\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-716-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"HK9NQmWEwqSAx1zJGVtNL","type":"Entry","createdAt":"2020-04-20T12:41:40.146Z","updatedAt":"2026-03-17T23:03:08.129Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":65,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 717","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++"],"creationDate":"2017-07-10T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 717 Editorials\n\nSRM 717 Editorials are now published. We are still awaiting the submission to the Div I Hard Problem. Thanks to [Srimaan1316](https://profiles.topcoder.com/Srimaan1316) and [Shizhouxing](https://profiles.topcoder.com/Shizhouxing) for contributing to the SRM 717 Editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n## NiceTable\nSRM 717 Round 1 - Division II, Level One\n- by [Shizhouxing](https://profiles.topcoder.com/Shizhouxing)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14630)\n\nAssume the table has n rows and m columns.\n\n__Solution I__\nIf we set a value for x[0], since x[0] xor y[0] = t[0][0], y[0] should be (x[0] xor t[0][0]). Then for i (1 <= i < n), since x[i] xor y[0] = t[i][0], x[i] should be (y[0] xor t[i][0]). Similarly, for j (1 <= j < m), since x[0] xor y[j] = t[0][j], y[j] should be (x[0] xor t[0][j]).\nSo we can deduce values of x[1]…x[n-1],y[0]…y[m-1] only from x[0]. Then, we just check whether for each i, j (0 <= i < n, 0 <= j < m), x[i] xor y[j] = t[i][j]. If this is true, the table is nice, otherwise the table is not nice.\n\n__Solution II__\nSince n and m are both very small (n, m <= 5), we can just do brute force. We try all possible values for x[0]…x[n-1], y[0]..y[m-1], and check whether they conform to the given table. The complexity for this algorithm is O(2^(n+m)* nm).\n\n__C++ Code__\nHere is an implementation of both solutions: Solution I is given as the main method isNice(), while Solution II is given as the method bf().\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\nint n, m, x[100], y[100];\nclass NiceTable\n{\npublic:\n   string bf(vector<string> t) {\n       for (int i = 0; i < 1 << n; ++i)\n           for (int j = 0; j < 1 << m; ++j) {\n               for (int k = 0; k < n; ++k) x[k] = bool((1 << k) & i);\n               for (int k = 0; k < m; ++k) y[k] = bool((1 << k) & j);\n               int ok = true;\n               for (int ii = 0; ii < n; ++ii)\n                   for (int jj = 0; jj < m; ++jj)\n                       if ((x[ii] ^ y[jj]) != t[ii][jj] - '0')\n                           ok = false;\n               if (ok) return \"Nice\";\n           }\n       return \"Not nice\";        \n   }\n   string isNice(vector <string> t)\n   {\n       n = t.size();\n       m = t[0].size();\n\n       x[0] = 0;\n       y[0] = t[0][0] - '0';\n       for (int i = 1; i < n; ++i) x[i] = (t[i][0] - '0') ^ y[0];\n       for (int i = 1; i < m; ++i) y[i] = (t[0][i] - '0') ^ x[0];\n\n       for (int i = 0; i < n; ++i)\n           for (int j = 0; j < m; ++j)\n               if (t[i][j] - '0' != (x[i] ^ y[j]))\n                   return \"Not nice\";\n\n       return \"Nice\";\n   }\n};\n\n[/cpp]\n``` \n\n## LexmanReplace\nSRM 717 Round 1 - Division II, Level Two \n- by [Srimaan1316](https://profiles.topcoder.com/Srimaan1316)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14631)\n\nIn this problem, you are given 2 strings: s and t. You have to replace some characters of the string s using the characters of string t, such that you obtain the lexicographically largest string. Note that you are not allowed to increase the length of the string s. Also note that in some cases, it is best to leave the string s as is, since that is the optimal answer.\nThis problem can be solved using a greedy approach. The idea is as follows. For better understanding, let us rename the string s as source and string t as allow_chars.\nSort the characters of allow_chars in the non-increasing order. For example, if the string is “egabn” then after sorting it becomes “ngeba”.\n\nLet next = 0.\n\nFor each character in the source string from left to right:\nCompare it with the next-th character of allow_chars.\nIf the character of source is the greater one or equal, do not change anything.\nElse, replace that character with the leftmost character of allow_chars, then increase next by one.\n\nThe time needed to solve this problem is the time taken to traverse source. Let srclen be the length of source, then the time complexity of the above solution is O(srclen).\nThough it was mentioned above that allow_chars is to be sorted in the non-increasing order and initialise next to 0 and then perform comparisons, for ease of implementation, I sorted the string in the non-decreasing order. So, instead of next being zero, it is now len-1.\n\nPseudocode:\n\n```\n[code]\n\nsort allow_chars in non-decreasing order;\nlen := length(allow_chars)\nlen--;\nsrclen := length(source)\nfor(int i = 0; i &lt; srclen; i++) if (len &gt;= 0 &amp;&amp; source[i] &lt; allow_chars[len])\nadd allow_chars[len] to the answer and decrement len;\nelse\nadd source[i] to the answer;\nreturn answer;\n[/code]\nC++ code:\n[cpp]\nclass LexmaxReplace\n{\npublic:\nstring get(string s, string t)\n{\nint len=t.length();\nsort(t.begin(),t.end());\nint length=s.length();\nstring ans=\"\";\nlen--;\nfor(int i=0;i&lt;length;i++)\n{\nif(s[i]&lt;t[len]&amp;&amp;len&gt;=0)\n{\nans+=t[len];\nlen--;\n}\nelse\n{\nans+=s[i];\n}\n}\nreturn ans;\n}\n};\n\n[/cpp]\n``` \n\n## DerangementsDiv2\nSRM 717 Round 1 - Division II, Level Three \n- by [Srimaan1316](https://profiles.topcoder.com/Srimaan1316)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14632)\n\nIn a gist, we need to find the number of derangements of the set {1…m} modulo 1000000007. We can solve this using inclusion-exclusion principle.\n__Prerequisites:__\n\n1. To understand more about derangements, check out this Wikipedia link.\n2. For even more ease of understanding of derangements check out this YouTube video.\n3. Learn about inclusion-exclusion principle here.\n4. Check this comment to know how formula for derangements can be derived using inclusion-exclusion principle.\n\nLet A be the set of all permutations of the set {1…n+m}.\nLet Ti be the set of permutations in which the element i is still in its original position.\nLet Dm be the required answer.\nThen,\n\n![SRM717 1](//images.ctfassets.net/piwi0eufbb2g/3XSzPbBlhzcm0PPsHT5Ith/16987ac46f86c9d046f18cbcf30d2e7b/SRM717_1.webp)\n\n (Why only m and not n+m? Because we need to find the number of derangements of only the first m numbers.)\n\n![SRM717 2](//images.ctfassets.net/piwi0eufbb2g/7XLQReNqbONwRFBOUFDAr/f5a05c38455b5b7607d6e7e6b7ead0ae/SRM717_2.webp)\n\nTherefore,\n\n![SRM717 3](//images.ctfassets.net/piwi0eufbb2g/2BttlA6zohsEd7mGw3J4MD/128c1ce252fe9429dfed1da4307ab94f/SRM717_3.webp)\n\nWe can simplify the above equation into:\n\n![SRM717 4](//images.ctfassets.net/piwi0eufbb2g/6n8RZ0JDjgp7iO4ZZaybie/d196364e1e7247a2804b677756aae86f/SRM717_4.webp)\n\nNow that we have the formula ready, we come to the implementation part. Looking at the above formula, it can be understood that we need to compute the factorial of a given number and binomial coefficients C(m,i) where C(m,i) = m! / ((m-i)! * i!). We can make use of the concept of Pascal triangle. Check out this to know more about Pascal triangle.\nAlso, rather than computing factorials multiple number of times, we precompute it once and store them in an array.\nPlease refer my code below to understand the implementation better.\n\n__C++ code__\n\n```\n[cpp]\n\nC++ code\n#include<bits/stdc++.h>\n#define endl '\\n'\n#define mod 1000000007\nusing namespace std;\nclass DerangementsDiv2\n{\nint fact[104];\nint pascal[103][103];\npublic:int count(int n, int m)\n{\n//Initialising the values of 0! and 1!\nfact[0]=1;\nfact[1]=1;\n// Calculating the factorial values upto 100.\nfor(int i=2;i<104;i++)\nfact[i]=(fact[i-1]*(long long)i)%mod;\n//Computing the Binomial Coefficients using Pascal Triangle.\nfor(int i=0;i<103;i++)\n{\npascal[i][0]=1;\nfor(int j=1;j<=i;j++)\npascal[i][j]=(pascal[i-1][j]+pascal[i-1][j-1])%mod;\n}\nint answer=fact[n+m];\nfor(int i=1;i<=m;i++)\n{\nint val=pascal[m][i];\nif(i&1)\nanswer=(answer-((long long)val*fact[m+n-i] %mod)+mod)%mod;\nelse\nanswer=(answer+((long long)val*fact[m+n-i]%mod))%mod;\n}\nreturn answer;\n}\n};\n\n[/cpp]\n```\n\n__Note__\nCheck out this to know more about performing modulo operation on negative numbers.\n\n## ScoresSequence\nSRM 717 Round 1 - Division I, Level One\n- by [Shizhouxing](https://profiles.topcoder.com/Shizhouxing)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14577)\n\nIt is said that the answer can always be uniquely determined. We can first construct a graph that satisfies the given score.\n\nFrom the scores sequence, we can deduce the in-degree and out-degree of each vertex. Now, we can construct the graph using a greedy algorithm. We consider vertices in the descending order of their out-degrees. For each vertex u, let d be its out-degree. We should choose d other vertices v[1], v[2], …, v[d], and add edges (u,v[1]), (u,v[2]), …, (u,v[d]).\n\nWe can choose those d vertices in the following way: each time, choose a vertex that has the largest remaining in-degree; i.e., its original in-degree minus the number of edges which end at that vertex. For two vertices with same remaining in-degrees, we’ll prefer the one with smaller out-degree. You can easily validate that the solution can’t be better if we don’t construct the graph in this way.\n\nFinally, we can use Floyd-Warshall algorithm to count the number of pairs of vertices (u,v) such that v is reachable from u, in O(n^3) time.\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair<int, int> pii;\nconst int inf = ~0U >> 1;\nconst ll INF = ~0ULL >> 1;\nint G[200][200], in[200], out[200];\nint n;\nclass ScoresSequence\n{\npublic:\nint count(vector <int> s)\n{\nn = s.size();\nsort(s.begin(), s.end(), greater<int>());\nfor (int i = 0; i < n; ++i) {\nin[i] = n - 1 - s[i];\nout[i] = s[i];\nfor (int j = 0; j < n; ++j)\nG[i][j] = false;\nG[i][i] = true;\n}\nfor (int i = 0; i < n; ++i) {\nwhile (out[i]--) {\nint j = -1;\nfor (int k = 0; k < n; ++k) if (i != k && !G[i][k] && (j == -1 || in[k] >= in[j]))\nj = k;\nG[i][j] = true;\nin[j]--;\n}\n}\nfor (int k = 0; k < n; ++k)\nfor (int i = 0; i < n; ++i)\nfor (int j = 0; j < n; ++j)\nG[i][j] |= G[i][k] & G[k][j];\nint cnt = 0;\nfor (int i = 0; i < n; ++i)\nfor (int j = 0; j < n; ++j)\nif (G[i][j]) ++cnt;\nreturn cnt;\n}\n};\n\n[/cpp]\n```\n\n## DerangementsStrikeBack\nSRM 717 Round 1 - Division I, Level Two \n- by [Shizhouxing](https://profiles.topcoder.com/Shizhouxing)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14563)\n\nObviously, B[0] = 1 and B[1] = n. Now, let’s compute B[i] from B[0], B[1], …, B[i-1] using dynamic programming.\n\nLet p(i) = j (1<=j<=n+i, j ≠ i). We have:\n\nIf j < i, consider the remaining subproblem:\nIf p(j) = i, now we can simply “remove” positions i and j from the problem to form a subproblem. We now need to arrange the remaining n+i-2 values where first i-2 values can’t be fixed points. The number of ways is B[i-2].\n\nIf p(j) ≠ i, that means for a valid permutation p(1), p(2), …, p(i-1), p(i+1), …, p(n+i), we have p(k) ≠ k (1<=k<=i-1, k ≠ j) and p(j) ≠ i. This is equivalent to the permutation p(1), p(2), …, p(i-1), p(i+1), …p(n+i) such that p(k) ≠ k (1<=k<=i-1). The number of permutations is B[i-1]. For both cases, there are i-1 such j’s, so the total number of permutations is (i-1)(B[i-2]+B[i-1]) If j > i, the remaining subproblem now is to count number of permutations p(1), p(2), …, p(i-1), p(i+1), …, p(n+i) such that p(k) ≠ k (1<=k<=i-1). The number of permutations is B[i-1]. Since there are n such j’s, the total number of permutations is n* B[i-1].\n\nTherefore, B[i] = (i-1) (B[i-2] + B[i-1]) + n*B[i-1] = (i-1) B[i-2] + (n+i-1) B[i-1]. So, we can simply compute B[1], …, B[m] in O(m) complexity.\n\nFinally, B[1] xor B[2] xor … xor B[m] is the answer that should be returned.\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\nconst int mo = 1000000007;\nint ans, B[200000];\nclass DerangementsStrikeBack\n{\npublic:\nint count(int n, int m)\n{\nB[0] = 1;\nB[1] = n;\nfor (int i = 2; i <= m; ++i)\nB[i] = ((long long)(i - 1) * B[i - 2] + (long long)(n + i - 1) * B[i - 1]) % mo;\nint ans = 0;\nfor (int i = 1; i <= m; ++i)\nans ^= B[i];\nreturn ans;\n}\n};\n\n[/cpp]\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-717-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3d2nxQG8P9jpthe6hOmO6f","type":"Entry","createdAt":"2020-04-20T12:41:41.543Z","updatedAt":"2026-03-17T22:09:02.074Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":47,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 718","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java"],"creationDate":"2017-07-19T00:00:00.000Z","readTime":"20 min","content":"# Single Round Match 718 Editorials\n\nSome of the SRM 718 Editorials are now published. Check out the editorials of the interesting SRM 718 problems below. Thanks to [Srimaan1316](https://profiles.topcoder.com/Srimaan1316), [marcose18](https://profiles.topcoder.com/marcose18), [Vetteru](https://profiles.topcoder.com/Vetteru) and [bqi343](https://profiles.topcoder.com/bqi343) for contributing to the editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n## RelativeHeights\nSRM 718 Round 1 - Division II, Level One \n-  by [Srimaan1316](https://profiles.topcoder.com/Srimaan1316)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14644)\n\nIn this problem you are given the heights of ‘n’ towers. You are required to choose n-1 of the towers and rank them according to their heights (ranks range between 0 to n-2). So, there would be C(n,n-1) choices. Of these you need to print out the choices that have unique rank ordering. To be more specific, if the rank orderings, for some example sequence, are as follows:\n\n[cpp]\n\n{0,2,3,1,4}\n{4,3,2,1,0}\n{3,4,1,2,0}\n{0,2,3,1,4}\n{2,4,1,0,3}\n{3,4,1,2,0}\n\n[/cpp]\n\nOf the above six possibilities, only 4 orderings look unique and the answer is thus 4.\nYou can follow a brute force method for this problem.\nPseudo Code:\n\n```\n[code]\n\nFor each tower\nRank all the other towers according to their heights.\nPush this rank profile into a set\nReturn the size of the set\n\n[/code]\n```\n\nMy implementation is as follows:\n```\n[cpp]\n\n#include<bits/stdc++.h>\n#define endl '\\n'\nusing namespace std;\nclass RelativeHeights\n{\npublic:int countWays(vector <int> h)\n{\nint hsiz=h.size();\nset<vector<int>> s;\nfor(int i=0;i<hsiz;i++)\n{\nint pos=0;\nvector<pair<int,int>> mp;\nvector<int> ind(hsiz-1);\nfor(int j=0;j<hsiz;j++)\n{\nif(i!=j)\nmp.push_back(make_pair(h[j],pos++));\n}\nsort(mp.begin(),mp.end());\nreverse(mp.begin(),mp.end());\nfor(int k=0;k<hsiz-1;k++)\nind[mp[k].second]=k;\ns.insert(ind);\n}\nreturn s.size();\n}\n};\n\n[/cpp]\n``` \n\n## InterleavingParenthesisDiv2\nSRM 718 Round 1 - Division II, Level Two\n- by [marcose18](https://profiles.topcoder.com/marcose18)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14642)\n\nWe will use dp to solve this problem. Now consider dp[i][j] as total ways of interleaving for first ‘i’ characters of string s1 & ‘j’ characters of string s2. Now it’s pretty easy to see that the last character of this string of length i + j will either be ith character of string s1 or jth character of string s2. Therefore the transitions of dp will be\ndp[i][j] = dp[i - 1][j] + dp[i][j - 1] (check for i = 0 & j = 0)\n\nThat’s pretty much it. Just check few cases like in the end total ‘(‘ characters should match ‘)’ characters and any intermediate dp state should have more ‘(‘ characters than ‘)’ if not that dp value will correspond to zero.\n\n__Java Code__\n\n```\n[java]\n\npublic class InterleavingParenthesisDiv2 {\npublic int mod = 1000000007;\npublic int countWays(String s1, String s2) {\nint n = s1.length(), m = s2.length();\nint[] p1 = new int[n+1], p2 = new int[m+1];\nfor (int i = 1; i <= n; i++) p1[i] = p1[i-1] + (s1.charAt(i-1) == '(' ? +1 : -1);\nfor (int i = 1; i <= m; i++) p2[i] = p2[i-1] + (s2.charAt(i-1) == '(' ? +1 : -1);\nint[][] dp = new int[n+1][m+1];\ndp[0][0] = 1;\nfor (int i = 0; i <= n; i++) {\nfor (int j = 0; j <= m; j++) {\nif (p1[i] + p2[j] < 0) { dp[i][j] = 0; continue; } if (i>0) dp[i][j] += dp[i-1][j];\nif (j>0) dp[i][j] += dp[i][j-1];\ndp[i][j] %= mod;\n}\n}\nreturn p1[n] + p2[m] == 0 ? dp[n][m] : 0;\n}\n}\n\n[/java]\n```\n\n## ChainCity\n\nSRM 718 Round 1 - Division II, Level Three \n- by [Vetteru](https://profiles.topcoder.com/Vetteru)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14643)\n\nThe solution of this problem is binary search.\n\nIn each step of binary search, we will find how many transporters required if all buildings must be at most X/2 distances away from nearest transporter.\nNote that X is a center value of binary search range.\n\nIf all buildings are at most X/2 distances away from nearest transporter, we can move from any building to another building at most X distances.\n\nBecause, start building to nearest transporter is at most X/2, and destination from nearest transporter is at most X/2.\n\nSo, total cost must be at most X.\n\nIf less than or equal to k transporters required, X is possible answer and update the binary search range.\n\nIf more than k transporters required, X is impossible answer and also update the search range.\nTo find how many transporters required, just build a transporter from left to right if current building is more than X/2 distances away from nearest transporter.\nExample)\n\ndist = {3, 5, 4}\nk = 2\nBuildings are at 0, 3, 8, 12\n\n__step 1)__ Range is [0, 12(= 3 + 5 + 4)], X = (0 + 12) / 2 = 6\n\nBuilding at 0 is not covered because no transporter is built.\n\nSo, build transporter at 3(= 0 + 6 / 2) and the transporter is covers from 0 to 6.\nWe don’t need to care about left buildings of current building. Because we build transporter from left to right.\n\nSo, build transporter at 3 is most efficient choice in this situation.\n\n3 is covered because transporter is at 3\n\n8 is not covered. So, build transporter at 11(= 8 + 6 / 2) and covers from 8 to 14.\n\n11 is covered by transporter at 11.\n\nNeed 2 transporter to cover all buildings.\nSo, 6 is possible answer.\nNew range is [0, 6].\n\n__step 2)__ Range is [0, 6], X = 3\n\nBuild transporter at 1.5 and [0, 3] is covered.\nNote that we can build transporter at anywhere.\n\n3 is covered.\n\n8 is not covered. So, build transporter at 9.5 and covers from 8 to 11\n\n12 is not covered. build transporter at 13.5\n\nNeed 3 transporter to cover all buildings.\nSo, 3 is impossible answer.\nNew range is [4, 6]\n\n__step 3)__ Range is [4, 6], X = 4 ((int)4.5)\n\nBuild transporter at 2 and covers from 0 to 4\n\n3 is covered\n\n8 is not covered. build transporter at 10 and covers from 8 to 12\n\n12 is covered\n\nNeed 2 transporter and 4 is possible answer.\n\nnew range is [4, 4]\n\n4 is answer of this case.\n\nComplexity:\nD := distance between first building and last building\nN := number of buildings\nTime Complexity : O(NlogD)\n- logD : cost of binary search\n- N : cost to judge\nSpace Complexity : O(N)\n- N : size of distances array\n\n```\n[java]\n\npublic class ChainCity {\npublic int findMin(int[] dist, int k) {\nint[] pos = convert(dist);\nreturn solve(pos, k);\n}\nprivate int[] convert(int[] dist) {\nint[] pos = new int[dist.length + 1];\nint cur = 0;\nfor (int i = 0; i < dist.length; i++) {\npos[i] = cur;\ncur += dist[i];\n}\npos[dist.length] = cur;\nreturn pos;\n}\nprivate int solve(int[] pos, int k) {\nint l = 0, r = pos[pos.length-1];\nwhile (l < r) { int c = (l + r) / 2; if (isPossible(c, k, pos)) { r = c; } else { l = c + 1; } } return r; } private boolean isPossible(int x, int k, int[] pos) { int coverTo = -1; for (int p : pos) { if (p > coverTo) {\nk--;\ncoverTo = p + x;\n}\n}\nreturn k >= 0;\n}\n}\n\n[/java]\n```\n\n## InterleavingParenthesis\nSRM 718 Round 1 - Division I, Level One\n- by [bqi343](https://profiles.topcoder.com/bqi343)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14635)\n\nThis is a straightforward dynamic programming problem. We need to count the number of strings which satisfy the following two conditions:\n\ncontains an equal number of left and right parentheses\n\nat no point in the string does the number of right parentheses exceed the number of left parentheses\n\nLet dp[i][j] be of the number of ways to combine the first i characters of s1 and the first j characters of s2 into a string such that the second condition is satisfied. If there are more right parentheses than left parentheses among the first i characters of s1 and the first j characters of s2, then we set dp[i][j]=0, because the second condition will be violated. Otherwise, we set dp[i][j]=dp[i-1][j]+dp[i][j-1], taking mod 10^9+7 as necessary.\nFinally, we must check if the first condition holds when we use all characters from both strings. If it does, the answer is dp[s1.length()][s2.length()]. Otherwise, the answer is 0.\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\n#define FOR(i, a, b) for (int i=a; i<b; i++)\n#define F0R(i, a) for (int i=0; i<a; i++)\nconst int MOD = 1000000007;\nclass InterleavingParenthesis {\npublic:\nint dp[2501][2501], cum1[2501], cum2[2501];\nint countWays(string s1, string s2) {\nF0R(i,2501) F0R(j,2501) dp[i][j] = 0;\nF0R(i,2501) cum1[i] = cum2[i] = 0;\nF0R(i,s1.length()) {\ncum1[i+1] = cum1[i];\nif (s1[i] == '(') cum1[i+1] ++;\nelse cum1[i+1] --;\n}\nF0R(i,s2.length()) {\ncum2[i+1] = cum2[i];\nif (s2[i] == '(') cum2[i+1] ++;\nelse cum2[i+1] --;\n}\ndp[0][0] = 1;\nF0R(i,s1.length()+1) F0R(j,s2.length()+1) if (cum1[i]+cum2[j] >= 0) {\nif (i > 0) dp[i][j] = (dp[i][j]+dp[i-1][j]) % MOD;\nif (j > 0) dp[i][j] = (dp[i][j]+dp[i][j-1]) % MOD;\n}\nif (cum1[s1.length()]+cum2[s2.length()] == 0) return dp[s1.length()][s2.length()];\nreturn 0;\n}\n};\n\n[/cpp]\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-718-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4D6SKwYjZRlOYWTIUM5PL2","type":"Entry","createdAt":"2020-04-20T12:41:41.734Z","updatedAt":"2026-03-17T19:35:25.916Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":66,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 719","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++"],"creationDate":"2017-09-20T00:00:00.000Z","readTime":"20 min","content":"# Single Round Match 719 Editorials\n\nSome of the SRM 719 Editorials are now published. Check out the editorials of the interesting SRM 719 problems below. Thanks to [Shizhouxing](https://www.topcoder.com/members/Shizhouxing), [nitish_](https://profiles.topcoder.com/nitish_) and [square1001](https://profiles.topcoder.com/square1001) for contributing to the editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n## LongLiveZhangzj\nSRM 719 Round 1 - Division II, Level One \n-  by [Shizhouxing](https://www.topcoder.com/members/Shizhouxing)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14675)\n\nWe need to count the number of words that are exciting in __speech__.\n\nFor each word s[i] in __speech__, we just check whether there is a word in __words__ which is exactly the same as s[i]. If so, word s[i] is considered to be exciting. The answer to the problem is the number of exciting words in __speech__.\n\n__Code__:\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\nclass LongLiveZhangzj\n{\npublic:\nint donate(vector <string> speech, vector <string> words)\n{\nint ans = 0;\nfor (auto x:speech) {\nint exciting = 0;\nfor (auto y:words)\nif (x == y) exciting = 1;\nans += exciting;\n}\nreturn ans;\n}\n};\n\n[/cpp]\n```\n\n## LongMansionDiv2\nSRM 719 Round 1 - Division II, Level Two\n- by [nitish_](https://profiles.topcoder.com/nitish_)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14674)\n\nIn total, it will be optimal to move only (N + M - 1) steps where N - the number of rows, M - the number of columns.This problem is a problem of a shortest path in a 2-D grid. Weights for crossing each box are given in an int[].The best solution for this problem is by greedy approach.\n\nReason for this is that it is optimal to choose a row with minimum weight and move horizontally across that row only because it will add minimum weight to the solution. Thus, the solution will be equal:\n\nans = M*(minumum_weight_among_all_rows) + cost_of_single_step_on_every_other_row.\n\n__Code__:\n\n```\n[cpp]\n#include <bits/stdc++.h>\nusing namespace std;\nclass LongMansionDiv2 {\npublic:\nlong long minimalTime(int M, vector <int> t) {\nlong long ans = 0;\nlong long sum = 0;\nfor(int i =0; i < t.size(); ++i)\nsum += t[i];\nlong long minm = *min_element(t.begin(), t.end());\nans = minm*M + sum - minm;\nreturn ans;\n}\n}\n\n[/cpp]\n```\n\n__Note:__ use long long to avoid overflow.\n__Complexity:__ O(N), since we iterate over the input array.\n\n## TwoDogsOnATree\nSRM 719 Round 1 - Division II, Level Three \n- by [nitish_](https://profiles.topcoder.com/nitish_)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14673)\n\nFirstly, root the tree at vertex 0. In a tree, between any two nodes, there is exactly only one path. Hence, in order to solve this problem, we should be able to find the XOR of all the weights on the path as quickly as possible. This can be done in O(N) preprocessing and O(1) for query.\n\nFind the XOR of edges of all the vertex from the root vertex and store it in XOR[].\nThus, XOR[x] will store the XOR of all the edges in the path between node x and the root. Now to compute this between any two vertex (x , y), simply xor the XOR[x]^XOR[y] in O(1). This statement is true, because if vertex x and y lie different side of root, then the path must go through the root, and one path is kind of extension of another. Otherwise, if they lie on the same side of root, then the repeated edges are disabled with xor operation, because x^x = 0; and 0^x = x. That’s why the above statement is correct.\n\nNow, suppose you choose a pair of nodes (a,b) for DOG 1 and another pair of nodes (c,d) for DOG 2. If there is no common edge between the two paths, then the result of A XOR B i.e. A^B = (XOR[a] ^ XOR[B])^(XOR[C]^XOR[d]), where A and B were the results for first and second paths respectively.\n\nNow, consider the other case, when there is overlapping of edges, then in that case, we can choose another permutation formed with same set of nodes which does not overlap i.e : either {(a, c) ,(b,d)} or {(a,d), (b,c)}. Result for any of these combination would result same as above. A^B = (XOR[a] ^ XOR[B])^(XOR[C]^XOR[d]).\n\nThus, the problem reduces to choosing 4 vertex a, b, c, d for which the XOR[a]^XOR[b]^XOR[C]^XOR[d] is maximum.\n\nTo solve this, There are many methods:\nFirstly, make a set of distinct values of all the pairs from the available nodes. This will give you maximum of N* N distinct values.\n\nNow, among all these pairs, Take the XOR of all pairs and return the maximum from it.\n\n__Code__:\n\n```\n[cpp]\n\n#include <vector>\n#include <set>\n#include <algorithm>\n#include <cmath>\nusing namespace std;\nclass TwoDogsOnATree {\npublic:\nint XOR[1020];\nint maximalXorSum(vector<int> parent, vector<int> w)\n{\nint n = parent.size() + 1;\nint ans = 0;\nset<int> st;\nfor (int i = 1; i < n; ++i) {\nXOR[i] = XOR[parent[i - 1]] ^ w[i - 1];\n}\nfor (int i = 0; i < n; ++i) {\nfor (int j = 0; j < i; ++j)\nst.insert(XOR[i] ^ XOR[j]);\n}\nset<int>::iterator it1;\nset<int>::iterator it2;\nfor (it1 = st.begin(); it1 != st.end(); ++it1) {\nfor (it2 = st.begin(); it2 != st.end(); ++it2)\nans = max(ans, *it1 ^ *it2);\n}\nreturn ans;\n}\n};\n\n[/cpp]\n```\n\n__Complexity__: O(N ^ 4), since there will be N^2 elements in st set.\n\n## LongMansionDiv1\nSRM 719 Round 1 - Division I, Level One \n- by [square1001](https://profiles.topcoder.com/square1001)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14641)\n\n__Make problem more simple__\n![SRM719 1](//images.ctfassets.net/piwi0eufbb2g/1XwCxHDXT8e0do3ZrHIAKH/dbcfb97436d279e836190a2b9ca3e2c2/SRM719_1.webp)\n\nYou are given a grid with H (H ≤ 50) rows by W (W ≤ 109) columns. Cell in i-th row and j-th column denotes (i, j). Each cell in a grid has written a positive integer. Also, each cell in the same row has written the same value ai. You are given the position of starting cell (sx, sy) and finishing cell (gx, gy). You can move to 4-directions (up, down, right, left). Calculate the minimum sum of numbers written in passed cells.\n\n__The solution__\n\nThe optimal solution is, amazingly, can always construct by following 3 steps. Pay attention that is assuming sy ≤ gy (because if sy > gy you can swap start and goal).\na. Move some cells upwards or downwards.\nb. Move right gy-sy times.\nc. Move some cells upwards or downwards and reach goal.\n\n![SRM719 2](//images.ctfassets.net/piwi0eufbb2g/2qDJgrXat3sEprJdmxQywS/e46d4abb1348514a0d3d907b167301c3/SRM719_2.webp)\n\nYou can choose row which uses in step b (row of finishing step a). In the constraint H ≤ 50, you can brute-force and get minimum of it. Also, you can calculate the cost of the path in O(H), so the total time complexity is O(H2).\n\n__Why this is optimal?__\n\n1. Moving extra left and right direction is not good\nMoving left and right more times than shortest, is a waste of cost. Why? You can see from the picture.\n\n![SRM719 4](//images.ctfassets.net/piwi0eufbb2g/4GG1WTmkYiEvxH5jbLnxd0/d71dd22a2347f7e4a9d56f7e93b70e7c/SRM719_4.webp)\n\nYou can erase the left arrow (assuming sy ≤ gy) and corresponding right arrow. Also, you can move the disconnected part one cell right. As all numbers in same row is same, the reduced cost is always the cost in left arrow row and plus cost in right arrow row, so it is always higher than zero.\n\n2. Moving right in different row is not good\nFirst, see the example in the picture.\n\n![SRM719 6](//images.ctfassets.net/piwi0eufbb2g/4XwScvRVt9WD9Wha0XgES9/8a6469f685d1b99465e33a85ece15057/SRM719_6.webp)\n\nIn this example, the left one costs 3A+3B+C, the middle one costs 5A+B+C, and the right one costs A+5B+C. You can see that for any real number A, B, C, 3A+3B+C≤max(5A+B+C,A+5B+C). You can prove it by solving in case of A>B, A=B, A<B, and using that the number in the same row is the same. And, in any pattern, you can reduce zero or more cost with “two row that uses right arrow to one row”, like left to middle or right one in the example.\n\nIf you do operation in 1. and 2. completely, you can get the path that can get from 3 steps that I first mentioned. So it means the optimal solution is in one of the way which can get from “3 steps”.\n\nCode:\n```\n[cpp]\n\n#include <cmath>\n#include <vector>\n#include <algorithm>\nusing namespace std;\nclass LongMansionDiv1 {\npublic:\nlong long minimalTime(vector<int> v, int sx, int sy, int ex, int ey) {\nint n = v.size();\nlong long ret = 1LL << 62;\nfor (int i = 0; i < n; i++) {\nlong long res = 1LL * v[i] * (abs(sy - ey) - 1);\nfor (int j = min(sx, i); j <= max(sx, i); j++) res += v[j];\nfor (int j = min(ex, i); j <= max(ex, i); j++) res += v[j];\nret = min(ret, res);\n}\nreturn ret;\n}\n};\n\n[/cpp]\n```\n\n__Bonus__: Also, if you use prefix sum technique, you can get the answer in time complexity O(H). Let’s think about the solution!","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-719-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5LR63W2skhcYLsxcAhOkYc","type":"Entry","createdAt":"2020-04-20T12:41:37.094Z","updatedAt":"2026-03-15T19:15:52.351Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":53,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 720","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java"],"creationDate":"2017-08-30T00:00:00.000Z","readTime":"15 min","content":"# Single Round Match 720 Editorials\n\nSRM 720 Editorials are now published. Thanks to [kapillamba4](https://profiles.topcoder.com/kapillamba4) and [marcose18](https://profiles.topcoder.com/marcose18) for contributing to the editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n## DistinctGridEasy\nSRM 720 Round 1 - Division II, Level One\n- by [marcose18](https://profiles.topcoder.com/marcose18)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14668)\n\nWe will solve this question with bruteforce. For each row and each column we will check if that row or column contains exactly k distinct elements or not. To check that we can use HashSet (Java) or unordered_set (C++).\n\nBelow is the working code in Java explained with appropriate comments.\n\n__Java Code__\n\n```\n[cpp]\n\nimport java.util.*;\nimport java.util.regex.*;\nimport java.text.*;\nimport java.math.*;\npublic class DistinctGridEasy {\npublic String checkGrid(int n, int k, int[] grid) {\nint matrix[][] = new int[n][n];\nfor (int i = 0; i < n; i++) { // make actual 2D matrix from given array.\nfor (int j = 0; j < n; j++)\nmatrix[i][j] = grid[i * n + j];\n}\nHashSet<Integer> set;\nfor (int i = 0; i < n; i++) {\nset = new HashSet<>();\nfor (int j = 0; j < n; j++) //check if ith row contains exactly k elements.\nset.add(matrix[i][j]);\nif (set.size() != k)\nreturn \"Bad\";\nset = new HashSet<>();\nfor (int j = 0; j < n; j++) //check if jth column contains exactly k elements\nset.add(matrix[j][i]);\nif (set.size() != k)\nreturn \"Bad\";\n}\nreturn \"Good\"; /*Finally return Good if each row and column contains\n} exactly k distinct elements.\n*/\n}\n[/cpp]\n```\n\n## MinProduct \nSRM 720 Round 1 - Division II, Level Two \n\n- by [kapillamba4](https://profiles.topcoder.com/kapillamba4)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14666)\n\nWe are given multiple copies of digits whose value is between 0 to 9 inclusive.\nUsing those digits we have to construct 2 numbers A and B such that their product is minimum and for both number A, B leading zeroes are allowed.\n\nSize of number A should be __blank1__ digits.\nSize of number B should be __blank2__ digits.\n\n__Constraints__\n1 ```<``` blank1 ```<``` 10\n1 ```<``` blank2= blank1+blank2. Therefore the maximum size of our digits vector will 9+9 = 18 (blank1 + blank2)\n\nSize of our digits vector is now equal to blank1+blank2.\n\nNow for each digit in digits vector we can decide to either put it in A or B. Therefore the total number of possibilities of creating A and B will be 2**(blank1+blank2) which is at max equal to 2**18 = 262144\n\nWe can iterate from 0 to 2**(blank1+blank2) using bitmask and for each bit ‘j’ in each number ‘i’ from 0 to 2**(blank1+blank2) we put digits[j] in A if j’th bit is set (is one) else we place it in B if the j’th bit is not set (is zero).\n\nFor each number ‘i’, after constructing A and B we check if size of A is blank1 and size of B is blank2, We update our answer with each iteration.\n\nRefer here to know how to iterate over of all subsets of a set using bitmasks.\nThe time complexity of the above solution is O(size * (2**size) ) where size is length of our digits vector.\n\n(maximum value of size is 18 as per the problem)\n\n__C++ Code__\n\n```\n[cpp]\n\n#include\nusing namespace std;\ntypedef long long ll;\nclass MinProduct {\nll pow2[20];\npublic:\nll findMin(vector amount, int blank1, int blank2) {\nstring digits;\nint j = 0;\nfor(int i = 0; i &lt; blank1+blank2; i++) {\nwhile(amount[j] == 0) ++j;\ndigits.push_back('0'+j);\namount[j]--;\n}\npow2[0] = 1;\nfor(ll i = 1; i &lt; 20; i++) {\npow2[i] = pow2[i-1]*2;\n}\nll ans = LLONG_MAX;\nfor(ll i = 0; i &lt; pow(2, digits.size()); i++) {\nstring A, B;\nfor(ll j = 0; j &lt; digits.size(); j++) {\nif(i &amp; pow2[j]) {\nA.push_back(digits[j]);\n} else {\nB.push_back(digits[j]);\n}\n}\nif(A.size() != blank1 || B.size() != blank2) {\ncontinue;\n}\nans = min(ans, stoll(A)*stoll(B));\n}\nreturn ans;\n}\n};\n[/cpp]\n```\n\n## SumProduct\nSRM 720 Round 1 - Division I, Level One\n\n- by [kapillamba4](https://profiles.topcoder.com/kapillamba4)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14661)\n\nWe are given multiple copies of digits from 0 to 9, an array ‘amount’ denotes the number of occurance of each digit from 0 to 9 inclusive.\n\nWe have to add the product of all distinct pairs of numbers A, B constructed using given copies of digits. Here leading zeroes are allowed.\nSize of number A should be __blank1__ digits.\nSize of number B should be __blank2__ digits.\n\n__Constraints:__\n0 < amount[i] <= 100\n1 < blank1 <= 100\n1 < blank2 <= 100\n\nFor each of i’th place in number A and j’th place in number B in Base-10 representation, fix digit value di for number A and digit value dj for number B and then calculate the number of occurrences of distinct pairs (A, B) such that for the pair di is present at i’th place in A and \ndj is present at j’th place in B.\n0 ```<``` i ```<``` blank1\n0 ```<``` j ```<``` blank2\n0 ```<=``` di ```<``` 10\n0 ```<=``` dj ```<``` 10\n\nAdd the result of ((10**i) * di * (10**j) * dj) * (occurrences) to the final ans with each iteration where `occurances` is the number of distinct pairs (A, B) such that di digit occurs at i'th place in A and dj digit occurs at j'th place in B.\n\nLet d[size][x][di][dj] denote the number of ways to fill in ‘size’ places using digits only available from x to 9 inclusive and digits di, dj are fixed.\n\nThe `occurances` can be calculated as d[blank1+blank2-2][0][di][dj] after placing di at i’th place and dj at j’th place.\n\nAll blank1+blank2-2 places (after fixing di and dj digits) in base-10 representation for A and B are distinct. Therefore choosing `y` places among `size` places is given by nCr(size, y) = size!/(y!* (size-y)!)\n\nTherefore the recursive relation is d[size][x][di][dj] = ∑d[size-y][x+1][di][dj]* nCr(size, y) where 0 <= y <= min(size, amount[i])\n\nd[size][x][di][dj] = 0 if size != 0 and x = 10 (maximum value of a digit in base-10 representation + 1 = 9 + 1 = 10)\n\nd[size][x][di][dj] = 1 if size = 0 and x = 10 (maximum value of a digit in base-10 representation + 1 = 9 + 1 = 10)\n\nBinomial coefficient (nCr) can be calculated in constant time if factorials and modular inverse of factorials of numbers from 0 to blank1+blank2 are calculated and memoized beforehand.\nTherefore the time complexity for choosing i, j, di and dj will be O(blank1* blank2 * max(di)* max(dj)) and time complexity for calculating the number of distinct pairs (A, B) after using memoization will be around O((blank1+blank2-2)* max(x)* max(di)* max(dj)* min(amount[x], size))\nO(blank1* blank2 * max(di)* max(dj) + (blank1+blank2-2)* max(x)* max(di)* max(dj)* min(amount[x], size))\n\nwhere maximum value of di, dj, x can be 10\n\nand maximum value of min(amount[x], size) can be 10\n\n__C++ Code__\n\n```\n[cpp]\n\n#include\nusing namespace std;\ntypedef long long ll;\nconst ll MOD = 1000000007;\nll d[205][10][10][10];\nll fac[205];\nll invFac[205];\nclass SumProduct {\npublic:\nll power(ll a, ll b) {\nif(a == 0) return 0;\nif(b == 1) return a;\nif(b == 0 || a == 1) return 1;\nif(b % 2) {\nreturn (power((a*a)%MOD, b/2)*a)%MOD;\n} else {\nreturn power((a*a)%MOD, b/2);\n}\n}\nll nCr(ll n, ll r) {\nreturn (((fac[n]*invFac[r])%MOD)*invFac[n-r])%MOD;\n}\nll occur(int i, int size, vector &amp;amount, int x, int y) {\nif(size != 0 &amp;&amp; i == amount.size()) return 0;\nif(size == 0 &amp;&amp; i == amount.size()) return 1;\nif(d[size][i][x][y] != -1) return d[size][i][x][y];\nll ans = 0;\nfor(int j = 0; j &lt;= min(amount[i], size); j++) {\n// nCr(size, j) gives number of ways to\n// choose ‘j’ places from ‘size’ places\nans += (occur(i+1, size-j, amount, x, y)*nCr(size, j))%MOD;\nans %= MOD;\n}\nreturn (d[size][i][x][y] = ans);\n}\nll findSum(vector amount, int blank1, int blank2) {\nfor(int i = 0; i &lt; 205; i++) {\nfor(int j = 0; j &lt; 10; j++) {\nfor(int k = 0; k &lt; 10; k++) {\nfor(int z = 0; z &lt; 10; z++) {\nd[i][j][k][z] = -1;\n}\n}\n}\n}\nfac[0] = 1;\ninvFac[0] = 1;\nfor(ll i = 1; i &lt; 205; i++) {\nfac[i] = (fac[i-1]*i)%MOD;\ninvFac[i] = (invFac[i-1]*power(i, MOD-2))%MOD;\n}\nll ans = 0;\nfor(int i = 0; i &lt; blank1; i++) {\nfor(int j = 0; j &lt; blank2; j++) {\nfor(int di = 0; di &lt; 10; di++) {\nfor(int dj = 0; dj = 0 &amp;&amp; amount[dj] &gt;= 0) {\nll a = (di*power(10, i))%MOD;\nll b = (dj*power(10, j))%MOD;\nll occurance = occur(0, blank1+blank2-2, amount, di, dj);\nans += (((a*b)%MOD)*occurance)%MOD;\nans %= MOD;\n}\namount[di]++;\namount[dj]++;\n}\n}\n}\n}\nreturn ans;\n}\n};\n\n[/cpp]\n\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7M4Mi2lee2fNvwwkdUle1b","type":"Entry","createdAt":"2020-04-20T12:41:39.297Z","updatedAt":"2020-04-20T12:41:39.297Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Aditya","tcHandle":"Aditya"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-720-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2KmP6yXtve3KIAk0ChzYOk","type":"Entry","createdAt":"2020-04-20T12:41:37.073Z","updatedAt":"2026-03-15T17:49:51.550Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":66,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 721","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2017-11-21T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 721 Editorials\n\nSome of the SRM 721 Editorials are now published. Check out the editorials of the interesting SRM 721 problems below. Thanks to [erk52](https://profiles.topcoder.com/erk52), [marcose18](https://profiles.topcoder.com/marcose18), [nitish_](https://profiles.topcoder.com/nitish_), [hl_a_k](https://profiles.topcoder.com/hl_a_k) and [square1001](https://profiles.topcoder.com/square1001) for contributing to the editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n## FlightDataRecorder\nSRM 721 Round 1 - Division II, Level One \n\n- by [erk52](https://profiles.topcoder.com/erk52)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14711)\n\nYou are given two arrays: one contains headings in degrees (e.g., 0 is east, 90 is north, 180 is west, 270 is south), and one contains distances travelled in those headings. The goal is to calculate the final position of the airplane that followed the given headings for the given directions. For example, if you are given [0,90], [3, 4], this describes a plane that flew 3 units east, and 4 units north, resulting in a final distance of 5 from the origin.\nThis is a straightforward problem that relies on some simple trigonometry.  We have an array of headings, and an array of distances. All we need to do is take each heading-direction pair, convert this into an x-distance and a y-distance, and sum each of these components to find the final position of the plane.\n\nTo convert from heading-direction to 2D Cartesian coordinates, we apply a simple transformation:\nx = r cos θ\ny = r sin θ\n\nIn this problem, r is the distance and theta is the heading. The built-in sin and cos functions are expecting the argument in radians. So we have to multiply by a factor of pi/180 to convert our headings from degrees into radians.\nOnce we know the final x and y positions of the plane, finding the distance is a simple application of the Pythagorean theorem:\nd^2 = x^2 + y^2\nd = sqrt(x^2 + y^2)\n\n__Python Code:__\n\n```\n[cpp]\n\nimport math\nclass FlightDataRecorder:\ndef getDistance(self, heading, distance):\ntotal_x, total_y = 0,0\nfor i in range(len(heading)):\nr = distance[i]\ntheta = heading[i]\ntotal_x += r*math.cos(math.pi*theta/180)\ntotal_y += r*math.sin(math.pi*theta/180)\nreturn math.sqrt(total_x**2 + total_y**2)\n\n[/cpp]\n```\n\n## RememberWordsEasy\nSRM 721 Round 1 - Division II, Level Two \n\n- by [marcose18](https://profiles.topcoder.com/marcose18)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14708)\n\nWe will solve this question by bruteforce.\n\nThe possible values on day d1 will be between 0 and w1, inclusive. And for each possible value(let’s say i) where 0 <= i <= w1, possible values of words learnt on day (d1 + 1) will be i - 1, i, i + 1, because absolute difference can be atmost 1 between each consecutive days.\nNow, for each combination of words learnt on day d1 and day (d1 + 1) which is nothing but (i, i - 1), (i, i), (i, i + 1), we will calculate minimum words that can be learnt in both semesters and maximum words that can be learnt in both semesters. If total words that are to be learnt in a particular semester is in between minimum and maximum for that particular semester in both cases, then we return string “Possible”. Otherwise if no combination exists, the answer is “Impossible”.\n\nNow if words learnt on day d1 is i, then minimum possible words learnt in first semester will be i + (i - 1) + (i - 2) …...max(1, i - d1 + 1) and maximum words that can be learnt are i + (i + 1) + (i + 2) …….(i + d1 - 1). Similarly it can be calculated for the second semester.\n\n__Java Code:__\n\n```\n[cpp]\n\nimport java.util.*;\nimport java.util.regex.*;\nimport java.text.*;\nimport java.math.*;\npublic class RememberWordsEasy {\nstatic boolean check(int i, int j, int w1, int w2, int d1, int d2) {\nlong low_i = Math.min(d1, i) * 1L * (i + Math.max(1, i - d1 + 1)) / 2;\nlong high_i = d1 * 1L * (i + i + d1 - 1) / 2;\nlong low_j = Math.min(d2, j) * 1L * (j + Math.max(0, j - d2 + 1)) / 2;\nlong high_j = d2 * 1L * (j + j + d2 - 1) / 2;\nif (w1 >= low_i && w1 <= high_i && w2 >= low_j && w2 <= high_j)\nreturn true;\nreturn false;\n}\npublic String isPossible(int d1, int d2, int w1, int w2) {\nfor (int i = 0; i <= w1; i++) {\nfor (int j = i - 1; j <= i + 1; j++)\nif (check(i, j, w1, w2, d1, d2))\nreturn \"Possible\";\n}\nreturn \"Impossible\";\n}\n}\n\n[/cpp]\n```\n\n## ApocalypseEasy\nSRM 721 Round 1 - Division II, Level Three \n\n- by  [hl_a_k](https://profiles.topcoder.com/hl_a_k)\n\n[Problem Details](http://archive.topcoder.com/ProblemStatement/pm/14710)\n\nThe key observation of this problem is that this is a maximum bipartite matching problem.\nThe nodes in position will be destroyed; others nodes will be safe.\nIn the problem statement, we know, in each turn we can move each token at most once. During the turns each node may temporarily contain arbitrarily many tokens. At the very end, each node must again contain at most one token.\n\nSo, every node in position corresponds to some safe node. We can precalculate the matching graph, then find the maximum bipartite matching.\n\n__Code__:\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\n#define ll long long\n#define FT(i,f,t) for(int i=f;i<=t;++i) #define TF(i,t,f) for(int i=t;i>=f;--i)\n#define REP(i,n) for(int i=0;i<n;++i)\n#define MM(a,v) memset(a,v,sizeof(a))\n#define ITR(it,ct) for(auto it=ct.begin();it!=ct.end();++it)\n#define MOD 1000000007\nint g[55][55];\nbool bpGraph[55][55];\nconst int INF = INT_MAX / 2;\n#define M 55\n#define N 55\n// A DFS based recursive function that returns true if a\n// matching for vertex u is possible\nbool bpm(bool bpGraph[M][N], int u, bool seen[], int matchR[])\n{\n// Try every job one by one\nfor (int v = 0; v < N; v++)\n{\n// If applicant u is interested in job v and v is\n// not visited\nif (bpGraph[u][v] && !seen[v])\n{\nseen[v] = true; // Mark v as visited\n// If job 'v' is not assigned to an applicant OR\n// previously assigned applicant for job v (which is matchR[v])\n// has an alternate job available.\n// Since v is marked as visited in the above line, matchR[v]\n// in the following recursive call will not get job 'v' again\nif (matchR[v] < 0 || bpm(bpGraph, matchR[v], seen, matchR))\n{\nmatchR[v] = u;\nreturn true;\n}\n}\n}\nreturn false;\n}\n// Returns maximum number of matching from M to N\nint maxBPM(bool bpGraph[M][N])\n{\n// An array to keep track of the applicants assigned to\n// jobs. The value of matchR[i] is the applicant numbers\n// assigned to job i, the value -1 indicates nobody is\n// assigned.\nint matchR[N];\n// Initially all jobs are available\nmemset(matchR, -1, sizeof(matchR));\nint result = 0; // Count of jobs assigned to applicants\nfor (int u = 0; u < M; u++)\n{\n// Mark all jobs as not seen for next applicant.\nbool seen[N];\nmemset(seen, 0, sizeof(seen));\n// Find if the applicant 'u' can get a job\nif (bpm(bpGraph, u, seen, matchR))\nresult++;\n}\nreturn result;\n}\nstruct ApocalypseEasy {\nint maximalSurvival(vector<int> p, vector<int> position, int t) {\nint n = p.size() + 1;\nREP(i,55)\nREP(j,55){\ng[i][j] = INF;\n}\nMM(bpGraph,false);\nREP(i,n - 1){\ng[p[i]][i+1] = g[i+1][p[i]] = 1;\n}\nREP(k,n)\nREP(i,n)\nREP(j,n){\ng[i][j] = min(g[i][j],g[i][k] + g[k][j]);\n}\nset<int> ps(position.begin(),position.end());\nset<int> valid;\nREP(i,n){\nif(ps.find(i) == ps.end()){\nvalid.insert(i);\n}\n}\nfor(auto &p:position){\nfor(auto &_t:valid){\nif(g[p][_t] <= t){\nbpGraph[p][_t] = true;\n}\n}\n}\nreturn maxBPM(bpGraph);\n}\n};\n\n[/cpp]\n```\n\n## RememberWords\nSRM 721 Round 1 - Division I, Level One \n\n- by [nitish_](https://profiles.topcoder.com/nitish_)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14707)\n\nTo solve this problem, we have to be concerned about the d1-th day and (d1+1)-th day of the college semester.\n\nThe difference between the work load between these two days should be less than or equal to 1. If we are able to find a solution for this, then solution exists, otherwise not.\n\nWe will find the maximum and minimum permissible value for the day d1 and day (d1+1). Now, it it easy to see that any value can be achieved between this range (because we can increase or decrease or remain constant our value over a range). To find this, we will use binary search over the search space.\n\nIn case of finding the minimum permissible value we can assume a value which could be achieved at the end of sequence and rest of the terms before that is greater than that, thus the sum of range is given by = a*n + (n*n-1)/2 where a = last term of sequence, n = number of terms.\nIn case of maximum permissible value, if we want to a maximum value at the end of a sequence, then other terms before than that should decrease by one. Thus the sum of this range is given by = a*n - (n*n-1)/2. Be sure to handle the case where number of terms(i.e. \"d\" ) gets lower that your assumed maximum value, some of your terms of arithmetic progression will get negative. We dont want that.\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\n#define ll long long\n#define INF 1000000000LL\nusing namespace std;\nclass RememberWords {\npublic:\nll bin_min(ll d, ll w) //d = no. of terms, w = sum of terms\n{\nll lo= 0LL, hi = INF, mid;\nwhile(hi > lo)\n{\nmid =(hi +lo)/2;\nll sum = mid*d + d*(d-1)/2;\nif(sum < w) lo = mid +1; else hi = mid; } return lo; } ll bin_max(ll d, ll w) { ll lo = 0LL, hi = INF, mid; while(hi> lo)\n{\nmid = (hi+lo+1)/2;\nll sum = d*mid - d*(d-1)/2;\nif(mid < d)\n{\nsum = mid*(mid+1)/2;\nif(sum < w) lo = mid; else hi = mid-1; } else { if(sum > w)\nhi = mid-1;\nelse\nlo = mid;\n}\n}\nreturn lo;\n}\nstring isPossible(int d1, int d2, int w1, int w2) {\nll min1,min2,max1,max2;\nmin1 = bin_min(d1,w1);\nmax1 = bin_max(d1,w1);\nmax2 = bin_max(d2,w2);\nmin2 = bin_min(d2,w2);\n//cout<<d1min<<\" \"<<d1max<<\" \"<<d2min<<\" \"<<d2max<<endl; if(min1 > max1 or min2 > max2)\nreturn \"Impossible\";\nelse if(max1+1 == min2)\nreturn \"Possible\";\nelse if(max2+1 == min1)\nreturn \"Possible\";\nelse if(max(min1, min2) <= min(max1, max2))\nreturn \"Possible\";\nelse return \"Impossible\";\n}\n};\n\n[/cpp]\n```\n\n## GraphAndPairs\nSRM 721 Round 1 - Division I, Level Two\n\n- by [square1001](https://profiles.topcoder.com/square1001)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14714)\n\n![SRM721 1](//images.ctfassets.net/piwi0eufbb2g/4AYmT9JOMc0nkEQIJ3NAWj/3986eef923668f5e0af3117d10572bf8/SRM721_1.webp)\n\nLook at the picture in above. This graph makes 25 pairs of vertices (x, y) in the which distance between vertex x and vertex y is exactly 4.\n\nLet a be the number of red vertices, let b be the number of blue vertices, and let c be the number of green vertices.\n\nLet’s consider the case which constructs the tree graph by adding edges, from each red vertex to the first green vertex, from each blue vertex to the last green vertex, and from the i-th green vertex to the (i+1)-st green vertex (1 ≤ i ≤ c-1).\n\nIf c ≥ 2, the distance between vertex x and vertex y is c+1 if and only if either x or y is a red vertex and another is a blue vertex. The reason is, if one is a red vertex and another is blue, the distance between x and y is c+1, and if either x or y belongs to a green vertex, the distance between x and y is less than c+1, and if x and y are both red vertices, the distance is 2 if x ≠ y and otherwise 0, and similarly if x and y are both blue vertices.\n\nSo, if you set c = d-1, the number of good pairs is ab and the number of vertices is a + b + c = + b + d - 1. Note that this statement is only established if c ≥ 2 (therefore d ≥ 3).\n\nThe case of d ≥ 3\n\nLet √k be the floor of the square root of k.\nIf you set (a, b) = (√k, √k), you can make (√k)2 good pairs with 2√k + d - 1 vertices.\nNow you have to make extra k - (√k)2 good pairs by making another graph as connected components. If you set (a, b) = (k - (√k)2, 1), you can make k - (√k)2 good pairs with k - (√k)2 + d vertices.\n\nBy combining the two graphs, you can make s good pairs with 2√k + k - (√k)2 + d - 1 vertices. As k ≤ 50000, the maximum value of √k is 223, and the maximum value of k - (√k)2 is 444 because it’s the difference of s and the largest square number less than or equal to k.\n\nAs d ≤ 50, the maximum number of vertices is less than or equal to 2 × 233 + 444 + 2 × 50 - 1 = 989. Since the graph is a forest, the number of edges is less than number of vertices, so it satisfies the condition of |V| ≤ 1000, |E| ≤ 1000 (|V| is the number of vertices, and |E| is the number of edges).\nThe case of d = 2\n\nThe constructing style of case d ≤ 3 and case d = 2 is quite different.\nFirst, a star graph Sa = K1,a contains C(a, 2) = a(a-1)/2 vertex pairs which distance between one and another is 2.\n\nSecond, a path graph Pb contains max(b-2, 0) vertex pairs which distance between one and another is 2.\n\nIf you maximize a, you can minimize b since a ≥ 1. Let’s think about maximizing a. Solving the inequality a(a-1)/2 ≤ k, you get\n\n![SRM721 2](//images.ctfassets.net/piwi0eufbb2g/5A3LZnfJ4ApHpaK9v6JTYy/e6229b2d7c5b82296130e0dd0361b293/SRM721_2.webp)\n\nSince k ≥ 1, a = 1 is always one solution, so the maximum value of a is\n\n![SRM721 3](//images.ctfassets.net/piwi0eufbb2g/25CEF0LSixyhD3kouUHEV4/ca8c5cb19fa87bbdd6e41837750e6087/SRM721_3.webp)\n\nIf you set (a, b) =\n\n![SRM721 4](//images.ctfassets.net/piwi0eufbb2g/6kR2Xw1OVZyNyX1r9563fB/f7e0e5dceb9d873ee172b6fffe22d5d8/SRM721_4.webp)\n\n,the number of good pairs will be k. Since k ≤ 50000 => a ≤ 316, it follows that b ≤ ½ × 316 × 315 - ½ × 315 × 314 = 315, so the number of vertices will be less than or equal to a + b + 3 = 624. Since the graph is a forest, the number of edges is less than the number of vertices, so it satisfies the condition of |V| ≤ 1000, |E| ≤ 1000.\n\n```\n[cpp]\n\n#include <cmath>\n#include <vector>\n#include <algorithm>\nusing namespace std;\nclass GraphAndPairs {\npublic:\nvector<int> construct(int d, int k) {\nvector<int> ret;\nif (d >= 3) {\nint sq = sqrt(k) + 1.0e-6;\nint a1 = sq, b1 = sq;\nint a2 = k - sq * sq, b2 = 1;\nfor (int i = 0; i < d - 2; i++) {\nret.push_back(i);\nret.push_back(i + 1);\n}\nfor (int i = 0; i < a1; i++) {\nret.push_back(0);\nret.push_back(i + d - 1);\n}\nfor (int i = 0; i < b1; i++) {\nret.push_back(d - 2);\nret.push_back(i + a1 + d - 1);\n}\nfor (int i = 0; i < d - 2; i++) {\nret.push_back(i + a1 + b1 + d - 1);\nret.push_back(i + a1 + b1 + d);\n}\nfor (int i = 0; i < a2; i++) {\nret.push_back(a1 + b1 + d - 1);\nret.push_back(i + a1 + b1 + 2 * d - 2);\n}\nfor (int i = 0; i < b2; i++) {\nret.push_back(a1 + b1 + 2 * d - 3);\nret.push_back(i + a1 + b1 + a2 + 2 * d - 2);\n}\n}\nelse {\nint a = (1 + sqrt(8 * k + 1)) / 2 + 1.0e-6, b = k - a * (a - 1) / 2;\nfor (int i = 0; i < a; i++) {\nret.push_back(0);\nret.push_back(i + 1);\n}\nfor (int i = 0; i < b + 1; i++) {\nret.push_back(i + a + 1);\nret.push_back(i + a + 2);\n}\n}\nret.insert(ret.begin(), *max_element(ret.begin(), ret.end()) + 1);\nreturn ret;\n}\n};\n\n[/cpp]\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-721-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2esng9v2bJ6ssDIH4EeAIW","type":"Entry","createdAt":"2020-04-20T12:41:37.090Z","updatedAt":"2026-03-15T17:18:16.522Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":87,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 722","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Python"],"creationDate":"2017-12-10T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 722 Editorials\n\nSRM 722 Editorials are now published. Thanks to [OB3LISK](https://profiles.topcoder.com/OB3LISK), [square1001](https://profiles.topcoder.com/square1001), [kapillamba4](https://profiles.topcoder.com/kapillamba4) and [asmn](https://profiles.topcoder.com/asmn) for contributing to the editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n## HillClimber\nSRM 722 Round 1 - Division II, Level One \n\n- by [OB3LISK](https://profiles.topcoder.com/OB3LISK)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14727)\n\nThe problem HillClimber gives us a set of mountains, and asks us to find the longest sequence of mountains that increase in height. (Said another way, what's the longest streak of mountains where we have to continuously climb up, without going down or remaining at the same height.)\nWe can see that this problem is a simple \"Longest Increasing Sequence\" (not to be confused with the famous Dynamic Programming problem, \"Longest Increasing SUBsequence\").\n\nWe're given an array of mountain heights as input. We'll need to maintain two variables, the longest sequence of uphill climbing we've ever seen, and the sequence of uphill climbing for the mountain series we're currently on.\n\nTraversing each element of the array of heights from left to right, we'll keep track of the mountain we're currently on, and the next mountain in line. If the next mountain is bigger than the mountain we're currently on, then we know that we're going uphill, which means we increase our local longest variable by one. It's also at this step where we decide, \"if this local longest is bigger than the longest I've seen so far, then we know that this new sequence is the longest I've ever seen\", and so we set our total longest the local longest.\n\nAfter traversing all but the last mountain, our longest uphill sequence variable will contain our final answer.\n\n```\n[cpp]\n\nclass HillClimber {\npublic:\nint longest(vector&lt;int&gt;);\n};\nint HillClimber::longest(vector&lt;int&gt; height)\n{\n// The longest sequence of increasing mountains.\nint longest = 0;\n/*\nThere are n+1 mountains, and n segments.\nWe care about increasing segments, which means\nthat mountain i is smaller than mountain i+1.\n*/\n// Keep track of each increasing sequence of mountains in this variable.\nint longestlocal = 0;\n// For each of the first n mountains...\nfor (int i = 0; i &lt; height.size(); i++) {\n// The two mountains we're looking at is the current mountain, and the next one.\nint mount1 = height[i];\nint mount2 = height[i + 1];\n// If mount1 is smaller than mount2, then we're going uphill. Increase longestlocal by 1.\nif (mount1 &lt; mount2) { longestlocal += 1; // Since we had an increase in height, we should check whether this current sequence is longer than &quot;longest&quot; if (longestlocal &gt; longest) {\n// Our longestlocal is the most uphill we've ever seen, so update our longest variable.\nlongest = longestlocal;\n}\n} else { // If the mount1 is bigger than mount2 (or equal), then we aren't going uphill!\n// Reset longestlocal to 0.\nlongestlocal = 0;\n}\n}\nreturn longest;\n}\n\n[/cpp]\n```\n\nThe complexity of our solution is O(N), as we have to visit each segment of a mountain only once. The space complexity for our solution is O(1), as we only need two variables of space (\"__longest__\" and \"__longestlocal__\") to hold the longest uphill sequence.\n\n## TCPhoneHomeEasy\nSRM 722 Round 1 - Division II, Level Two\n\n- by [square1001](https://profiles.topcoder.com/square1001)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14728)\n\n__What is this problem?__\nYou are required to count the number of (digits)-digit integers (let’s call them “good integers”, leading zeros are allowed), for which there are no prefix that is equal to one of the elements of specialPrefixes.\n\nFor example, if digits=3 and specialPrefixes={“1”, “23”, “456”}, the answer is 889. Since there are only 111 integers (“100” to “199”, “230” to “239”, and “456”) for which one of the prefixes is in specialPrefixes, the answer is 1000 – 111 = 889.\nThe Solution\n\nConsider the example where digits=4. What are the integers with the prefix “25”? The answer is all integers between 2500 and 2599.\n\nMore generally, if digits=d, the integers which the prefix s, all integer between l = 10^d-|s| * int(s) and r = 10^d-|s| * (int(s) + 1) – 1 (|s| denotes the length of s, and int(s) denotes the transformation of s from string format to integer).\n\nSo, for each element s in specialPrefixes, you can find l, r for them. The number x is good integer if and only if there are no s which is l ```≤``` x ```≤``` r. Now you can brute-force the value x (the range is 0 ```≤``` x ```<``` 10^digits).\n\nTime Complexity: O(10^digits * K). K equals to number of special prefix.\nMemory Complexity: O(digits * K)\n\n__C++ Code:__\n\n```\n[cpp]\n\n#include &lt;string&gt;\n#include &lt;vector&gt;\nusing namespace std;\nint l[55], r[55];\nclass TCPhoneHomeEasy {\nprivate:\nint power(int a, int b) {\nint ret = 1;\nfor(int i = 0; i &lt; b; i++) {\nret *= a;\n}\nreturn ret;\n}\npublic:\nint validNumbers(int digits, vector&lt;string&gt; specialPrefixes) {\nint n = specialPrefixes.size();\nfor(int i = 0; i &lt; n; i++) {\nstring s = specialPrefixes[i];\nl[i] = power(10, digits - s.size()) * stoi(s);\nr[i] = power(10, digits - s.size()) * (stoi(s) + 1) - 1;\n}\nint all = power(10, digits);\nint answer = 0;\nfor(int i = 0; i &lt; all; i++) {\nbool good = true;\nfor(int j = 0; j &lt; n; j++) {\nif(l[j] &lt;= i &amp;&amp; i &lt;= r[j]) good = false;\n}\nif(good) answer++;\n}\nreturn answer;\n}\n};\n\n[/cpp]\n```\n\n## MulticoreProcessingEasy\nSRM 722 Round 1 - Division II, Level Three\n\n- by [kapillamba4](https://profiles.topcoder.com/kapillamba4)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14732)\n\nYou are given 2 arrays of the same size, one represents the speed of computation of a system and other - the maximum number of cores of a system.\n\nA work requires jobLength units of computation and if number of cores utilized is ‘x’ then work gets divided between them as jobLength/x per core\n\ncorePenalty is penalty imposed on computation time for each core utilized beyond one.\nTherefore final formula comes out to be:\n\ncomputationTime = ((jobLength / cores) / speed) + corePenalty*(cores-1)\n\nWe have to choose a system and number of cores to utilize such that total computation time is minimum. We will iterate over each system and its number of cores calculating minimum computation time for each iteration.\n\nWe must return a minimum integer value for computationTime therefore we round up the value of computationTime and return it.\n\nC++Code:\n\n```\n[cpp]\n\n#include &lt;bits/stdc++.h&gt;\nclass MulticoreProcessingEasy {\npublic:\nint fastestTime(int jobLength, int corePenalty, std::vector &lt;int&gt; speed, std::vector &lt;int&gt; cores) {\ndouble ans = 99999999999.0;\nfor(int i = 0; i &lt; speed.size(); i++) {\nfor(int c = 1; c &lt;= cores[i]; c++) {\nans = std::min(ans, ((double)(jobLength)/c)/speed[i]+corePenalty*(c-1));\n}\n}\nreturn std::ceil(ans);\n}\n}\n\n[/cpp]\n```\n\n## TCPhoneHome\nSRM 722 Round 1 - Division I, Level One \n\n- by [square1001](https://profiles.topcoder.com/square1001)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14698)\n\n__What is this problem?__\nYou are required to count the number of (digits)-digit integers (let’s call them “good integers”, leading zeros are allowed), for which there are no prefix that is equal to one of the elements of specialPrefixes.\n\nFor example, if digits=3 and specialPrefixes={“1”, “23”, “456”}, the answer is 889. Since there are only 111 integers (“100” to “199”, “230” to “239”, and “456”) for which one of the prefixes is in specialPrefixes, the answer is 1000 – 111 = 889.\n\nThe integer digits is at most 17.\n\n__The Solution__\nThe digits can be up to 17, so of course you cannot brute-force x. You have to come up with more efficient solution.\n\nThe idea is that, for example, if there’s element “123” and “12345” in specialPrefixes, “12345” has no additional impact on the answer. Generally, suppose if there are element s and t, and s is a prefix of t, t has no meaning. So, you can erase t from specialPrefixes. When there is no meaningless element in specialPrefixes, the answer is 10^digits – (sum of 10^digits-|s| for each element s in specialPrefixes), letting |s| = (length of s).\n\nWhy this way can get the correct answer? Suppose that there is no meaningless element in specialPrefixes. You have to prove that there is no integer x that there are two or more of it’s prefixes in specialPrefixes. If there are two prefixes of x, saying s and t in specialPrefixes, you can say that “s is a prefix of t” or “t is a prefix of s”. It means s or t is a meaningless element, so it makes contradiction.\n\nYou can erase all meaningless element in specialPrefixes in this way:\n1) check there are pair of distinct numbers (x, y) such that specialPrefixes[x] is a prefix of specialPrefixes[y]. If there are no such pair, this is the end of routine.\n2) if there are such pair (x, y), erase specialPrefixes[y] and go back to operation (1).\n\n__Time Complexity:__ O(K^3). K equals to number of special prefixes.\n__Memory Complexity:__ O(K)\n\n__Alternative Solution__\nThe idea is that you can determine integers l and r that the number has prefix s if and only if the number is between l and r. For example, 10-digit integer which has prefix “869120” is, between 8691200000 and 8691209999.\n\nIf you process naively it seems like taking O(10^digits * K) if K is equals to the number of special prefix, and obviously it gets Execution Time Limit Exceeded. But you can use “coordinate compression” technique for this problem and calculate faster.\n\nYou can reduce to the following problem: You are given array l, r with length K. How many (digits)-digit number integer x that there are no integer k that l[k] ≤ x < r[k]. There are at most 2K distinct elements in l and r, so use coordinate compression and you only have to check x for less or equal to these 2K elements. Finally this works in time complexity O(K^2).\n\n__C++ Code__\n\n```\n[cpp]\n\n#include &lt;bits/stdc++.h&gt;\nusing namespace std;\nclass TCPhoneHome {\npublic:\nlong long power(int a, int b) {\nlong long ret = 1;\nfor(int i = 0; i &lt; b; i++) ret *= a;\nreturn ret;\n}\nlong long validNumbers(int digits, vector&lt;string&gt; specialPrefixes) {\nwhile(true) {\nbool found = false;\nfor(int i = 0; i &lt; specialPrefixes.size() &amp;&amp; !found; i++) {\nfor(int j = 0; j &lt; specialPrefixes.size() &amp;&amp; !found; j++) {\nif(i == j) continue;\nstring s = specialPrefixes[i];\nstring t = specialPrefixes[j];\nif(s == t.substr(0, s.size())) {\n// string t has no meaning\nspecialPrefixes.erase(specialPrefixes.begin() + j);\nfound = true;\n}\n}\n}\nif(!found) break;\n}\nlong long ret = power(10, digits);\nfor(string s : specialPrefixes) ret -= power(10, digits - s.size());\nreturn ret;\n}\n};\n\n[/cpp]\n```\n\n## MulticoreProcessing\nSRM 722 Round 1 - Division I, Level Two \n\n- by [kapillamba4](https://profiles.topcoder.com/kapillamba4)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14699)\n\nYou are given 2 arrays of same size n, one represents the speed of computation of a system and other the maximum number of cores of a system.\n\nA work requires jobLength units of computation and if number of cores utilized are ‘x’ than work gets divided between them as jobLength/x per core.\n\ncorePenalty is penalty imposed on computation time for each core utilized beyond one.\nFor each system we know its computation speed, therefore we can calculate minimum computation time for each system by varying the its number of utilized cores: 1 <= cores <= maximum_cores\nTherefore final formula comes out to be:\n\ncomputationTime = ((jobLength / cores) / speed) + corePenalty*(cores-1);\n\nWe can observe that the above formula represents a familiar graph of\nf(x) = c1/x + c2* x,[ more information here](https://www.wolframalpha.com/input/?i=1%252Fx%252Bx)\n\n![SRM 722](//images.ctfassets.net/piwi0eufbb2g/1o1s5tXqumnutyvRmGOhPg/d3d422a7e01881960576c86d6959a801/SRM_722.webp)\n\nIf we iterate linearly over all systems and overall possible utilized cores values, time complexity will be Θ(Σ(speed[i]* cores[i])) where 0 <= i < n.\n\nHowever we can reduce the time complexity to Θ(Σ(speed[i]* log(cores[i]))) by using ternary search for finding minima for above formula for each system separately.\n\nHere is a good article which explains how ternary search works and here is another good article from TopCoder Cookbook.\n\nWe must return a minimum integer value for computationTime therefore we round up the value of computationTime before returning it.\n\n__C++ Code__\n\n```\n[cpp]\n\n#include &lt;bits/stdc++.h&gt;\nclass MulticoreProcessing {\nconst double eps = 0.00001;\npublic:\ndouble floatMin(long long jobLength, int corePenalty, int speed, double c) {\nreturn ((((double)jobLength)/c)/speed+corePenalty*(c-1));\n}\nlong long longMin(long long jobLength, int corePenalty, int speed, long long c) {\nreturn (((jobLength+c-1)/c+speed-1)/speed+corePenalty*(c-1));\n}\nlong long ternary(long long jobLength, int corePenalty, int speed, int n) {\ndouble r = n, l = 1;\nwhile(fabs(r - l) &gt; eps) {\ndouble m1 = l+(r-l)/3;\ndouble m2 = r-(r-l)/3;\ndouble f1 = floatMin(jobLength, corePenalty, speed, m1);\ndouble f2 = floatMin(jobLength, corePenalty, speed, m2);\nif(f1 &gt; f2) {\nl = m1;\n} else {\nr = m2;\n}\n}\nreturn std::min(longMin(jobLength, corePenalty, speed, floor(l)),\nlongMin(jobLength, corePenalty, speed, ceil(l)));\n}\nlong long fastestTime(long long jobLength, int corePenalty,\nstd::vector &lt;int&gt; speed, std::vector &lt;int&gt; cores) {\nlong long ans = std::numeric_limits&lt;long long&gt;::max();\nfor(int i = 0; i &lt; speed.size(); i++) {\nans = std::min(ans, ternary(jobLength, corePenalty, speed[i], cores[i]));\n}\nreturn ans;\n}\n};\n\n[/cpp]\n``` \n\n## DominoTiling\nSRM 722 Round 1 - Division I, Level Three \n\n- by [asmn](https://profiles.topcoder.com/asmn)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14700)\n\nYou are given a 2D rectangular grid with some cells need to be covered by disjoint 2x1 dominos. Your goal is to calculate the number of ways to do that.\n\nThe idea is to use dynamic programing to do a row by row calculation. For each row r, we only consider placing horizontal dominos covering cells in row r and vertical dominos covering cells in row r and r+1. Use binary number mask to represent the placement of vertical dominos in row r. Placement of vertical dominos in row r-1 and cells don’t need to be covered is represented as binary number pMask and rowMask. In the following figure, mask is (0000101)2, rowMaskis (0100000)2 and pMask is (1000010)2. The tuple (mask, pMask, rowMask) is considered valid if there is a valid dominos placement covering all cells in the row. That means (mask, pmask, rowMask) are all disjoint and the cells uncovered can be covered by horizontal dominos.\n\n![SRM 722 2](//images.ctfassets.net/piwi0eufbb2g/3y16jTU68D4QuKy1r6ueHd/19957b75b0324b3a16224ef9645f5a34/SRM_722_2.webp)\n\nWhen we finish placing dominos in row 0 ~ r-1, let count[r][mask] to be the number of valid ways to fully cover row r with placement mask. The transfer function can be represented as:\nIn a n * m grid, the start condition is count[-1][(00..0)2] = 1, and the final answer is count[n-1][ (00..0)2].\n\nTo speed up calculation, we can perform 2 optimizations:\n1. Instead of checking each (pMask, rowMask[r], mask), we pre calculate all valid mask for each pMask(assuming rowMask[r]=0) by dfs(depth first seach) on all valid placement in a row.\n2. Since we only need row r-1’s information, all previous information can be discarded.\n\n__Python Code__\n\n```\n[cpp]\n\ndef calcT(mask, n):\nret = []\nA = ''.join(('1' if mask &amp; 1 &lt;&lt; i &gt; 0 else '0') for i in range(n))\ndef dfs(k, now):\nif k &gt;= n:\nret.append(int(now, 2))\nelse:\ndfs(k + 1, (('0' if A[k] == '1' else '1')) + now)\nif A[k:k + 2] == '00':\ndfs(k + 2, '00' + now)\ndfs(0, '')\nreturn ret\nclass DominoTiling:\ndef count(self, grid):\nn = len(grid[0])\nnMask = 1 &lt;&lt; n\nT = [calcT(mask, n) for mask in range(nMask)]\ncountNow = [1] + [0] * (nMask - 1)\nfor row in grid:\ncountNext = [0] * nMask\nrowMask = int(row.replace('.', '0').replace('X', '1'), 2)\nfor pMask in range(nMask):\nif pMask &amp; rowMask &gt; 0:\ncontinue\nfor mask in T[pMask | rowMask]:\ncountNext[mask] += countNow[pMask]\ncountNow = countNext\nreturn countNow[0]\n\n[/cpp]\n```\n\nIt is easily to see that the overall time complexity is O(n* 4^m), where n is number of rows and m is the number of columns. The memory space complexity is O(4^m).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-722-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3G6BagJ93MlhyYk8xhPMfN","type":"Entry","createdAt":"2020-04-20T12:41:37.132Z","updatedAt":"2026-03-15T12:06:28.473Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":45,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 723","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++"],"creationDate":"2017-12-10T00:00:00.000Z","readTime":"20 min","content":"# Single Round Match 723 Editorials\n\nSome of the SRM 723 Editorials are now published. Thanks to [nitish_](https://profiles.topcoder.com/nitish_) and [kapillamba4](https://profiles.topcoder.com/kapillamba4)  for contributing to the editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n### SRM 723 Round 1 - Division II, Level Two TopXorerEasy\n###  SRM 723 Round 1 - Division I, Level One TopXorer\n- by [nitish_](https://profiles.topcoder.com/nitish_)\n\n[Problem Details TopXorerEasy](https://archive.topcoder.com/ProblemStatement/pm/14737)\n\n[Problem Details TopXorer](https://archive.topcoder.com/ProblemStatement/pm/14736)\n\nTo obtain the answer, we will set all the bits one by one starting from maximum bit.\n\nSuppose integers X = 1xxxxxxxxxxxx (13 bits including 1) and Y = 1xxxxxx . It can be guaranteed that we can at least obtain 111111111111 (12 bits) as the maximum XOR of these numbers. Now, in order to obtain a number greater than this, ee should make use of 13th (1) set bit of X. But when we use that bit, it is not guaranteed that all the bits after that are set to be 1.\n\nThus, in order to check that, we should use the set bit from the smallest available number with us. If there is a number which can contribute to that bit, then use that number. Other numbers which are greater than the smallest number can now be updated to (2^(log2(n)) - 1), because this number will have all the bits as 1 which can be utilised later.\n\nImplementation (Div II Medium):\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\nclass TopXorerEasy {\npublic:\nint maximalRating(int A, int B, int C) {\nint res = 0;\nint idx = -1;\nvector <int >v;\nv.push_back(A);\nv.push_back(B);\nv.push_back(C);\nfor(int i =30; i >=0; --i)\n{\nidx = -1;\nfor(int j = 0; j < 3; ++j)\n{\nif(v[j]&(1<<i))\n{\nif(idx == -1 or v[j] < v[idx])\nidx = j;\n}\n}\nif(idx != -1)\n{\nres += (1<<i);\nv[idx] ^= (1<<i);\nfor(int j = 0; j < 3; ++j)\n{\nif(v[j]&(1<<i))\nv[j] = (1<<i) - 1 ;\n}\n}\n}\nreturn res;\n}\n};\n[/cpp]\n```\n\nImplementation for Div I Easy is similar: we take a vector instead of three numbers A, B, C.\n\n### SimpleMazeEasy\nSRM 723 Round 1 - Division II, Level Three \n- by  [kapillamba4](https://profiles.topcoder.com/kapillamba4)\n\nThere are 5n^2 rooms and order of n^4 pairs of distances to add up. The maximum distance between any two pairs can be 4 * n-2 (can be observed easily)\n\nTherefore, the answer must be some constant multiplied by n^5 and some lower degree terms (a quintic polynomial).\n\nWe can calculate the answer for several test cases using a slow brute force solution:\nn = 0, result = 0\nn = 1, result = 16\nn = 2, result = 600\nn = 3, result = 4680\nn = 4, result = 19904\nn = 5, result = 61000\nn = 6, result = 152136\nn = 7, result = 329280\nThese data points seem to form a nice polynomial.\n\n![SRM 723](//images.ctfassets.net/piwi0eufbb2g/Iw1LFrQoey2TGZlDfNLqS/3e16995ae36dbcc34467fd283393a9dc/SRM_723.webp)\n\nWe can use Lagrange interpolation method to calculate results for other data points. We must also calculate modular multiplicative inverse of denominators for each term in Lagrange’s interpolation formula.\n\nWe can calculate exact polynomial equation using Newton's Interpolation Formula which comes out to be:\nf(x) = 333333332*(x^3) + 666666691*(x^5)\n\nC++Code:\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nclass SimpleMazeEasy {\nconst long long mod = 1000000007;\npublic:\nlong long power(long long base, int exp) {\nbase %= mod;\nif(exp == 1) return base;\nif(base == 0) return 0LL;\nif(base == 1) return 1LL;\nif(exp == 0) return 1LL;\nif(exp % 2) return (power((base*base)%mod, exp/2)*base)%mod;\nelse return power((base*base)%mod, exp/2);\n}\nint findSum(long long n) {\nreturn ((333333332LL*power(n, 3))%mod + (666666691LL*power(n, 5))%mod)%mod;\n}\n};\n[/cpp]\n\n```\n\n### BuffaloBuffaloBuffalo\nSRM 723 Round 1 - Division I, Level Two \n- by  [kapillamba4](https://profiles.topcoder.com/kapillamba4)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14731)\n\nWe are given a string of length ‘n’ consisting of several characters repeated multiple times and ‘?’ character repeated multiple times.\n\nFind in how many ways a valid string of length ‘n’ can be constructed by interleaving several “buffalo” strings together where corresponding characters of valid string and given string match.\n\nNote: The ‘?’ character in given string can match to any character of string “buffalo”\nLet dp[a][b][c][/c][d][e][f] be the number of ways to construct remaining valid string from indices [0 to idx], where\n‘b’ is already repeated a times,\n‘u’ is already repeated b times,\n‘f’ is already repeated c times,\n‘a’ is already repeated d times,\n‘l’ is already repeated e times,\n‘o’ is already repeated f times,\nand a+b+c+d+e+f == n-idx.\n\nHere a ```<=``` b ```<=``` c/2 ```<=``` d ```<=``` e ```<=``` f ```<=``` n/7 equality should always hold true and N should be a multiple of 7 (size of string “buffalo”)\n\nA string is said to be valid/stable if above equalities hold true.\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nint dp[15][15][30][15][15][15];\nclass BuffaloBuffaloBuffalo {\nstd::string pat;\nint maxBufalo;\nconst int mod = 1000000007;\nconst std::string bufalo = \"bufalo\";\npublic:\nbool stable(int C[]) {\nif (C['b'] <= C['u'] &&\nC['u'] * 2 <= C['f'] &&\nC['f'] <= C['a'] * 2 &&\nC['a'] <= C['l'] &&\nC['l'] <= C['o'] &&\nC['o'] <= maxBufalo) {\nreturn true;\n} else {\nreturn false;\n}\n}\nint solve(int C[], int idx) {\nif (idx == -1) {\nreturn 1;\n}\nint &ref = dp[C['b']][C['u']][C['f']][C['a']][C['l']][C['o']];\nif (ref != -1) {\nreturn ref;\n}\nif (pat[idx] != '?') {\n++C[pat[idx] + 0];\nint ans = 0;\nif (!stable(C)) {\nans = 0;\n} else {\nans = solve(C, idx - 1);\n}\n--C[pat[idx] + 0];\nreturn (ref = ans);\n} else {\nint ans = 0;\nfor (char c: bufalo) {\n++C[c + 0];\nif (stable(C)) {\nans = (ans + solve(C, idx - 1)) % mod;\n}\n--C[c + 0];\n}\nreturn (ref = ans);\n}\n}\nint count(std::string pattern) {\npat = pattern;\nint A[256];\nmemset(A, 0, sizeof(A));\nmemset(dp, -1, sizeof(dp));\nif (pat.size() % 7 != 0) {\nreturn 0;\n}\nmaxBufalo = pat.size() / 7;\nfor (char c2: pat) {\nbool flag = true;\nfor (char c: bufalo) {\nif (c == c2 || c2 == '?')\nflag = false;\n}\nif (flag) {\nreturn 0;\n}\n}\nreturn solve(A, pat.size() - 1);\n}\n};\n[/cpp]\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-723-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1xhLLzglb4HBpxKH5Pt6Ye","type":"Entry","createdAt":"2020-04-20T12:41:37.144Z","updatedAt":"2026-03-15T11:51:26.398Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":64,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 724","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++"],"creationDate":"2018-01-18T00:00:00.000Z","readTime":"15 min","content":"# Single Round Match 724 Editorials\n\nSome of the SRM 724 Editorials are now published. Thanks to [square1001](https://profiles.topcoder.com/square1001) for contributing to the editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n## GravityPuzzleEasy\nSRM 724 Round 1 - Division II, Level One\n\n-  by [square1001](https://profiles.topcoder.com/square1001)\n\n[Problem Details ](https://archive.topcoder.com/ProblemStatement/pm/14742)\n\n__Simple Explanation of Problem__\nThere is a board which is an H by W grid. You are given state of the grid, board. This argument consists from H strings of length W. There is a box in a cell which is in y-th topmost row and x-th leftmost column, if and only if x-th letter of y-th string of board is ‘#’. This board has the gravity, so if there are k boxes on x-th leftmost column, k bottommost cells on this column has a box and others are not. You can see the example of the right (only the red cells has a box.)\n\n__Solution and Approach__\nFirst, you have to count the number of boxes in x-th left column. It means that we have to count “the number of ‘#’ in board[y][x]” for each x. (Let this ccntt[x] for each x.)\nAfter that, you have to get the answer. For doing this, first you have to prepare H string with length W (let this ans), and all of them should be filled with ‘.’. And then, for each x, you have to assign ‘#’ to ans[H – cnt[x]][x], ans[H – cnt[x] + 1][x],…, ans[H – 1][x].\nThat’s all.\n\n![SRM-724-1-300x112](//images.ctfassets.net/piwi0eufbb2g/2YXzgQA81PM8GwO1dkpMtf/11b9f31b5293bfa1d03da01690200bad/SRM-724-1-300x112.webp)\n\nTime Complexity: O(HW)\nMemory Complexity: O(HW)\nSource Code in C++\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\nclass GravityPuzzleEasy {\npublic:\nvector<string> solve(vector<string> board) {\nint H = board.size(), W = board[0].size();\nvector<int> cnt(W);\nfor (int i = 0; i < W; i++) {\nfor (int j = 0; j < H; j++) {\nif (board[j][i] == '#') {\ncnt[i]++;\n}\n}\n}\nvector<string> ans(H, string(W, '.'));\nfor (int i = 0; i < W; i++) {\nfor (int j = H - cnt[i]; j < H; j++) {\nans[j][i] = '#';\n}\n}\nreturn ans;\n}\n};\n[/cpp]\n```\n\n__Related Problems__\nSRM 724 Division 1 [Medium GravityPuzzle](https://archive.topcoder.com/ProblemStatement/pm/14743) – The problem is in same competition and the problem name is similar, but the problem is completely different. If you are good at competitive programming you can try this problem.\n\n## OrAndSumEasy\nSRM 724 Round 1 - Division II, Level Two \n\n-  by [square1001](https://profiles.topcoder.com/square1001)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14745)\n\n__Simple Explanation of Problem__\nFor a given pairOr and pairSum, determine if there is a pair of non-negative integers (a, b) such that “a + b = pairSum” and “the bitwise or of a and b is pairOr”.\nFor example, if pairOr= 7 and pairSum= 11, (a, b) = (5, 6) satisfies the condition. But if pairOr= 7 and pairSum= 24 there are no such (a, b) that satisfies the condition.\nThe value of pairOrand pairSumis between 0 and 1018.\n\n__Solution and Approach__\nLet “x AND y” the bitwise and of x and y, and let “x OR y” the bitwise or of the same. One key observation is, for every non-negative integer x and y, (x AND y) + (x OR y) = x + y stands.\nWhy this is always true? Assume if both x and y is 0 or 1.\n\n| (x, y)     | x AND y     | x OR y     | x + y     |\n| ---------- | ---------- | ---------- | ---------- |\n| (0, 0)     | 0       | 0       | 0       |\n| (0, 1)     | 0       | 1       | 1       |\n| (1, 0)     | 0       | 1       | 1       |\n| (1, 1)     | 1       | 1       | 2       |\n\nAs you can see from this table, if both x and y is 0 or 1, it is always\n(x AND y) + (x OR y) = x + y\n\nYou can expand to all non-negative integers. For this, let’s use binary notation! Let p the k-th digit (in binary notation) of x and let q the k-th digit (in binary notation) of y. (x AND y) is the sum of (pΛq)x2k and (x OR y) is the sum of (pVq)x2k , and (x + y) is the sum of (p+q)x2k. Therefore, (x + y) – (x AND y) – (x OR y) equals the sum of ((p+q)-(pΛq)-(pVq))x2k=0x2k=0 (since both p and q is 0 or 1, (p + q) – (p AND q) – (p OR q) is always true). Since (x + y) – (x AND y) – (x OR y) = 0, it is obvious to say (x AND y) + (x OR y) = (x + y).\n\nNow, you can reduce to this problem: Is there a pair of non-negative integers (a, b) that satisfies (a AND b) = pairAnd = (pairSum – pairOr) and (a OR b) = pairOr? (For the constraints of problem, pairAnd can be negative)\n\nYou can determine if there is (a, b), by using three following checking conditions.\n1. If pairAnd is negative, obviously there is no (a, b) because (a AND b) is always non-negative.\n2. If there is a non-negative integer k that k-th digit (in binary notation) of pairAnd is 1 and k-th digit (in binary notation) of pairOr is 0, there is no (a, b). You can see that in the table on up has no (x AND y, x OR y) = (1, 0) combination.\n3. Otherwise, the answer always exists because you can set (a, b) = (pairAnd, pairOr).\nYou can determine if condition b satisfies, with judging for each bit. But there are more elegant way. If you pass condition a, you can judge only from setting (a, b) = (pairAnd, pairOr) and check if it is a valid solution.\nIf you use this way, you can write the code simply and can reduce the time complexity to O(1).\nUseful Concepts\nIf you come across the problem which uses bitwise operations, think about the solution that you can divide the problem into one digit in binary notation. If you can do this the problem will be much simple.\n\nAlso, if you want to learn more about problem which uses bitwise operations, see this article - A Bit of Fun: Fun with Bits.\n\nSource code in C++\n\n```\n[cpp]\n\n#include <bits/stdc++.h>\nusing namespace std;\nclass OrAndSumEasy {\npublic:\nstring isPossible(long long a, long long b) {\nreturn b - a >= 0 && ((b - a) | a) == a ? \"Possible\" : \"Impossible\";\n}\n};\n[/cpp]\n\n```\n\n__Related Problems__\nSRM 724 Division 1 Easy - OrAndSum, the harder version of this problem, which is in Division 1 of the same contest.\n\n## OrAndSum \nSRM 724 Round 1 - Division I, Level One - ## OrAndSum\n\n- by [square1001](https://profiles.topcoder.com/square1001)\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14744)\n\n__Simple Explanation of Problem__\nYou are given two arrays of non-negative integers of length n, pairOrand pairSum. Determine if there is a way to construct a sequence of non-negative integers of length n+1, x0,x1,x2...,xn , that satisfies xiVxi+1=pairOr[i] and xi+xi+1=pairSum[i], for all integer i (0 ≤ i < n). Here, OR denotes the bitwise or. You can assume that n is between 1 and 50, and each element of pairOrand pairSumis between 0 and 1018.\n\n__Solution and Approach__\nLet “x AND y” the bitwise and of x and y, and let “x OR y” the bitwise or of the same. One key observation is, for every non-negative integer x and y, (x AND y) + (x OR y) = x + y stands.\nWhy this is always true? Assume if both x and y is 0 or 1.\n\n| (x, y)     | x AND y     | x OR y     | x + y     |\n| ---------- | ---------- | ---------- | ---------- |\n| (0, 0)     | 0       | 0       | 0       |\n| (0, 1)     | 0       | 1       | 1       |\n| (1, 0)     | 0       | 1       | 1       |\n| (1, 1)     | 1       | 1       | 2       |\n\nAs you can see from this table, if both x and y is 0 or 1, it is always\n(x AND y) + (x OR y) = x + y\n\nYou can expand to all non-negative integers. For this, let’s use binary notation! Let p the k-th digit (in binary notation) of x and let q the k-th digit (in binary notation) of y. (x AND y) is the sum of (pΛq)x2k and (x OR y) is the sum of (pVq)x2k , and (x + y) is the sum of (p+q)x2k . Therefore, (x + y) – (x AND y) – (x OR y) equals the sum of ((p+q)-(pΛq)-(pVq))x2k=0x2k (since both p and q is 0 or 1, (p + q) – (p AND q) – (p OR q) is always true). Since (x + y) – (x AND y) – (x OR y) = 0, it is obvious to say (x AND y) + (x OR y) = (x + y).\n\nNow you can reduce to this problem. You are given two arrays of non-negative integers of length n, pairAnd and pairOr. Determine if there is a way to construct a sequence of length n+1, x0,x1,x2,....xn that satisfies xiΛxi+1=pairAnd[i](¿pairSum[i]-pairOr[i]) and xiVxi+1 = pairOr[i].\n\nThe condition is only with bitwise operation! Now you can consider each digit in binary notation independently. It means the sequence x exists if and only if sequence x exists when you only consider about k-th (0-origin) digit, for all non-negative integer k.\n\nIt means you can reduce the problem that the elements of pairAnd and pairOr is 0 or 1. The problem is much simple now!\n\nYou can use greedy technique to solve. First, decide the value x0 . Repeat this until all element of x is decided: Suppose if x0,x1,x2,.....,xk is decided. Now, if pairAnd[k] = 1 and pairOr[k] = 0, obviously there is no valid sequence x. Otherwise, you can divide into three conditions:\n\n1. Case of pairAnd[k] = 0 and pairOr[k] = 0. If xk=1, there is no valid sequence x. Otherwise, xk+1=0.\n2. Case of pairAnd[k] = 0 and pairOr[k] = 1. xk+1=1-xk stands.\n3. Case of pairAnd[k] = 1 and pairOr[k] = 1. If xk=0, there is no valid sequence x. Otherwise, xk+1=1.\nYou can determine whether there is a valid sequence x, in time complexity O(n). Since there are no more than 60 bits (≤ log2 pairAnd[k], ≤ log2 pairOr[k]), you can solve this problem efficiently, which is much faster than time limit.\nTime Complexity: O(n log2 max) when max is the maximum among pairSum.\nMemory Complexity: O(n)\n\n__Useful Concepts__\nIf you come across the problem which uses bitwise operations, think about the solution that you can divide the problem into one digit in binary notation. If you can do this the problem will be much simple.\n\nAlso, if you want to learn more about problem which uses bitwise operations, see this article - [A Bit of Fun: Fun with Bits.](https://www.topcoder.com/thrive/articles/A%20bit%20of%20fun:%20fun%20with%20bits)\n\nSource code in C++\n\n```\n[cpp]\nclass OrAndSum {\npublic:\nstring isPossible(vector<long long> b, vector<long long> s) {\nint n = s.size();\nvector<long long> a(n);\nfor(int i = 0; i < n; i++) {\na[i] = s[i] - b[i];\nif((a[i] | b[i]) != b[i]) return \"Impossible\";\n}\nfor(int i = 0; i < 60; i++) {\nvector<int> p(n);\nfor(int j = 0; j < n; j++) {\nif(a[j] & (1LL << i)) p[j] = 2;\nelse if(b[j] & (1LL << i)) p[j] = 1;\nelse p[j] = 0;\n}\nbool flag = false;\nfor(int j = 0; j < 2; j++) {\nint cur = j; bool f = true;\nfor(int k = 0; k < n; k++) {\nif(cur == 0 && p[k] == 2) {\nf = false; break;\n}\nif(cur == 1 && p[k] == 0) {\nf = false; break;\n}\nif(p[k] == 1) cur = 1 – cur;\n}\nif(f) flag = true;\n}\nif(!flag) return \"Impossible\";\n}\nreturn \"Possible\";\n}\n};\n[/cpp]\n\n```\n\n__Related Problem__\nSRM 724 Division 2 Medium - [OrAndSumEasy](https://archive.topcoder.com/ProblemStatement/pm/14745) – the easier version (n=1 version) of this problem.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7M4Mi2lee2fNvwwkdUle1b","type":"Entry","createdAt":"2020-04-20T12:41:39.297Z","updatedAt":"2020-04-20T12:41:39.297Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Aditya","tcHandle":"Aditya"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-724-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2yfQOD5yBZXBCqf1L4H4Ff","type":"Entry","createdAt":"2020-04-20T12:41:37.145Z","updatedAt":"2026-03-14T23:35:16.303Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":52,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 726","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++"],"creationDate":"2018-02-07T00:00:00.000Z","readTime":"20 min","content":"# Single Round Match 726 Editorials\n\nSome of the SRM 726 Editorials are now published. Thanks to [OB3LISK](https://profiles.topcoder.com/OB3LISK), [nitish_](https://profiles.topcoder.com/nitish_) and [square1001](https://profiles.topcoder.com/square1001) for contributing to the editorials. If you wish to discuss the problems or editorials you may do it in the discussion forum here.\n\n##  StringHalving  \n-  by [OB3LISK](https://profiles.topcoder.com/OB3LISK)\nRound 1 - Division II, Level One \n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14760)\n\nIn this problem, we have a string where each letter appears exactly twice, and we want to remove the duplicate letters in such a way that the first letter is lexicographically smallest.\nA naive approach is to generate all possible ways of removing the duplicate letters and check which of those ways has the smallest beginning letter. But that's not necessary.\nNotice that, for our string, we're only interested in the characters that can appear in beginning of the string. For a character to appear in the beginning of a string, it must appear before every other character and its duplicate both appear. For example:\nabcddeeabc\n\nWhen we consider the above string, a, b, c, and d can all be characters that appear at the beginning of the string after we remove duplicates. The reason that 'e' can't be chosen is because 'd' shows up twice before 'e' does. That means no matter which 'd' is removed, it will appear before any 'e's can show up.\n\nSo now we know that to solve our problem, we just need to find which characters appear in the string before any other character has its duplicate show up. Then, we can choose the smallest character from that set as our answer.\n\nTo solve this problem, we're going to make use of a frequency array. We create an array where each index represents a character. For example, index 0 represents 'a', index 1 represents 'b', and index 25 represents 'z'. Inside of each of these indices will be a number that represents the number of times we see a particular character.\n\nFor this problem, we'll look at each character in the string, from left to right, updating our frequency array as we go, and once we find a frequency of 2 for any character, we know that we can only choose a letter from the letters we've visited before. We then check our frequency array for the letters we've seen to find which letter was the smallest, and return that as our answer.\n\nThe time complexity for this solution is O(N) (specifically O(N/2 + 1) ), since at worst we have to check half of the letters in our string until we find the duplicate. The space complexity is O(1), since the only extra space we use is a frequency array to represent the count of 26 characters.\n\n__Code:__\n\n```\n[cpp]\n\n#include<iostream>\n#include<string>\nusing namespace std;\nclass StringHalving\n{\npublic:\nstring lexsmallest(string);\n};\nstring StringHalving::lexsmallest(string s)\n{\nstring answer = \"\"; // The string that we return.\n// Create a frequency array for each character we see.\n// For example, 'a' = index 0, and if it shows up 3 times\n// then freq[0] = 3;\nint freq[26] = {0}; // Initialize each index to 0.\n// Go through each character in our string and mark our frequency array.\nfor(int i = 0; i < s.length(); i++)\n{\nchar c = s[i];\nfreq[c-'a'] += 1;\n// If we find a duplicate (since the letter shows up twice now). Stop checking letters.\nif(freq[c-'a'] == 2)\n{\nbreak;\n}\n}\n// Find which of the letters we found so far is the \"smallest\".\nfor(int i = 0; i < 26; i++)\n{\nchar c = 'a' + i;\n// The first letter we find based on our indexing ('a' = 0 is lowest, 1 is next lowest, etc.)\n// is going to be our best answer.\nif(freq[i] > 0)\n{\nanswer = c;\nbreak;\n}\n}\nreturn answer;\n}\n[/cpp]\n```\n\n(Notice the useful indexing trick used in the code.\n'a' - 'a' = 0\n'b' - 'a' = 1\n'z' - 'a' = 25\n\nYou can easily get the correct index by simply subtracting char variables.)\n\n ## TurtleGame  \nby [nitish_](https://profiles.topcoder.com/nitish_)\nSRM 726 Round 1 - Division II, Level Two\n\n[Problem Details](http://archive.topcoder.com/ProblemStatement/pm/14618)\n\nGiven a n x m matrix, and the constraint that a player can move only either down side or right side, the length of the turtle friendly path is fixed, which is (n+m-1).\nIt is given that the board is initially at a turtle friendly path. Because they are playing optimally, we can fix these (n+m-1) blocks and remove everything else. Therefore, if the difference between the number of available blocks and (n+m-1) is Odd, then we return 'Win' else 'Lose'.\n\nComplexity is O(n*m).\n\n__C++ Code:__\n\n```\n[cpp]\n#include <bits/stdc++.h>\nusing namespace std;\nclass TurtleGame {\npublic:\nstring getwinner(vector <string> board) {\nint valid_moves = 0,n = board.size(),m = board[0].length() ;\nfor(int i =0; i < n; ++i)\n{\nfor(int j = 0; j < m; ++j)\nif(board[i][j] == '.') ++valid_moves;\n}\nint diff = valid_moves - (n+m-1);\nif(diff&1)\nreturn \"Win\";\nelse\nreturn \"Lose\";\n}\n};\n[/cpp]\n```\n\n## HeroicScheduled2\nby [nitish_](https://profiles.topcoder.com/nitish_)\nSRM 726 Round 1 - Division II, Level Three\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14751)\n\nThe problem statement says that you have to find the count of all the possible schedules that can take place. The solution to this problem is greedy + dynamic programming.\n\nFirst, it is wise to first choose a task to do whose deadline is closer. Thus, we will be able to do more number of tasks.\n\nSo, sort the schedules based on the finish time of each schedule.\nThe state of DP will be {index of schedule, bitmask which tracks which day has been used till now}.\n\nThus, if we can find a day vacant between the start[i] and finish[i], then we can schedule that task that day. Or, we can skip that task without scheduling that. Both of the cases increase result by 1.\n\nComplexity: O(N*M), where N = number of tasks and M = 216 (bitmask).\n\n__C++ code:__\n\n```\n[cpp]\n#include <bits/stdc++.h>\nusing namespace std;\n#define ll long long\nclass HeroicScheduled2 {\npublic:\nint N;\nvector <pair<int,int> >S;\nll DP[60][1<<16];\nll f(int idx, int mask)\n{\nif(idx == N)\nreturn 1;\nif(DP[idx][mask] != -1)\nreturn DP[idx][mask];\nll res = 0;\nres += f(idx+1, mask);\nfor(int i =S[idx].second; i <= S[idx].first; ++i)\n{\nif(!(mask&(1<<i)))\n{\nres += f(idx+1, mask|(1<<i));\nbreak;\n}\n}\nreturn DP[idx][mask] = res;\n}\nlong long getcount(vector <int> start, vector <int> finish) {\nmemset(DP, -1, sizeof DP);\nfor(int i =0; i < start.size(); ++i)\nS.push_back({finish[i], start[i]});\nsort(S.begin(), S.end());\nN = finish.size();\nll ans = f(0,0);\nreturn ans;\n}\n};\n[/cpp]\n```\n\n## Unpacking  \n-  by [square1001](https://profiles.topcoder.com/square1001)\nSRM 726 Round 1 - Division I, Level One\n\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14759)\n\n__Simple Explanation of Problem__\n\nThere are N boxes which contains red and blue candies. The i-th box has three values: a[i], b[i], and cost[i]. It means, to buy i-th box costs cost[i], and (number of red candies, number of blue candies) = (a[i], b[i]), (a[i]+1, b[i]–1), or (a[i]–1, b[i]+1) are possible. What is the minimum cost if you want to guarantee that you can get at least K candies of same color? If you cannot guarantee even if you buy any set of boxes, answer -1 instead. You can assume, 1 ≤ N ≤ 50, and 1 ≤ a[i], b[i], K ≤ 10000.\nSolution and Approach\n\nFirst, the problem seems complicated. So, let’s think about the following problem instead: “if you buy all boxes, can you guarantee that you can get at least K candies of same color?” Actually, it’s not so hard. You can guarantee that you can get at least K candies if and only if it satisfies one of the three following condition:\n1. The sum of a[i]-1 is at least K.\n2. The sum of b[i]-1 is at least K.\n3. The sum of a[i]+b[i] is at least 2K-1.\n\nYou can prove easily if you take following process. First, take a[i]-1 red candies and b[i]-1 blue candies from each box. Now, there are 2 candies remaining in each box and any color configuration is possible. Then, take all the remaining 2N candies to empty the boxes. Now, for any pair of non-negative integers (x, y) that satisfies x + y = 2N, “you took (sum of a[i]-1)+x red candies and (sum of b[i]-1)+y blue candies” is possible. If you solve the inequalities over the integers, 0≤x≤2N, (sum of a[i]-1)+x<K, (sum of b[i]-1)+(2N-x)<K simultaneously, the answer is “(the sum of a[i]-1)<K and (the sum of b[i]-1)<K and (the sum of a[i]+b[i])≤2K-2”. Therefore, you can guarantee that you can get at least K candies if and only if it satisfies one of the condition a, b, or c.\n\nNow the problem became simple. You can take the minimum value of “what is the minimal cost subset of boxes that the sum of a-1 is at least K?”, “what is the minimal cost subset of boxes that the sum of b-1 is at least K?”, and “what is the minimal cost subset of boxes that the sum of a+b is at least 2K-1?”. All three problem has the same form: “There are N non-negative integers v[0], v[1],…, v[N-1]. Selecting value v[i] costs c[i]. What is the minimum cost of taking integers so that sum of integers is at least K?” (let’s call this “sub-problem”).\nYou can easily solve with knapsack-like dynamic programming. Therefore, you can solve in O(NK) and it runs much quicker than time limit.\n\nTime Complexity: O(NK)\n\nMemory Complexity: O(NK), and it can be reduced to O(N+K)\n\n__Useful Concepts__\nIf you don’t know about dynamic programming, I suggest reading a Topcoder data science tutorial, Dynamic Programming: From Novice to Advanced.\n\n__C++ code:__\n\n```\n[cpp]\n\n#include <vector>\n#include <algorithm>\nusing namespace std;\nconst int inf = 1012345678;\nclass Unpacking {\npublic:\nint solve(vector<int> v, vector<int> c, int K) {\nint N = v.size();\nvector<vector<int> > dp(N + 1, vector<int>(K + 1));\nfill(dp[0].begin() + 1, dp[0].end(), inf);\ndp[0][0] = 0;\nfor (int i = 0; i < N; i++) {\nfor (int j = 0; j <= K; j++) dp[i + 1][j] = dp[i][j];\nfor (int j = 0; j <= K; j++) dp[i + 1][min(j + v[i], K)] = min(dp[i + 1][min(j + v[i], K)], dp[i][j] + c[i]);\n}\nreturn dp[N][K];\n}\nint getcost(vector<int> a, vector<int> b, vector<int> cost, int K) {\nint N = a.size();\nvector<int> v1(N), v2(N), v3(N);\nfor (int i = 0; i < N; i++) {\nv1[i] = a[i] - 1;\nv2[i] = b[i] - 1;\nv3[i] = a[i] + b[i];\n}\nint ret = min({ solve(v1, cost, K), solve(v2, cost, K), solve(v3, cost, 2 * K - 1) });\nreturn ret == inf ? -1 : ret;\n}\n};\n[/cpp]\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7M4Mi2lee2fNvwwkdUle1b","type":"Entry","createdAt":"2020-04-20T12:41:39.297Z","updatedAt":"2020-04-20T12:41:39.297Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Aditya","tcHandle":"Aditya"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-726-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6rB7ADTnL35WFV0oZEMeDm","type":"Entry","createdAt":"2020-04-20T12:43:24.658Z","updatedAt":"2026-03-10T17:40:05.164Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":113,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 730","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java"],"creationDate":"2020-04-09T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 730 Editorials\n\n## IntervalIntersections\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14814)\n\nUsed as: Division Two - Level One:\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 250                                             |\n| __Submission Rate__       | 235 / 267 (88.01%)                              |\n| __Success Rate__          | 177 / 235 (75.32%)                              |\n| __High Score__            | __cnyali_lk__ for 248.75 points (2 mins 1 secs) |\n| __Average Score__         | 202.81 (for 177 correct submissions)            |\n\nThere are several cases to consider. We need to check if segments intersect or not.\n\ny1 ```<``` x2: the answer is x2 - x1.\n\ny2 ```<``` x1: the answer is x1 - y2.\n\nOtherwise, segments intersect and the answer is zero.\n\nCode by bohuss:\n\n```\nint ans = 0;\nif(y1<x2)\nreturn x2 - y1;\nif(y2<x1)\nreturn x1 - y2;\nreturn 0;\n```\n\n## ExpectedMinimumPowerDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14813)\n\nUsed as: Division Two - Level Two:\n\n| Value              | 500                                            |\n| Submission Rate    | 106 / 267 (39.70%)                             |\n| Success Rate       | 87 / 106 (82.08%)                              |\n| High Score         | __cxhscst2__ for 469.89 points (7 mins 17 secs)|\n| Average Score      | 296.77 (for 87 correct submissions)            |\n\nFor each s, let’s count in how many ways s is the minimum element. We must choose s and also x - 1 elements greater than x. So we want to calculate\n\n![SRM 730 1](//images.ctfassets.net/piwi0eufbb2g/64aP50sl1eQhkahin4FM34/9261fb01e643bd1b2ffc137ed8f73ab0/SRM_730_1.webp)\n\nWe can calculate the [n choose r](https://cp-algorithms.com/combinatorics/binomial-coefficients.html) for each i. This leads to an O(n^2) solution. Note that n choose r never overflows from the 64-bit integer (e. g. long long in C++) when n, r are in the range [1, 50].Another solution is to calculate n choose r for all of the possible values in the range [1, 50] (preprocessing). Like the code below by [cxhscst2](https://www.topcoder.com/members/cxhscst2):\n\n```\nconst int M = 60;\nlong long c[M][M];\ndouble findExp(int n, int x) {\nmemset(c, 0, sizeof c); // fill all of the array with 0\nc[0][0] = 1;\nfor(int i = 0; i <= 50; i++){\nc[i][0];\nfor(int j = 1; j <= i; j++)\nc[i][j] = c[i - 1][j - 1] + c[i - 1][j];\n}\ndouble ans = 0;\nfor(int i = 1; i <= n - x + 1; i++){\nint now = n - i;\ndouble ss = 1;\nfor(int j = 1; j <= i; j++)\nss = ss * 2;\nans = ans + ss / (double) c[n][x] * c[now][x - 1];\n}\nreturn ans;\n}\n```\n\nAnother solution written in java:\n\n```\npublic double findExp(int n, int x) {\nlong total = 0;\nlong p = 0;\nfor (int min = 1; min <= n - x + 1; min++) {\nlong sets = comb(n - min, x - 1);\ntotal += sets;\nlong bit = (1L << min);\np += bit * sets;\n}\nreturn p / (double) total;\n}\n\nprivate long comb(long n, long k) {\nif (k == 0) return 1L;\nreturn (n * comb(n - 1, k - 1)) / k;\n}\n```\n\n## StonesOnATreeDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14812)\n\nUsed as: Division Two - Level Three:\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 1000                                             |\n| __Submission Rate__       | 18 / 267 (6.74%)                             |\n| __Success Rate__          | 3 / 18 (16.67%)                              |\n| __High Score__            | __maroon_kuri__ for 897.68 points (9 mins 49 secs) |\n| __Average Score__         | 640.17 (for 3 correct submissions)           |\n\n## StonesOnATree\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14811)\n\nUsed as: Division One - Level One:\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 250                                          |\n| __Submission Rate__       | 181 / 216 (83.80%)                           |\n| __Success Rate__          | 109 / 181 (60.22%)                           |\n| __High Score__            | __Kriii__ for 236.54 points (6 mins 51 secs) |\n| __Average Score__         | 161.34 (for 109 correct submissions)         |\n\nThe main goal of the game is to put a stone on the root. What is the last step before we can do it? Putting a stone on each of the children of the root. Because w[] is increasing, we will put a stone on each of the children one by one. i. e. we find a permutation of children, then we will manage to put a stone on each of them one by one.\n\ndp[v] = The smallest W for which there is a way to put a stone on v such that during the game the total weight of nodes with stones never exceeds W. Note that we only consider subtree of v.\n\nFor example, consider the root has only two children: c, d. If we choose to put a stone on c then d, the answer is max(dp[c], w[c] + dp[d]).\n\nIf we choose permutation p, then dp[0] = max(dp[p[0]], w[p[0]] + dp[p[1]], w[p[0]] + w[p[1]] + dp[p[2]], …).\n\nWe should find a permutation that leads to the minimum answer. Consider two children c, d. We put c before d in the permutation if and only if w[c] + dp[d] ```<``` w[d] + dp[c].\n\nSo we sort the children with the comparison function above and calculate the dp.C++ code by [Kriii](https://profiles.topcoder.com/Kriii):\n\n```\nint minStones(vector<int p, vector<int w) {\nint n = p.size() + 1;\nvector<vector<int g(n);\nfor (int i = 1; i < n; i++) g[p[i - 1]].push_back(i);\n\nvector<int a(n);\nfor (int i = n - 1; i = 0; i--) {\nvector<pair<int, int u;\nfor (auto &x : g[i]) u.push_back({ w[x],a[x] });\nsort(u.begin(), u.end(), [](const pair<int, int &a, const pair<int, int &b) {\nreturn max(a.second, a.first + b.second) < max(b.second,b.first+a.second);\n});\n\nint r = 0, s = 0;\nfor (auto &p : u) {\nr = max(r, s + p.second);\ns += p.first;\n}\na[i] = max(r, s + w[i]);\n}\nreturn a[0];\n}\n```\n\n## Subgraphs\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14817)\n\nUsed as: Division One - Level Two:\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 500                                          |\n| __Submission Rate__       | 63 / 216 (29.17%)                           |\n| __Success Rate__          | 51 / 63 (80.95%)                          |\n| __High Score__            | __Kriii__ for 413.36 points (13 mins 36 secs) |\n| __Average Score__         | 283.53 (for 51 correct submissions)        |\n\nHere is the graph:\n![SRM 730 2](//images.ctfassets.net/piwi0eufbb2g/4ji5g9asfzpOerm7HltjWC/979e452d0de3e223b268726107110c4b/SRM_730_2.webp)\n\nThere is no edge between vertices in the range [1, k].\n\nAll of the vertices in the range [k+1, 2k] are pairwise connected.\n\nVertex i (i ```<=``` k) is connected to k + 1, k + 2, … k + i.\n\nNow to select a subgraph with x edges and k vertices, let p be the greatest integer such that p * (p - 1) / 2 ```<=``` x. We select the vertices in the ranges [2k - p + 1, 2k], [1, k - p - 1], and the vertex k - p + x - p * (p - 1) / 2.\n\n```\nvector<string findGroups(int k) {\nint f[50][50] = { 0, };\nvector<string choose;\nchoose.push_back(\"YN\");\nfor (int j = 2; j <= k; j++) {\nvector<string nchoose;\nfor (auto &s : choose) nchoose.push_back(s + \"NY\");\nfor (int i = 0; i < 2 * j - 2; i++) f[i][2 * j - 2] = f[2 * j - 2][i] = 1;\nint u = j * (j - 1) / 2;\nfor (int i = choose.size(); i <= u; i++) {\nnchoose.push_back(choose[i - (j - 1)] + \"YN\");\n}\nchoose = nchoose;\n}\nvector<string ans;\n\nint n = 2 * k;\nfor (int i = 0; i < n; i++) {\nstring s;\nfor (int j = 0; j < n; j++) {\nif (f[i][j]) s += '1';\nelse s += '0';\n}\nans.push_back(s);\n}\n\nans.insert(ans.end(),choose.begin(), choose.end());\nreturn ans;\n}\n\n```\n\n## ExpectedMinimumPower \n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14795)\n\nUsed as: Division One - Level Three:\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 1000                                          |\n| __Submission Rate__       | 24 / 216 (11.11%)                             |\n| __Success Rate__          | 24 / 24 (100.00%)                             |\n| __High Score__            | __ksun48__ for 975.25 points (4 mins 32 secs) |\n| __Average Score__         |722.85 (for 24 correct submissions)            |\n\nThe problem is asking for\n![SRM 730 3](//images.ctfassets.net/piwi0eufbb2g/4JXvgc69dYYRfuw9qmuHku/959012c102eb59952df4958817b8320c/SRM_730_3.webp)\n\nWe calculate\n![SRM 730 4](//images.ctfassets.net/piwi0eufbb2g/4xPtOW4QY2EPQ9IIGEmBcV/f8c814e5d53403b4e79fcbd2feaf36be/SRM_730_4.webp)\ninstead and then double the answer.\n\nConsider the following problem: “We have n people. Choose one of them as the leader, then choose x - 1 people with greater index as deputy and choose a subset (possibly empty) of people with less index (than the leader) as an employee. How many ways are there?\n\nYou can deduce that answer to this problem is\n\n![SRM 730 5](//images.ctfassets.net/piwi0eufbb2g/3DQDadzROmhPOxDViB84A7/bd304ef70871a25fb75726c87f556c13/SRM_730_5.webp)\n\nLet’s calculate the answer in another way. For each of the ways for the above problem, the last x - 1 chosen persons are deputy. The x-th one is the leader and others are employees.\n\nSo, for each subset of n people having at least x people, it is also an answer to the above problem. So,\n\n![SRM 730 6](//images.ctfassets.net/piwi0eufbb2g/1uEH1t3iZDp5EIy9ASj8SD/66e93ff42a780cf0d5615eb54df5b348/SRM_730_6.webp)\n\n```\ntypedef long long LL;\n#define MOD 1000000007\nLL powmod(LL a, LL n){\nif(n == 0) return 1;\nif(n % 2) return (a*powmod(a,n-1)) % MOD;\nLL c = powmod(a, n/2);\nreturn (c*c) % MOD;\n}\nLL inv(LL a){\nreturn powmod(a, MOD-2);\n}\n\n// call init();\nclass ExpectedMinimumPower{\npublic:\nLL findExp(LL n, LL x){\nLL ans = 0;\nLL cur = 1;\nfor(LL a = 0; a < x; a++){\nans += cur;\ncur = (cur * (n - a)) % MOD;\ncur = (cur * inv(a + 1)) % MOD;\nans %= MOD;\n}\nans = powmod(2, n) - ans;\nans %= MOD;\nans *= 2;\nans %= MOD;\nwhile(ans < 0) ans += MOD;\nreturn ans;\n}\n};\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-730-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"p65ZTGtN6RstpiBOXXs4f","type":"Entry","createdAt":"2020-04-20T12:42:14.086Z","updatedAt":"2026-03-09T22:00:25.411Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":50,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 731","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-07-11T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 731 Editorials\n\n## Division 2 Easy - RingLex\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14859)\n\nThe problem requires brute-forcing the offset x and the prime number p, which both are less than n. There are at most n^2 combinations of (x,p).\n\nIf we decide n and p, we can generate string of length n. The minimal one is the answer. The computation time is proportional to n^3.The constraints of n```<=```50 says that this solution will pass in execution time limit of 2 seconds.\n\nSince n```<=```50, we can judge prime by checking if the number is 2, 3, 5, 7, 11, 13, 17, 23, 29, 31, 37, 43, 47 or not. But there’s a different way. The prime numbers are the numbers which is not divisible by any integer between 2 and  p-1. If we check divisibility for all numbers between 2 and p-1, we can check if the number p is a prime.\n\n```\n#include <string\n\n#include <algorithm\n\nusing namespace std;\nclass RingLex {\npublic:\nbool isprime(int n) {\nif (n <= 1) return false;\nfor (int i = 2; i < n; ++i) {\nif (n % i == 0) return false;\n}\nreturn true;\n}\nstring getmin(string s) {\nint n = s.size();\nstring t;\nfor (int i = 0; i < n; ++i) t += s;\nstring ans = \"~\"; // ASCII Code 127\nfor (int i = 0; i < n; ++i) {\nfor (int j = 1; j < n; ++j) {\nif (isprime(j)) {\nstring gen;\nfor (int k = 0; k < n; ++k) {\ngen += t[i + j * k];\n}\nans = min(ans, gen);\n}\n}\n}\nreturn ans;\n}\n};\n```\n\n## Division 2 Medium - DancingClass\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14857)\n\nSome problem requires big integers which is more than 64-bits. This problem is one example.\n\nFirst, we explain how to calculate the probability of which the number of boy-girl pairs will be at least K, in the randomly-gendered N people in dancing class.\n\nIf there are i boys and N-i girls, we will have i(N-i) boy-girl pair. This probability will be (½)^N * C(N,i)  where C(N,i) is the number of combinations to choose i items from N distinguishable items. This is called “binomial coefficient”, and it can be calculated from [Pascal’s Triangle](https://en.wikipedia.org/wiki/Pascal%27s_triangle). The probability that there are at least K boy-girl pairs is the sum of (1/2)^N * C(N,i) for all integer i which holds i*(N-i) >= K.\n\nSecond, we will explain how can we deal with the very big numbers. One possible way is to use double (in C++, C#, Java) or long double (in C++) typed variables, which stores real numbers. The double-typed (64-bit) real number variables will assure error of about at most 10^-15 per an arithmetic operation. Here, there are no cases that the probability will be 0.5-x or 0.5+x for very small x like 10^-12, it is okay. The example source code is eriksuenderhauf’s Program written during the contest.\n\nHowever, we can also use big integers. To solve just with integers (not using real numbers), we need to calculate the sum of C(N,i) for all i which holds  i*(N-i) = K, and check if the sum (let this be S) is larger than, equal to, or less than 2^N-1.We can calculate S by using Pascal’s triangle, but we can also use the formula C(N,i)+ C(N, i-1) * (N-i+1)/ i and calculate C(N,i)  in increasing order of i. This will achieve the time complexity of O(N^2). Here is my implementation in C++. (Since it includes my personal source code library of big integers, the source code size is relatively large)\n\n```\n#ifndef ___CLASS_MODINT\n#define ___CLASS_MODINT\n#include <vector\n\n#include <cstdint\n\nusing singlebit = uint32_t;\nusing doublebit = uint64_t;\nstatic constexpr singlebit find_inv(singlebit n, int d = 5, singlebit x = 1) {\nreturn d == 0 ? x : find_inv(n, d - 1, x * (2 - x * n));\n}\ntemplate <singlebit mod, singlebit primroot class modint {\n// Fast Modulo Integer, Assertion: mod < 2^31\nprivate:\nsinglebit n;\nstatic constexpr int level = 32; // LIMIT OF singlebit\nstatic constexpr singlebit max_value = -1;\nstatic constexpr singlebit r2 = (((1ull << level) % mod) << level) % mod;\nstatic constexpr singlebit inv = singlebit(-1) * find_inv(mod);\nstatic singlebit reduce(doublebit x) {\nsinglebit res = (x + doublebit(singlebit(x) * inv) * mod) level;\nreturn res < mod ? res : res - mod;\n}\npublic:\nmodint() : n(0) {};\nmodint(singlebit n_) { n = reduce(doublebit(n_) * r2); };\nmodint& operator=(const singlebit x) { n = reduce(doublebit(x) * r2); return *this; }\nbool operator==(const modint& x) const { return n == x.n; }\nbool operator!=(const modint& x) const { return n != x.n; }\nmodint& operator+=(const modint& x) { n += x.n; n -= (n < mod ? 0 : mod); return *this; }\nmodint& operator-=(const modint& x) { n += mod - x.n; n -= (n < mod ? 0 : mod); return *this; }\nmodint& operator*=(const modint& x) { n = reduce(1ull * n * x.n); return *this; }\nmodint operator+(const modint& x) const { return modint(*this) += x; }\nmodint operator-(const modint& x) const { return modint(*this) -= x; }\nmodint operator*(const modint& x) const { return modint(*this) *= x; }\nstatic singlebit get_mod() { return mod; }\nstatic singlebit get_primroot() { return primroot; }\nsinglebit get() { return reduce(doublebit(n)); }\nmodint binpow(singlebit b) {\nmodint ans(1), cur(*this);\nwhile (b 0) {\nif (b & 1) ans *= cur;\ncur *= cur;\nb = 1;\n}\nreturn ans;\n}\n};\ntemplate<typename modulo\n\nstd::vector<modulo get_modvector(std::vector<int v) {\nstd::vector<modulo ans(v.size());\nfor (int i = 0; i < v.size(); ++i) {\nans[i] = v[i];\n}\nreturn ans;\n}\n#endif\n#ifndef ___CLASS_NTT\n#define ___CLASS_NTT\n#include <vector\n\ntemplate<typename modulo\n\nclass ntt {\n// Number Theoretic Transform\nprivate:\nint depth;\nstd::vector<modulo roots;\nstd::vector<modulo powinv;\npublic:\nntt() {\ndepth = 0;\nuint32_t div_number = modulo::get_mod() - 1;\nwhile (div_number % 2 == 0) div_number = 1, ++depth;\nmodulo b = modulo::get_primroot();\nfor (int i = 0; i < depth; ++i) b *= b;\nmodulo baseroot = modulo::get_primroot(), bb = b;\nwhile (bb != 1) bb *= b, baseroot *= modulo::get_primroot();\nroots = std::vector<modulo(depth + 1, 0);\npowinv = std::vector<modulo(depth + 1, 0);\npowinv[1] = (modulo::get_mod() + 1) / 2;\nfor (int i = 2; i <= depth; ++i) powinv[i] = powinv[i - 1] * powinv[1];\nroots[depth] = 1;\nfor (int i = 0; i < modulo::get_mod() - 1; i += 1 << depth) roots[depth] *= baseroot;\nfor (int i = depth - 1; i = 1; --i) roots[i] = roots[i + 1] * roots[i + 1];\n}\nvoid fourier_transform(std::vector<modulo &v, bool inverse) {\nint s = v.size();\nfor (int i = 0, j = 1; j < s - 1; ++j) {\nfor (int k = s 1; k (i ^= k); k = 1);\nif (i < j) std::swap(v[i], v[j]);\n}\nint sc = 0, sz = 1;\nwhile (sz < s) sz *= 2, ++sc;\nstd::vector<modulo pw(s + 1); pw[0] = 1;\nfor (int i = 1; i <= s; i++) pw[i] = pw[i - 1] * roots[sc];\nint qs = s;\nfor (int b = 1; b < s; b <<= 1) {\nqs = 1;\nfor (int i = 0; i < s; i += b * 2) {\nfor (int j = i; j < i + b; ++j) {\nmodulo delta = pw[(inverse ? b * 2 - j + i : j - i) * qs] * v[j + b];\nv[j + b] = v[j] - delta;\nv[j] += delta;\n}\n}\n}\nif (inverse) {\nfor (int i = 0; i < s; ++i) v[i] *= powinv[sc];\n}\n}\nstd::vector<modulo convolve(std::vector<modulo v1, std::vector<modulo v2) {\nconst int threshold = 16;\nif (v1.size() < v2.size()) swap(v1, v2);\nint s1 = 1; while (s1 < v1.size()) s1 <<= 1; v1.resize(s1);\nint s2 = 1; while (s2 < v2.size()) s2 <<= 1; v2.resize(s2 * 2);\nstd::vector<modulo ans(s1 + s2);\nif (s2 <= threshold) {\nfor (int i = 0; i < s1; ++i) {\nfor (int j = 0; j < s2; ++j) {\nans[i + j] += v1[i] * v2[j];\n}\n}\n}\nelse {\nfourier_transform(v2, false);\nfor (int i = 0; i < s1; i += s2) {\nstd::vector<modulo v(v1.begin() + i, v1.begin() + i + s2);\nv.resize(s2 * 2);\nfourier_transform(v, false);\nfor (int j = 0; j < v.size(); ++j) v[j] *= v2[j];\nfourier_transform(v, true);\nfor (int j = 0; j < s2 * 2; ++j) {\nans[i + j] += v[j];\n}\n}\n}\nreturn ans;\n}\n};\n#endif\n#ifndef __CLASS_BASICINTEGER\n#define __CLASS_BASICINTEGER\n#include <vector\n\nusing modulo1 = modint<469762049, 3; ntt<modulo1 ntt_base1;\nusing modulo2 = modint<167772161, 3; ntt<modulo2 ntt_base2;\nconst modulo1 magic_inv = modulo1(modulo2::get_mod()).binpow(modulo1::get_mod() - 2);\ntemplate<int base\n\nclass basic_integer {\nprotected:\nstd::vector<int a;\npublic:\nbasic_integer() : a(std::vector<int({ 0 })) {};\nbasic_integer(const std::vector<int& a_) : a(a_) {};\nint size() const { return a.size(); }\nint nth_digit(int n) const { return a[n]; }\nbasic_integer& resize() {\nint lim = 1;\nfor (int i = 0; i < a.size(); ++i) {\nif (a[i] != 0) lim = i + 1;\n}\na.resize(lim);\nreturn *this;\n}\nbasic_integer& shift() {\nfor (int i = 0; i < int(a.size()) - 1; ++i) {\nif (a[i] = 0) {\na[i + 1] += a[i] / base;\na[i] %= base;\n}\nelse {\nint x = (-a[i] + base - 1) / base;\na[i] += x * base;\na[i + 1] -= x;\n}\n}\nwhile (a.back() = base) {\na.push_back(a.back() / base);\na[a.size() - 2] %= base;\n}\nreturn *this;\n}\nbool operator==(const basic_integer& b) const { return a == b.a; }\nbool operator!=(const basic_integer& b) const { return a != b.a; }\nbool operator<(const basic_integer& b) const {\nif (a.size() != b.a.size()) return a.size() < b.a.size();\nfor (int i = a.size() - 1; i = 0; --i) {\nif (a[i] != b.a[i]) return a[i] < b.a[i];\n}\nreturn false;\n}\nbool operator(const basic_integer& b) const { return b < (*this); }\nbool operator<=(const basic_integer& b) const { return !((*this) b); }\nbool operator=(const basic_integer& b) const { return !((*this) < b); }\nbasic_integer& operator<<=(const uint32_t x) {\nif (a.back() = 1 || a.size() = 2) {\nstd::vector<int v(x, 0);\na.insert(a.begin(), v.begin(), v.end());\n}\nreturn (*this);\n}\nbasic_integer& operator=(const uint32_t x) {\nif (x == 0) return *this;\nif (x a.size()) a = { 0 };\nelse a = std::vector<int(a.begin() + x, a.end());\nreturn (*this);\n}\nbasic_integer& operator+=(const basic_integer& b) {\nif (a.size() < b.a.size()) a.resize(b.a.size(), 0);\nfor (int i = 0; i < b.a.size(); ++i) a[i] += b.a[i];\nreturn (*this).shift();\n}\nbasic_integer& operator-=(const basic_integer& b) {\nfor (int i = 0; i < b.a.size(); ++i) a[i] -= b.a[i];\nreturn (*this).shift().resize();\n}\nbasic_integer& operator*=(const basic_integer& b) {\nstd::vector<modulo1 mul_base1 = ntt_base1.convolve(get_modvector<modulo1(a), get_modvector<modulo1(b.a));\nstd::vector<modulo2 mul_base2 = ntt_base2.convolve(get_modvector<modulo2(a), get_modvector<modulo2(b.a));\nconst int margin = 20;\na = std::vector<int(mul_base1.size() + margin);\nfor (int i = 0; i < a.size() - margin; ++i) {\n// s * p1 + a1 = val = t * p2 + a2's solution is t = (a1 - a2) / p2 (mod p1)\nlong long val = (long long)(((mul_base1[i] - modulo1(mul_base2[i].get())) * magic_inv).get()) * modulo2::get_mod() + mul_base2[i].get();\nfor (int j = i; val 0 && j < a.size(); ++j) {\na[j] += val % base;\nif (a[j] = base) {\na[j] -= base;\na[j + 1] += 1;\n}\nval /= base;\n}\n}\nreturn (*this).resize();\n}\nbasic_integer& operator/=(const basic_integer& b) {\nint preci = a.size() - b.a.size();\nbasic_integer t({ 1 });\nbasic_integer two = basic_integer({ 2 }) << b.a.size();\nbasic_integer pre;\nint lim = std::min(preci, 3);\nint blim = std::min(int(b.a.size()), 6);\nt <<= lim;\nwhile (pre != t) {\nbasic_integer rb = b (b.a.size() - blim);\nif (blim != b.a.size()) rb += basic_integer({ 1 });\npre = t;\nt *= (basic_integer({ 2 }) << (blim + lim)) - rb * t;\nt.a = std::vector<int(t.a.begin() + lim + blim, t.a.end());\n}\nif (lim != preci) {\npre = basic_integer();\nwhile (pre != t) {\nbasic_integer rb = b (b.a.size() - blim);\nif (blim != b.a.size()) rb += basic_integer({ 1 });\npre = t;\nt *= (basic_integer({ 2 }) << (blim + lim)) - rb * t;\nt.a = std::vector<int(t.a.begin() + lim + blim, t.a.end());\nint next_lim = std::min(lim * 2 + 1, preci);\nif (next_lim != lim) t <<= next_lim - lim;\nint next_blim = std::min(blim * 2 + 1, int(b.a.size()));\nlim = next_lim;\nblim = next_blim;\n}\n}\nbasic_integer ans = (*this) * t;\nans.a = std::vector<int(ans.a.begin() + a.size(), ans.a.end());\nwhile ((ans + basic_integer({ 1 })) * b <= (*this)) {\nans += basic_integer({ 1 });\n}\n(*this) = ans.resize();\nreturn *this;\n}\nbasic_integer& divide_by_2() {\nfor (int i = a.size() - 1; i = 0; --i) {\nint carry = a[i] % 2;\na[i] /= 2;\nif (i != 0) a[i - 1] += carry * base;\n}\nif (a.size() = 2 && a.back() == 0) a.pop_back();\nreturn *this;\n}\nbasic_integer operator<<(int x) const { return basic_integer(*this) <<= x; }\nbasic_integer operator (int x) const { return basic_integer(*this) = x; }\nbasic_integer operator+(const basic_integer& b) const { return basic_integer(*this) += b; }\nbasic_integer operator-(const basic_integer& b) const { return basic_integer(*this) -= b; }\nbasic_integer operator*(const basic_integer& b) const { return basic_integer(*this) *= b; }\nbasic_integer operator/(const basic_integer& b) const { return basic_integer(*this) /= b; }\n};\n#endif\n#ifndef ___CLASS_NEWBIGINT\n#define ___CLASS_NEWBIGINT\n#include <string\n\n#include <iostream\n\n#include <algorithm\n\nconst int digit = 4;\nconst int digit_base = 10000;\nclass bigint : public basic_integer<digit_base {\npublic:\nbigint() { a = std::vector<int({ 0 }); };\nbigint(long long x) {\na.clear();\nfor (int i = 0; x 0; ++i) {\na.push_back(x % digit_base);\nx /= digit_base;\n}\nif (a.size() == 0) a = { 0 };\n}\nbigint(const std::string& s) {\na.clear();\nfor (int i = 0; digit * i < s.size(); ++i) {\na.push_back(std::stoi(s.substr(std::max(int(s.size()) - i * digit - digit, 0), digit - std::max(digit + i * digit - int(s.size()), 0))));\n}\nif (a.size() == 0) a = { 0 };\n}\nstd::string to_string() const {\nstd::string ret;\nbool flag = false;\nfor (int i = a.size() - 1; i = 0; --i) {\nif (a[i] 0 && !flag) {\nret += std::to_string(a[i]);\nflag = true;\n}\nelse if (flag) {\nstd::string sub = std::to_string(a[i]);\nret += std::string(digit - sub.size(), '0') + sub;\n}\n}\nreturn ret.empty() ? \"0\" : ret;\n}\nint convert_int() const { return std::stoi((*this).to_string()); }\nlong long convert_ll() const { return std::stoll((*this).to_string()); }\nbigint& operator<<=(int x) { return reinterpret_cast<bigint&(reinterpret_cast<basic_integer&(a) <<= x); }\nbigint& operator=(int x) { return reinterpret_cast<bigint&(reinterpret_cast<basic_integer&(a) = x); }\nbigint& operator+=(const bigint& b) { return reinterpret_cast<bigint&(reinterpret_cast<basic_integer&(a) += basic_integer(b)); }\nbigint& operator-=(const bigint& b) { return reinterpret_cast<bigint&(reinterpret_cast<basic_integer&(a) -= basic_integer(b)); }\nbigint& operator*=(const bigint& b) { return reinterpret_cast<bigint&(reinterpret_cast<basic_integer&(a) *= basic_integer(b)); }\nbigint& operator/=(const bigint& b) { return reinterpret_cast<bigint&(reinterpret_cast<basic_integer&(a) /= basic_integer(b)); }\nbigint& divide_by_2() { return reinterpret_cast<bigint&(reinterpret_cast<basic_integer&(a).divide_by_2()); }\nbigint operator<<(int x) const { return bigint(*this) <<= x; }\nbigint operator (int x) const { return bigint(*this) = x; }\nbigint operator+(const bigint& b) const { return bigint(*this) += b; }\nbigint operator-(const bigint& b) const { return bigint(*this) -= b; }\nbigint operator*(const bigint& b) const { return bigint(*this) *= b; }\nbigint operator/(const bigint& b) const { return bigint(*this) /= b; }\nfriend std::istream& operator (std::istream& is, bigint& x) { std::string s; is s; x = bigint(s); return is; }\nfriend std::ostream& operator<<(std::ostream& os, const bigint& x) { os << x.to_string(); return os; }\n};\n#endif\n#include <string\n\nusing namespace std;\nclass DancingClass {\npublic:\nstring checkOdds(int N, int K) {\nvector<bigint b(N + 1);\nb[0] = 1;\nfor (int i = 1; i <= N; ++i) {\nb[i] = (b[i - 1] * (N - i + 1)) / i;\n}\nbigint all = 0, sum = 0;\nfor (int i = 0; i <= N; ++i) {\nall += b[i];\nif (i * (N - i) = K) sum += b[i];\n}\nif (sum * 2 == all) return \"Equal\";\nreturn sum * 2 all ? \"High\" : \"Low\";\n}\n};\n```\n\n## Division 2 Hard - JustBrackets\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14855)\n\nSolving this problem is difficult. Most of them came up with wrong solutions and failed in system tests. Only one competitor submitted a correct solution and passed.\n\nMy solution uses SRM 731 Division 1 Easy - TreesAndBrackets as a subproblem. This problem means, given a bracket string S, check if we can turn this string to bracket string T with some operations of removing consecutive “()”.\n\nThis problem (Div2 Hard) asks to find lexicographically smallest string from S with some operations of removing consecutive “()”.\n\nLet’s do greedy approach. We will decide the answer from the first character. The example of approach is as follows:\n\nCan the resulted string start from “(“ ? → Yes (The 1st letter of optimal answer is “(“ )\n\nCan the resulted string start from “((“ ? → Yes (The 2nd letter of optimal answer is “(” )\n\nCan the resulted string start from “(((“ ? → No (The 3rd letter of optimal answer is “)” )\n\nCan the resulted string start from “(()(“ ? → Yes (The 4th letter of optimal answer is “(“ )\n\nAnd so on…\n\nHere, if the resulted string became a non-empty valid bracket sequence, we can terminate this loop, because it has no meaning (will be lexicographically larger) to append any string.\n\nSo, how can you judge things like “Can the resulted string start from “(()(“ ?”. Actually, it is equivalent to the question “Can the resulted string start from “(()())” ?”, which is also equivalent to “Can the resulted string be “(()())” ?”. It means, instead of asking if the resulted string start from a non-necessarily valid bracket sequence, we can ask if the resulted string be a valid bracket sequence by adding some “)”.\n\nYou may notice that this subproblem is same as Div1 Easy one. We can calculate in O(N^2) (see my editorial of Div1 Easy). Since the greedy approach takes at most N steps, we can solve this problem in O(N^3) time complexity.\n\nOf course, I think there can be a faster solution. Let’s think about it :)\n\n__Time Complexity: O(N^3)__\n\n```\n#include <string\n\n#include <vector\n\n#include <iostream\n\n#include <algorithm\n\nusing namespace std;\nclass JustBrackets {\npublic:\nbool valid(string S, string T) {\nvector<string sp, tp;\nint depth = 0, pre = 0;\nfor(int i = 0; i < S.size(); ++i) {\nif(S[i] == '(') ++depth;\nelse --depth;\nif(depth == 0) {\nstring sub = S.substr(pre + 1, i - 1 - pre);\nsp.push_back(sub);\npre = i + 1;\n}\n}\ndepth = 0, pre = 0;\nfor(int i = 0; i < T.size(); ++i) {\nif(T[i] == '(') ++depth;\nelse --depth;\nif(depth == 0) {\nstring sub = T.substr(pre + 1, i - 1 - pre);\ntp.push_back(sub);\npre = i + 1;\n}\n}\nint ptr = 0;\nfor(int i = 0; i < tp.size(); ++i) {\nwhile(ptr < sp.size()) {\nbool res = valid(sp[ptr], tp[i]);\nif(res) break;\n++ptr;\n}\nif(ptr == sp.size()) return false;\n++ptr;\n}\nreturn true;\n}\nstring getSmallest(string S) {\nstring ans = \"\";\nwhile(true) {\nint depth = 0;\nfor(int i = 0; i < ans.size(); ++i) {\nif(ans[i] == '(') ++depth;\nelse --depth;\n}\nif(ans != \"\" && depth == 0) break;\nstring nxt = ans + \"(\" + string(depth + 1, ')');\nif(valid(S, nxt)) ans += '(';\nelse ans += ')';\n}\nreturn ans;\n}\n};\n```\n\n## Division 1 Easy - TreesAndBrackets\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14836)\n\n__Solution with Reversed Thinking + Dynamic Programming__\nIn this problem, we remove leaves and transform t1 to  t2. However, we can also think that this problem is to add leaves and transform  t2 to t1.\n\nIf we think about it we can solve by DP. To make a valid tree from   t2, we can repeatedly insert “valid forest string” between i-th character and (i+1)-th character 1<= i <=|t2| -1).\n\nHere, “valid forest string” is the string which has following properties:\n\nThere number of ‘(‘ and the number of ‘)’ are same.\n\nFor any prefix, the number of ‘(‘ is greater than or equal to the number of ‘)’.\n\nSuch string is sometimes called “parenthesis sequence” or “parenthesis string”. There are many problems in competitive programming which uses parenthesis sequence, for example, SRM 521 Div1 Easy - MissingParentheses.\n\nNow, let dp[i][j] that “We can transform validly when just looking first i characters of t2 and first j characters of t1”.\n\nHere, dp[i][j] is true. For other dp[i][j], it is true if it meets either of conditions:\n\nt2[i-1]=t1[j-1]and dp[i-1][j-1]  is true\n\nt1[j-k,j) is a valid forest string and dp[i][j-k] is true\n\nIf dp[|t2|][|t1|] is true, the answer is “Possible”, otherwise “Impossible”. We can solve this problem in time complexity O(N^4) and this can be improved to O(N^3) if we only take constant time to judge if the substring is a valid forest string.\n\nDuring the contest, ainta solved in this way and solved in just 4 minutes and 36 seconds! We can see his source code for implementation.\n\nSolution with DFS + Greedy Algorithm\n\nFor some people this solution could be more simple. Let’s try to solve recursively.\n\nFirst, let’s think the following situation:\n\nt1 is expressed as ((u1)(u2 )....(ux ))\n\nt2 s expressed as  ((v1)(v2 )....(vy ))\n\nWe can use greedy algorithm. If (u1) can be transformed to (v1), then we should only care about if ((u2)(u3 )....(ux )) can be transformed to  ((v23)(v )....(vy )). In other words, “match (u1) and  (v1)”. If cannot, we should only care about if ((u2)(u3 )....(ux )) can be transformed to ((v1)(v2 )....(vy )). In other words, (u1) will not be “matched” to anything.\n\nWe can judge it recursively. The total number of recursion is at most n times, so the time complexity will be O(n^2) (depends on implementation, though), which is faster than DP solution.\n\n```\n#include <string\n\n#include <vector\n\n#include <iostream\n\n#include <algorithm\n\nusing namespace std;\nclass TreesAndBrackets {\npublic:\nbool valid(string S, string T) {\nvector<string sp, tp;\nint depth = 0, pre = 0;\nfor(int i = 0; i < S.size(); ++i) {\nif(S[i] == '(') ++depth;\nelse --depth;\nif(depth == 0) {\nstring sub = S.substr(pre + 1, i - 1 - pre);\nsp.push_back(sub);\npre = i + 1;\n}\n}\ndepth = 0, pre = 0;\nfor(int i = 0; i < T.size(); ++i) {\nif(T[i] == '(') ++depth;\nelse --depth;\nif(depth == 0) {\nstring sub = T.substr(pre + 1, i - 1 - pre);\ntp.push_back(sub);\npre = i + 1;\n}\n}\nint ptr = 0;\nfor(int i = 0; i < tp.size(); ++i) {\nwhile(ptr < sp.size()) {\nbool res = valid(sp[ptr], tp[i]);\nif(res) break;\n++ptr;\n}\nif(ptr == sp.size()) return false;\n++ptr;\n}\nreturn true;\n}\nstring check(string S, string T) {\nbool res = valid(S, T);\nreturn (res ? \"Possible\" : \"Impossible\");\n}\n};\n```\n\n## Division 1 Medium - RndSubTree\n[Problem Details\n](https://archive.topcoder.com/ProblemStatement/pm/14837)\nI think that this problem is difficult. Even more difficult than Div1 Hard of this contest, aside from the number of solvers were larger for Div1 Medium.\n\n__Prerequisite: Knowledge about Binomial Distribution__\nA binomial distribution X= B(n,p) is the probabilistic distribution of number of successes for n independent trials which will success at probability p.\n\nThe expected value E(X)= np. That’s because there are n independent trials that the expected ‘contribution’ to the final number of successes is p.\n\nThe variance V(X)=np(1-p). If n=1, the value is 0 for probability 1-p and 1 for probability p, so the variance is V(X)=(1-p)(0-p)^2 + p(1-p)^2= p(1-p). Since there are n independent trials, the variance will be multiplied by n, which means V(X)= np(1-p).\n\nNow let’s find the expected square of value E(X^2). There is a famous formula that, for any probabilistic distribution, V(X)=E(X^2)- (E(X))^2. It means, for binomial distribution X= B(n,p) X=B(n, p), the expected square of value E(X^2)= (E(X))^2+V(X)= (np)^2 +np(1-p) = np(np-p +1).\n\n__Solution Part #1 - How can we calculate the expected probability?__\n\nLet G be a rooted tree of N vertices. This time, G will be the (induced) subgraph consists of all red vertices on infinite binary tree. The total distance of N(N-1)/2 pair of vertices can be calculated in this way: Letting Ci be the size of subtree of G rooted at vertex i, the total distance will be equal to the sum of ci * (N-Ci). It is intuitive if you think about the number of shortest paths which passes the ancestor-going edge from vertex i, is  ci * (N-Ci)\n\nSo, we should calculate the expected value of  ci * (N-Ci) for all red vertices. But we need one more additional information j - the probability of which the vertex  will turn red in exactly j-th token-putting operation. Let this probability P(j,i). Also, let Ri the probability which token passes vertex i when putting one token after the vertex i turns red. The expected contribution to ci * (N-Ci) will be P(j,i) * E((X+1) * (N-X-1)) where X=B(N-j-1,Ri ).\n\n__Solution Part #2 - Calculating exact expected values__\n\nHere,  P(j,i) is same if the depth of vertex i is same. So, we define P(j,i) the probability of which the leftmost vertex of depth i will turn red in exactly j-th token-putting operation. Here, there are two children (call left/right child) in a vertex of infinite binary tree. And the leftmost vertex of depth i means the vertex which goes left children i times from the root.\n\nLet q(j,i) the probability that the maximum depth of red leftmost vertex is i when exactly j tokens were put. Here, it holds:\n\np(j,i) = q(j,i)+ q(j, i+1)+ q(j,i+2)+.... -1(j-1, i+1)+q(j-1, i+2)... \n\nWe can calculate q(j,i) by dynamic programming.\n\nq(1,0)=1 \n\nq(j,i) = q(j-1, i)* (1-2^(i+1)) + q(j-1, i-1) *2^-i\n\nNote that the maximum depth of red leftmost vertices changes from i to i+1 in probability 2^(i+1), because the token needs to go left i+1 times consecutively.\n\nBecause of j<i, we can calculate all values of q(j,i) up to N tokens in O(N^2) time complexity. After this, with cumulative sum technique, we can calculate p(j,i) in O(N^2) time complexity.\n\nSo, the expected contribution to expected value in when the leftmost vertex of depth i will turn red in exactly j-th token, is, p(j,i) * E*((X+1) * (N-X-1)) when X=B(N-j-1,2^-i). Note that, here Ri (in part #1) changed to 2^-1,, because the probability which the leftmost vertex of depth is equal to the probability that the token goes left i times consecutively.\n\nNow, let’s calculate E*((X+1) * (N-X-1)). If you define Y= X+1 = X=B(N-j-1,2^-i) +1 , you now have to calculate E(Y*(N-Y)). Here, E(Y)= (N-j-1) *2^-i +1, and V(Y)= (N-j-1) * 2^-i*(1-2^-i) - then we can calculate E(Y^2)=(E(Y^2)= (E(Y))^2 + V (Y) \n\nAnd we can then calculate E(Y*(N-Y) = N*E(Y) - E(Y^2). That’s all - now we only have to calculate the sum of  p(j,i)* E(Y*(N-Y))* 2î (note that there are 2î vertices of depth i and their contributions to expected total distances are equal by symmetry). And it’s the answer.\n\n__Total Time Complexity:O(N^2)__\n\n```\n#ifndef CLASS_MODINT\n#define CLASS_MODINT\n#include <cstdint\n\ntemplate<std::uint32_t mod\n\nclass modint {\nprivate:\nstd::uint32_t n;\npublic:\nmodint() : n(0) {};\nmodint(std::int64_t n_) : n((n_ = 0 ? n_ : mod - (-n_) % mod) % mod) {};\nstd::uint32_t get() const { return n; }\nbool operator==(const modint& m) const { return n == m.n; }\nbool operator!=(const modint& m) const { return n != m.n; }\nmodint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }\nmodint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }\nmodint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }\nmodint operator+(const modint& m) const { return modint(*this) += m; }\nmodint operator-(const modint& m) const { return modint(*this) -= m; }\nmodint operator*(const modint& m) const { return modint(*this) *= m; }\nmodint pow(std::uint64_t b) const {\nmodint ans = 1, m = modint(*this);\nwhile (b) {\nif (b & 1) ans *= m;\nm *= m;\nb = 1;\n}\nreturn ans;\n}\nmodint inv() const { return (*this).pow(mod - 2); }\n};\n#endif // CLASS_MODINT\n#include <vector\n\n#include <algorithm\n\nusing namespace std;\nconst int mod = 1000000007;\nusing modulo = modint<mod;\nclass RndSubTree {\nprivate:\nint N;\nvector<modulo pw;\npublic:\nvoid init() {\npw.resize(2 * N + 1);\npw[N] = 1;\nmodulo inv2 = modulo(2).inv();\nfor(int i = 0; i < N; ++i) pw[N + i + 1] = pw[N + i] * 2;\nfor(int i = 0; i < N; ++i) pw[N - i - 1] = pw[N - i] * inv2;\n}\nmodulo pow2(int x) {\n// assuming -N <= x <= N, returns 2^x modulo 10^9+7\nreturn pw[x + N];\n}\nint count(int N_) {\nN = N_;\ninit();\nvector<vector<modulo dp(N + 1, vector<modulo(N, modulo(0)));\ndp[1][0] = 1;\nfor(int i = 2; i <= N; ++i) {\nfor(int j = 0; j < i; ++j) {\ndp[i][j] += dp[i - 1][j] * (modulo(1) - pow2(-(j + 1)));\nif(j = 1) dp[i][j] += dp[i - 1][j - 1] * pow2(-j);\n}\n}\nfor(int i = 1; i <= N; ++i) {\nfor(int j = i - 2; j = 0; --j) {\ndp[i][j] += dp[i][j + 1];\n}\n}\nmodulo ans = 0;\nfor(int i = 1; i <= N; ++i) {\nfor(int j = 1; j < i; ++j) {\nmodulo prob = pow2(-j);\nmodulo ex = prob * (N - i) + modulo(1);\nmodulo var = prob * (modulo(1) - prob) * (N - i);\nmodulo ex_square = var + ex * ex;\nmodulo ex_contrib = modulo(N) * ex - ex_square; // expectation of x*(N-x)\nans += ex_contrib * (dp[i][j] - dp[i - 1][j]) * pow2(j);\n}\n}\nreturn ans.get();\n}\n};\n```\n\n## Division 1 Hard - SquadConstructor2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14860)\n\n__Slow DP Solution__\n\nBrute-forcing all possibilities is really difficult. There are C(256,8) 4.0966 * 10^14 which takes days or even years to calculate the optimal answer. This may cause things like this.\n\nThis problem can be solved by dynamic programming efficiently than brute-force. Let dp[i][j][seq] (seq= seq0, seq1,......seqN-1)) the possibility (in boolean value) of “choosing j players from friends 0 through i-1, and the current number of players which can play strategy k is seqk”.\n\nLet the number of friends S. The number of combinations of (i,j,seq) is at most S * (K+1) *(K+ 1)^N= S* (K+1)^N+1. And there are two ways to move from (i,j,seq): to choose friend i, or not. The calculation of new seq  takes O(N) time, so the total time complexity of this DP is O(S*N* (K+1)^N+1).\n\nLet’s assign S=256, N=8, K=8 for maximum case… and S* N * (K+1)^N+1 will be about 7.9344* 10^11, which is far better than brute-force solution!\n\n__Fast DP Optimization with “bitset”__\n\nLet’s optimize this DP with bitset! We can think that bitset is a boolean array of fixed length s. We can see this as an s-digit binary number, and we can calculate bitwise-AND, bitwise-OR, bitwise-XOR, and bitwise-shift. It is very fast because it is splitted each (usually) 64 digits and processed by integer array, plus bitwise operations. So, let’s assume that it is 64-times fast than naive calculation.\n\nActually, this DP can be calculated by bitset! But, how to use? Here are two tips to use bitset by transforming seq to an integer.\n\nLet h=seq0 * (K+1)^0 + seq1 *(K+1)^1+...+ seqN-1* (K+1)^N-1.\n\nIf we add friend i, then the new h will become h+d, when d is the sum of (K+1)^x for all x that friend can use strategy x.\n\nSo this will become a variant of the well-known “partial sum problem”. Partial sum problem is that “we choose some elements from a1,a2,...an, then, judge if it is possible to choose elements that sum will be exactly k^n.The partial sum problem can be solved by bitset like following.\f\n\n```\nbitset<1000007 bs;\nbs[0] = 1;\nfor(int i = 0; i < n; ++i) {\nbs = bs << a[i];\n}\nreturn (bs[k] ? “Possible” : “Impossible”;\n```\n\nAnd the time complexity will be, O(nk) times 1/64. We can similarly do the DP with bitset, and the time complexity will be O(S* (K+1)^N+1) times 1/64. In this problem, the maximum case will be S=256, K=8, N=8, and S* (K+1)^N+1/ 64 will be about 1.5497* 10^9. Actually, this is slightly tight for the execution time limit 3 seconds.\n\nWe now eliminate the unnecessary elements. Let Ti the set of ability friend i can use. If there are more than K occurrences that Ti Tj (Note: i-j is possible), the friend i will never be in the squad. The maximum case I can consider is that “N=8 and all cases of |Ti|=3 or 4”, which no element will be eliminated. In this case,S= C(8,3) + C(8,4)= 56+70= 126, which halves the execution time.\n\nMy following source code passed all test cases in less than 2.5 seconds. I think solving this problem in this way using Java, C#, Python, VB will be difficult, and that’s one of the reason why most people are using C++ in competitive programming.\n\n```\n#include <bitset\n\n#include <vector\n\n#include <algorithm\n\nusing namespace std;\nbitset<43046721 dp[9];\nint digit[11];\nclass SquadConstructor2 {\npublic:\nint teamget(int N, int K, vector<int A) {\nvector<int fixedA;\nfor(int i = 0; i < A.size(); ++i) {\nint excel = 0;\nfor(int j = 0; j < A.size(); ++j) {\nif((A[i] | A[j]) == A[j]) ++excel;\n}\nif(excel <= K) {\nfixedA.push_back(A[i]);\n}\n}\nA = fixedA;\ndp[0][0] = 1;\nfor(int i = 0; i < A.size(); ++i) {\nint mul = 1, sum = 0;\nfor(int j = 0; j < N; ++j) {\nif((A[i] j) & 1) {\nsum += mul;\n}\nmul *= K + 1;\n}\nfor(int j = K - 1; j = 0; --j) {\ndp[j + 1] |= dp[j] << sum;\n}\n}\nint cnt = 0, ans = 0;\nwhile(digit[N] != 1) {\nif(dp[K][cnt++]) {\nint sum = 0;\nfor(int i = 0; i < N; ++i) {\nsum += digit[i] * digit[i];\n}\nans = max(ans, sum);\n}\n++digit[0];\nint pos = 0;\nwhile(digit[pos] == K + 1) {\ndigit[pos] = 0;\n++digit[++pos];\n}\n}\nreturn ans;\n}\n};\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7L8jqW1gCl6glwSnV8LKTN","type":"Entry","createdAt":"2020-04-20T12:42:14.078Z","updatedAt":"2020-04-20T12:42:14.078Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"square1001","tcHandle":"square1001"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-731-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"21U43wxi3qFfdQqZNEZtzz","type":"Entry","createdAt":"2020-04-20T12:41:37.382Z","updatedAt":"2026-03-01T23:41:05.615Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":42,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 733","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2018-04-14T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 733 Editorials\n\nThe author of this round is [ltdtl](https://www.topcoder.com/members/ltdtl).\n\n## Div II Easy::MinimizeAbsoluteDifferenceDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14884)\n\nIn this problem, we have an expression with three integers a,b,c and we want to arrange them to minimize the value of |?/? - ?|. This is an easier version of the div1 easy.\nThis is mainly an implementation problem. We can try all 3! = 6 permutations take the one that results in the minimum value. The time complexity is O(n! * n) where n = 3 in this problem.\n[cpp]\n```\n#include<bits/stdc++.h>\nusing namespace std;\nstruct MinimizeAbsoluteDifferenceDiv2{\nvector <int> findTriple(int x0, int x1, int x2) {\nint x[3]={x0,x1,x2};\nint p[3]={0,1,2};\nfor(int i=0;i<3;i++)assert(x[i]>=1 && x[i] <=10000);\nvector <int> an(3);\ndouble mi=1e18;\ndo{\ndouble v=fabs(x[p[0]]*1./x[p[1]]-x[p[2]]);\nif(v<mi){\nmi=v;\nan=vector <int> (p,p+3);\n}\n}while(next_permutation(p,p+3));\nreturn an;\n}\n};\n[/cpp]\n```\n\n## Div II Medium::BulidingSpanningTreeDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14888)\n\nIn this problem, we are given a complete graph with n nodes, and n-3 “special” edges. We need count the number of spanning trees that contain all of these edges. This is an easier version of the div1 medium.\n\nFirst, if there are any cycles in E, then the answer is zero, since a spanning tree can’t have a cycle.\n\nThe actual topology of E doesn't matter, what matters is the sizes of the connected components it forms. In addition, since E has n-3 edges and no cycles, there will be exactly 3 components left over.\n\nLet the sizes of these components be s_0, s_1, s_2.\nTo form a spanning tree, we must add two more edges. There are three possible edges we can add, of which we need to choose exactly two of them.\n1) We add an edge between s_0, s_1. This can be done in s_0*s_1 ways. (A)\n2) We add an edge between s_0, s_2. This can be done in s_0*s_2 ways. (B)\n3) We add an edge between s_1, s_2. This can be done in s_1*s_2 ways. (C)\n\nThus, the final answer is the sum of products of choosing two of the edges, which is A*B + A*C + B*C = (s_0*s_1) * (s_0*s_2) + (s_0*s_1) * (s_1*s_2) + (s_0*s_2) * (s_1*s_2).\n\nThe time it takes to find the sizes of the components is similar to using Kruskal’s and union find which takes O(n * \\alpha(n)), where \\alpha(n) is the inverse ackermann function.\nDon't forget about the modulo.\n\n__C++ code:__\n[cpp]\n\n```\n#include<bits/stdc++.h>\n#define SZ(X) (int)((X).size())\nusing namespace std;\nconst int SIZE = 1024;\nconst int MOD = 987654323;\nint d[SIZE],num[SIZE];\nvoid uu(int x,int y) {\nwhile(x != d[x]) x = d[x];\nwhile(y != d[y]) y = d[y];\nif(x == y) return;\nd[x] = d[y];\nnum[y] += num[x];\n}\nstruct BuildingSpanningTreesDiv2{\nint getNumberOfSpanningTrees(int n, vector <int> x, vector <int> y){\nassert(4 <= n && n <= 1000);\nint m = n - 3;\nassert(SZ(x) == m && SZ(y) == m);\nfor(int i = 1; i <= n; i++) {\nd[i] = i;\nnum[i] = 1;\n}\nfor(int i = 0; i < m; i++) {\nassert(1 <= x[i] && x[i] < y[i] && y[i] <= n);\nuu(x[i], y[i]);\n}\nvector<long long> gg;\nfor(int i = 1; i <= n; i++) {\nif(d[i] == i) gg.push_back(num[i]);\n}\nif(SZ(gg) != 3) return 0;\nreturn (gg[0] * gg[1] * gg[1] * gg[2] +\ngg[0] * gg[2] * gg[2] * gg[1] +\ngg[1] * gg[0] * gg[0] * gg[2]) % MOD;\n}\n};\n```\n[/cpp]\n\n## Div II Hard::HamiltonianPathsInGraph\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14881)\n\nThis is a classic problem where we want to find a hamiltonian path in a tournament graph. There may already exist some resources online about it (see this link for example: https://math.stackexchange.com/questions/1682492/prove-that-every-tournament-contains-at-least-one-hamiltonian-path). This is an easier version of the div1 hard.\n\nWe will prove an answer always exists by constructing one. We do this by induction.\nFirst, our base case is when n=1, which is just a path with a single node.\n\nNow, consider an arbitrary n > 1, and suppose we have constructed a hamiltonian path of the vertices {0,1,2,..,n-2} and we want to add vertex n-1.\n\nFor each node {0,1,2,...,n-2}, color node i red if there is an edge from i to n-1, otherwise color node i blue if there is an edge from n-1 to i.\n\nSuppose the hamiltonian path on {0,1,2,..,n-2} is p_0, p_1, ..., p_{n-2}.\nIf p_0 is blue, we can append node n-1 to the beginning. If p_{n-2} is red, then we can append node n-1 to the end. So, now let's consider the harder case when p_0 is red and p_{n-2} is blue.\nWe want to find p_i and p_{i+1} such that p_i is red and p_{i+1} is blue.\nThis must exist, since the first node in our path is red, and the last node is blue, so at some point, it must switch from red to blue, at which point we can insert n.\nThus, this shows that we can always extend the hamiltonian path by 1, which completes our induction and gives us an algorithm.\n\nTo implement this, we can follow the steps in our induction above. There are n times where we add nodes, and each of those steps takes O(n) time (O(n) to classify the previous nodes as red or blue, and O(n) time to insert our new node into this list).\n\n__Java Code__\n[java]\n```\nimport java.util.Set;\nimport java.util.HashSet;\npublic\nclass HamiltonianPathsInGraph {\npublic int[] findPath(String[] X) {\nint n = X.length;\nint[] left = new int[128], right = new int[128];\nint start, end;\nint ans[] = new int[n];\nstart = end = 0;\nleft[0] = right[0] = -1;\nfor(int i = 1; i < n; i++) { if(X[i].charAt(start) == '+') { // i->start\nleft[start] = i;\nright[i] = start;\nleft[i] = -1;\nstart = i;\ncontinue;\n}\nif(X[end].charAt(i) == '+') { // end -> i\nright[end] = i;\nleft[i] = end;\nright[i] = -1;\nend = i;\ncontinue;\n}\n// start->i && i->end\nint j = start;\nwhile(X[j].charAt(i) == '+') j = right[j];\n// X[left[j]][i] = '+' & X[i][j] = '+';\nint k = left[j];\nright[k] = i; left[i] = k;\nleft[j] = i; right[i] = j;\n}\nint x = start, idx = 0;\nwhile(x != -1) {\nans[idx] = x;\nidx++;\nx = right[x];\n}\nreturn ans;\n}\n}\n```\n[/java]\n\n## Div I Easy::MinimizeAbsoluteDifferenceDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14883)\n\nIn this problem, you are given five variables a,b,c,d,e and you want to put four of them in the expression |?/? - ?/?| so the resulting value is minimized. This is a harder version of the div2 easy.\n\nThis is an implementation problem. Here, we can try all 5! permutations of replacement, and take the minimum possible value. The time complexity is O(n! * n) where n = 5.\n\n__Java Code:__\n[java]\n```\nclass MinimizeAbsoluteDifferenceDiv1 {\npublic int[] findTuple(int[] x) {\nint[] ans = new int[4];\nlong ans1 = 0, ans2 = 0;\nfor(int i = 0; i < 5; i++) {\nfor(int j = 0; j < 5; j++) {\nif(i == j)continue;\nfor(int k = 0; k < 5 ; k++) {\nif(k == i || k == j) continue;\nfor(int l = 0; l < 5; l++) {\nif(l == i || l == j || l == k) continue;\nlong a = x[i], b = x[j], c = x[k], d = x[l];\nlong f1 = (a*d - c*b), f2 = b*d;\nif(f1 < 0) f1 = -f1;\nif(ans2 == 0 || (ans1*f2 > f1*ans2)) {\nans1 = f1;\nans2 = f2;\nans[0] = i;\nans[1] = j;\nans[2] = k;\nans[3] = l;\n}\n}\n}\n}\n}\nreturn ans;\n}\npublic String checkData(int[] x) {\nif(x == null || x.length != 5)\nreturn \"x must contain exactly five elements.\";\nfor(int i = 0; i < x.length; i++) {\nif(x[i] < 1 || x[i] > 10000) {\nreturn String.format(\"Element \" + i + \" of x must be between 1 and 10,000, inclusive.\");\n}\n}\nreturn \"\";\n}\n```\n[/java]\n\n## Div I Medium::BuildingSpanningTreeDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14880)\n\nIn this problem, you are given a complete graph with n nodes, and some special edges. We want to count the number of spanning trees that contain all of these edges. This is a harder version of the div2 medium.\n\nThis is a classic problem (a similar problem can be found here: \n[http://codeforces.com/problemset/problem/156/D](http://codeforces.com/problemset/problem/156/D)). An editorial (only in russian) can be found here: http://codeforces.com/blog/entry/4005?locale=en, which I’ll briefly summarize. The first few steps are similar as in the div2 solution.\nNamely, if there are any cycles in E, the answer is zero.\n\nOtherwise, the actual topology of E doesn't matter, what matters is the size of each connected component.\n\nLet these sizes be s_0, s_1, ..., s_{k-1}. The answer is (n)^(k - 2) * s_0 * s_1 * … * s_{k-1}.\nThe proof can be seen as a generalization of Caley’s formula on the number of trees with n nodes. You can also see this math stack exchange link for some more information: https://math.stackexchange.com/questions/2550064/proof-of-generalized-cayleys-formula\nThe complexity analysis is similar to div2 medium, where the time is dominated by needing to find the sizes of the components, which is O(n * \\alpha(n)), where \\alpha(n) is the inverse ackermann function.\n\n__C++ code:__\n[cpp]\n```\n#include<bits/stdc++.h>\n#define SZ(X) (int)((X).size())\nusing namespace std;\nconst int SIZE = 1024;\nconst int MOD = 987654323;\nint d[SIZE],num[SIZE];\nbool uu(int x,int y) {\nwhile(x != d[x]) x = d[x];\nwhile(y != d[y]) y = d[y];\nif(x == y) return 0;\nd[x] = d[y];\nnum[y] += num[x];\nreturn 1;\n}\nstruct BuildingSpanningTreesDiv1{\nint getNumberOfSpanningTrees(int n, vector <int> x, vector <int> y){\nassert(1 <= n && n <= 1000);\nint m = SZ(x);\nassert(SZ(y) == m);\nfor(int i = 1; i <= n; i++) {\nd[i] = i;\nnum[i] = 1;\n}\nset<pair<int,int>>H;\nfor(int i = 0; i < m; i++) {\nassert(1 <= x[i] && x[i] < y[i] && y[i] <= n);\nassert(H.count(make_pair(x[i], y[i])) == 0);\nif(!uu(x[i], y[i])) return 0;\nH.insert(make_pair(x[i], y[i]));\n}\nvector<long long> gg;\nlong long ans = 1;\nint cnt = 0;\nfor(int i = 1; i <= n; i++) {\nif(d[i] == i) {\ngg.push_back(num[i]);\ncnt ++;\nans = ans * num[i] % MOD;\n}\n}\nif(SZ(gg) == 1) return 1;\nfor(int i = 0; i < SZ(gg) - 2; i++) {\nans = ans * n % MOD;\n}\nreturn ans;\n}\n};\n```\n[/cpp]\n\n## Div I Hard::HamiltonianCircuits\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14882)\n\nThis is also a somewhat classic problem where we want to find a hamiltonian circuit in a tournament graph. There may already exist some resources online about it (see this link for example: https://math.stackexchange.com/questions/1682492/prove-that-every-tournament-contains-at-least-one-hamiltonian-path). This is an harder version of the div2 hard.\nAnother approach is as follows.\nLet’s add the nodes in one by one. We will proceed by induction.\n\nAfter each step, instead of maintaining a hamiltonian circuit, we will have a list of hamiltonian circuits for each strongly connected components of the nodes 0,1,2,...,i-1. In addition, since this is a tournament graph, the SCCs from a line from left to right, with all SCC edges in the left pointing to the right.\n\nNow, to add node i, we will find the leftmost SCC that i has an edge to and the rightmost SCC that i has an edge to. Call these SCCs indices A and B respectively.\nIf A > B, then that means we need to insert a new SCC with only node i in between A and B.\nIf A == B, then that means we need to insert node i into SCC A, we can brute force where to insert i (there must exist such an insertion point because there is an edge to and from i in this component).\n\nIf A < B, then we can merge all components from A to B, and also merge their cycles together (we use node i to connect B -> i -> A to make a big cycle). Since we already have cycles in each component, we can rotate each one so that the appropriate node is at the beginning/end.\nAt the end, if there is only one SCC, we can return the cycle of that component, otherwise, return the empty list.\nOne step takes O(n) time, so the overall runtime is O(n^2).\n\n__Python Code:__\n[python]\n```\nclass HamiltonianCircuits():\ndef findCircuit(self, n, seed, a, b, c, d, e):\nvalue = seed\nconn = [[False for j in range(n)] for i in range(n)]\nfor i in range(n):\nfor j in range(i+1, n):\nif value % 1000 <= 250:\nconn[i][j] = True\nconn[j][i] = False\nelse:\nconn[j][i] = True\nconn[i][j] = False\nvalue = (a * value + b) % c\nfor x,y in zip(d,e):\nconn[x][y] = True\nconn[y][x] = False\ncycles = []\nfor add in range(n):\ng1 = -1\ng2 = len(cycles)\nfor ci in range(len(cycles)):\nif any(conn[i][add] for i in cycles[ci]):\ng1 = max(g1, ci)\nif any(conn[add][i] for i in cycles[ci]):\ng2 = min(g2, ci)\nif g1 < g2:\ncycles = cycles[:g2] + [[add]] + cycles[g2:]\ncontinue\nif g1 == g2:\nfor i in range(len(cycles[g1])):\nif conn[cycles[g1][i-1]][add] and conn[add][cycles[g1][i]]:\ncycles[g1] = cycles[g1][:i] + [add] + cycles[g1][i:]\nbreak\ncontinue\na1 = next(i for i in range(len(cycles[g1])) if conn[cycles[g1][i]][add])\na2 = next(i for i in range(len(cycles[g2])) if conn[add][cycles[g2][i]])\npref = cycles[:g2]\nsuff = cycles[g1+1:]\ncycles[g1] = cycles[g1][a1+1:] + cycles[g1][:a1+1]\ncycles[g2] = cycles[g2][a2:] + cycles[g2][:a2]\nmid = []\nfor i in range(g2,g1+1):\nmid.extend(cycles[i])\nmid.append(add)\ncycles = pref + [mid] + suff\nif len(cycles) != 1:\nreturn []\nreturn cycles[0]\n```\n[/python]","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-733-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"x62doCxcQmo96B3lJWiqq","type":"Entry","createdAt":"2020-04-20T12:41:37.420Z","updatedAt":"2026-03-01T23:10:37.685Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 734","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2018-05-18T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 734 Editorials\n\nThe author of this round and editorial is [Vasyl[alphacom]](https://www.topcoder.com/members/Vasyl[alphacom]). The round was held on 16th May 21:00 UTC-4.\n\n## Div 2 Easy - TheRoundCityDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14898)\n\nIn this problem we have to count lattice points on a plane that are at most r units far from the origin.\n\nObviously we count only points which both coordinates do not exceed r by an absolute value.\nSince r is at most 100, we can simply iterate over all lattice points (x, y) where -r <= x, y <= r and count such that x^2 + y^2 <= r^2.\nThe time complexity is O(r^2).\n\n## Div 2 Hard - TheRectangularCityDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14902)\n\nIn this problem you are given a matrix of 0s and 1s.\nYou have to count the number of paths which\n* start at any border cell\n* visit all matrix 0s and no matrix 1s\n* end at any border cell\nSince there are at most 20 matrix cells the problem can be solved using a dynamic programming approach.\n\nWe'll have states with two dimensions:\n* mask - the cell binary mask representing a visited cell set\n* last - the last visited cell\n\nThe state value is the number of ways to visit all the cells represented by the mask and finish in cell last.\nThe transitions between the states can be done by iterating over all neighbours of the last cell.\n\n## Div 1 Easy - TheRoundCityDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14897)\n\nIn this problem we have to count lattice points on a plane that are at most r units far from the origin and are visible from the origin.\n\nA lattice point is visible from the origin if a line segment connecting the point and the origin contains no other lattice points.\nNotice that we can first count only visible lattice points (x, y) such that x > 0 and y >= 0 and then multiply the result by 4.\n\nIt's easy to see that for each visible form the origin lattice point (x, y) gcd(x, y) = 1.\nHere gcd is the greatest common divisor and we assume (x, y) is not at the origin.\nLet's iterate over all x coordinates from 1 to r, inclusive.\n\nThen we find the maximal possible value of y coordinate maxY = floor(sqrt(r^2 - x^2)).\nNow we have to count coprime with x numbers in range [0, maxY].\n\nThis can be done by using inclusion–exclusion principle over all distinct prime divisors of x.\nThe time complexity linearly depends on the total number of prime divisors of integers from 1 to r which is O(r*log(r)).\n\n## Div 1 Medium - TheSquareCityDiv1\n\nThis is a harder version of Div 2 problem TheSquareCityDiv2.\nIn this problem first you have to construct a matrix of integers.\n\nThen for each cell X we find several values:\n1) next(X) - a next cell Y with the maximal value such that a Manhattan distance between X and Y is at most r.\nIf there are multiple such cells you choose the one with the smallest row and then the one with the smallest column.\nIf next(X)=X we call cell X a terminal cell.\n2) d(X) - a destination cell which can be found using the following rules:\n* let d(X) = X;\n* while d(X) is not a terminal cell d(X) = next(d(X)).\n3) cnt(X) - a number of cells Y such that d(Y) = X.\n\nFinally, we have to find the number of cells X such that cnt(X) > 0 and a maximal value of cnt(X) over all cells.\nLet's construct n(X, R) in the same way as next(X) but instead of r we'll use variable R.\nThen next(X) = n(X, r).\n\nIt's easy to see that for each cell X n(X, 0) = X.\nLet X1, X2, X3, X4 are direct neighbours of X, then\nn(X, R+1) = max(n(X1, R), n(X2, R), n(X3, R), n(X4, R)).\n\nThus we can find all values next(X) in O(r * n^2) time.\nNow we have a directed acyclic graph defined by next(X).\nWe can simply find the required values by traversing the graph using dfs or bfs in O(n^2) time.\nThe overall complexity is O(r*n^2)).\n\n## Div 1 Hard - TheRectangularCityDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14901)\n\nThis is a harder version of Div 2 problem TheRectangularCityDiv2.\n\nIn this problem you are given a matrix of 0s and 1s.\nYou have to count the number of paths which\n* start at any border cell\n* visit all matrix 0s and no matrix 1s\n* end at any border cell\n\nThe problem can be solved by dynamic programming with profile.\nThe profile will consist of n or m (which one is smaller) cells.\nCells on one side of the profile have already been visited and they form several (possibly none) partial paths which may connect to each other and should later form a single final path we are looking for.\n\nThe profile configuration describes the way partial paths relate to the profile cells.\nNote that we can have up to 5 partial paths in a profile.\n\nThe state will have a few dimensions:\n* the current cell\n* the profile configuration\n* the number of opened connections (partial path ends) of the current cell (from 0 to 2)\n* the number of the final path ends (from 0 to 2)\n\nThe value is the number of ways to get the given configuration.\nThe transitions between states can be done by iterating over all possible ways how the next cell connects to its neighbours from the current profile (up to 2). Note that the next cell can also be one of the final path ends.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-734-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4jUKEpAXnaL9nfkJAjsqPb","type":"Entry","createdAt":"2020-04-20T12:41:38.549Z","updatedAt":"2026-03-01T23:03:26.991Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":44,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 735","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2018-06-26T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 735 Editorials\n\nIn lieu of the tragic passing of [ltaravilse](https://profiles.topcoder.com/ltaravilse), we ran SRM 735 and TCO18 Round 2C on Tuesday, June 26, 2018 in his honor. \n\n## Div2 Easy: BinaryCalculator\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14930)\n\nIn this problem, you are given a very simple calculator displaying a number. That number can be increased by 3 or decreased by 2 at the press of a button. The goal is to turn a into b using the smallest possible number of button presses.\n\nThere are many possible approaches including a closed form solution, but we outline one that is very simple to code and prove, and thanks to the constraints it is fast enough.\n\nNote that if the current number is larger than b, we need to press the button -2 at least once. Since the operations are commutative, performing this operation right away cannot make matters worse than optimum. Similarly, if the current number is smaller than b, we can press +3 right away. This process can thus be simulated as follows:\n\n```\nclass BinaryCalculator {\npublic:\nint minimumSteps(int a, int b) {\nint ans = 0;\nwhile (a != b) {\nif (a > b) a -= 2;\nelse a += 3;\nans++;\n}\nreturn ans;\n}\n}\n```\n\nThe complexity of this approach is O(|a-b|).\n\n## Div2 Medium: Teleportation Maze\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14946)\n\nIn this task we have a grid representing a maze. There are two types of moves - a quick step towards any of the 4 adjacent cells costing 1 second, or a teleport to the closest empty cell in any of the 4 directions costing 2 seconds. The goal is to find a shortest route from A to B.\nThe limits are small, so one can afford to use any shortest path algorithm, e.g. Dijkstra, to solve it. We present a solution that is faster by a logarithmic factor and is based on BFS. In one BFS iteration, we normally have an array A of vertices to which the distance is d, and use it to construct an array B of vertices at distance d+1. For graphs with unweighted edges, this approach is sufficient. In our problem, we have edges with two different weights: 1 and 2. We can thus modify the BFS to build two arrays at the same time - apart from B already mentioned we construct C containing vertices at distance d+2.\nThe code in C++ is below:\n\n```\nclass TeleportationMaze {\npublic:\nint pathLength(vector a, int r1, int c1, int r2, int c2) {\nint H = a.size();\nint W = a[0].size();\nvector<vector> D(H, vector(W, -1));\nD[r1][c1] = 0;\nvector<pair<int,int>> Aundefined, B, C;\nint time = 0;\nauto checkEdge = [&](int r, int c, int dr, int dc) {\nint nr = r+dr, nc = c+dc;\nwhile (nr >= 0 && nr < H && nc >= 0 && nc < W && a[nr][nc] == '#') { nr += dr; nc += dc; } if (nr >= 0 && nr < H && nc >= 0 && nc < W) { if (nr == r + dr && nc == c + dc) { if (D[nr][nc] > time + 1) {\nD[nr][nc] = time + 1;\nB.push_back({nr,nc});\n}\n} else {\nif (D[nr][nc] > time + 2) {\nD[nr][nc] = time + 2;\nC.push_back({nr,nc});\n}\n}\n}\n};\nwhile (!A.empty() || !B.empty()) {\nfor (auto &p: A) {\nint r = p.first, c = p.second;\ncheckEdge(r, c, 1, 0);\ncheckEdge(r, c, -1, 0);\ncheckEdge(r, c, 0, 1);\ncheckEdge(r, c, 0, -1);\n}\nswap(A,B);\nswap(B,C);\nC.clear();\ntime++;\n}\nreturn D[r2][c2];\n}\n};\n```\n\nThe solution works in O(H W), where H is the number of rows and W is the number of columns.\nSlower solutions, such as ones running in O(H2 W2), could also get accepted.\n\n## Div2 Hard, TCO 2C Medium: MajoritySubarray\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14932)\n\nIn this problem we are given an array a of integers. We are asked to find the number of contiguous subarrays in which there is a number that with more occurrences than half the length of the subarray.\n\nAs the number of possible values in a is rather small (at most 50), we can count the answer separately for every possible value. In other words, for a fixed x, we are asking about the number of subarrays in which x is a majority.\n\nThis is much easier to approach. We process the array from left to right and maintain a current balance, initially b[0] = 0. If a[i] = x, the balance increases by 1, otherwise it is decreased by 1 (i.e. b[i] = b[i-1] ± 1). How do we now count the number of subarrays that end at index i and have x as majority? We can see that this is equal to the number of indices j < i for which b[j] < b[i] - as this means that there are strictly more x’s than non-x’s in the subarray [j,i). This is a very similar problem to counting the number of inversions in an array, and we can use a segment or Fenwick tree to do this fast. Below is a sample implementation in C++.\n\n```\nclass MajoritySubarray {\nvector F;\nint fenwick_sum(int i) const {\nint s = 0;\nwhile (i > 0) { s += F[i]; i -= i & -i; }\nreturn s;\n}\nvoid fenwick_add(int i, int k) {\nwhile (i < (1<<18)) { F[i] += k; i += i & -i; }\n}\npublic:\nll getCount(int N, int seed, int modulo) {\nvector a(N);\nfor (int i = 0; i < N; ++i) { a[i] = (seed>>16) % modulo;\nseed = (seed * 1103515245 + 12345) & 0x7fffffff;\n}\nF.resize(1<<18);\nll ans = 0LL;\nfor (int x = 0; x < modulo; ++x) {\nfill(F.begin(),F.end(),0);\nint bal = N;\nfor (int i = 0; i < N; ++i) {\nfenwick_add(bal, 1);\nif (a[i] == x) ++bal; else --bal;\nans += fenwick_sum(bal-1);\n}\n}\nreturn ans;\n}\n};\n```\n\nNote that for the ease of implementation, the balance in the code starts at N and not from zero as previously mentioned. This is because the Fenwick tree implementation of our choice only accepts non-negative indices. Since we are only ever comparing these balances to each other, this does not change the answer.\nThe complexity of this approach is clearly O(m n log n).\nBonus: Can you do it in O(n log n)?\n\n## Div1 Easy, TCO 2C Easy: PalindromeSubsequence\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14925)\n\nWe are given a string of length at most 50 characters from an alphabet of size 2. We want to partition the string into some subsequences (not necessarily contiguous) such that each such subsequence is a palindrome. Furthermore, we want to use the fewest subsequences possible.\nThis task may look quite intimidating at first. Indeed, for an alphabet had size 3, author is not aware of any polynomial solution. Luckily, we can abuse the fact that there are only two different letters.\n\nIf the string is already palindrome, there is not much left to do. Otherwise, we simply pick all occurrences of ‘a’ as the first string, and all occurrences of ‘b’ as the second. Below is a sample implementation in C++.\n\n```\nclass PalindromeSubsequence {\nbool isPalindrome(string s) const {\nfor (int i = 0; i < s.size()/2; ++i) {\nif (s[i] != s[s.size()-1-i]) return false;\n}\nreturn true;\n}\npublic:\nvector optimalPartition(string s) {\nint N = s.size();\nvector x(N, 1);\nif (!isPalindrome(s)) {\nfor (int j = 0; j < N; ++j) {\nx[j] += s[j] == 'b';\n}\n}\nreturn x;\n}\n};\n```\n\nThe complexity of this approach is O(n), where n is the length of the input.\n\n## Div1 Medium, TCO 2C Hard: QuadraticIdentity\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14924)\n\nWe are given a ring of integers modulo m, and we want to find all a’s from that ring that are invariant to squaring.\n\nAs m is too large, we cannot afford to try all possibilities. Instead, we rewrite a2a (mod m)as a(a-1)=km for some non-negative k. Put differently, it must be true that m divides a(a-1). We can rewrite this fact as a=xcand a-1=yd for some integers x,y and cd=m. Subtracting these two equations we get -xc +yd = 1. This can be solved by Extended Euclidean algorithm. Bézout identity tells us that this has integer solutions for x and y if and only if gcd(c,d) = 1. We can thus run this algorithm for all divisors d of m for which gcd(d,m/d) = 1. In order to find these easily, we can simply factorise to m to prime powers, and then try all possibilities of assigning the factors to c or d. Because of that, that the number of solutions is always a power of 2. As the product of the 14 smallest primes is larger than upper bound on m, there are at most 2^13 solutions.\n\n```\nclass QuadraticIdentity {\nvector factors, answer;\nll M;\nll extended_gcd(ll a, ll b) {\nll s = 0, old_s = 1, t = 1, old_t = 0, r = b, old_r = a;\nwhile (r != 0) {\nll q = old_r / r, z;\nz = old_r; old_r = r; r = z - q * r;\nz = old_s; old_s = s; s = z - q * s;\nz = old_t; old_t = t; t = z - q * t;\n}\nll ans = b*old_t;\nif (ans < 0) ans += M;\nreturn ans;\n}\nvoid generate(ll a, ll b, int i) {\nif (i == factors.size()) {\nanswer.push_back(extended_gcd(a, b));\n} else {\ngenerate(a * factors[i], b, i+1);\ngenerate(a, factors[i] * b, i+1);\n}\n}\nvector getFixedPoints(ll M) {\nthis->M = M;\nll N = M;\nfor (ll i = 2; i*i <= M; ++i) {\nif (N % i == 0) {\nll P = 1;\nwhile (N % i == 0) {\nN /= i;\nP *= i;\n}\nfactors.push_back(P);\n}\n}\nif (N != 1) { factors.push_back(N); }\ngenerate(1, 1, 0);\nsort(answer.begin(),answer.end());\nreturn answer;\n}\n};\n```\n\nThe complexity is O(sqrt(m) + 2^p log m), where p is the number of distinct prime factors of m.\n\n## Div1 Hard: MaxSquare\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14929)\n\nIn this problem, you are given a square matrix, and the goal is to find a square submatrix having the maximum possible sum of elements. The matrix is given in a special format, and it is so big that we cannot even afford to generate it explicitly.\n\nGenerating the vector b from which the matrix A is constructed is a bit of code and carefulness in implementation, but it is something that we can afford. As it will be evident soon, the two-dimensional nature of the problem is a red herring, as there is always an optimal solution perfectly aligned with the main diagonal. We prove that just by manipulating the symbols. Mathematically speaking, we seek the following:\n\nAns = max_{c,x,y} sum_{i=x}^{x+c-1} sum_{j=y}^{y+c-1} b_i + b_j.\nWe can try all possible values of c - the submatrix dimension - and then maximize over all possible c:\nAns = max_c max_{x,y} sum_{i=x}^{x+c-1} sum_{j=y}^{y+c-1} b_i + b_j\nAs b_i does not depend on j, we can take it outside of the inner sum:\nAns = max_c max_{x,y} sum_{i=x}^{x+c-1} (b_i * c + sum_{j=y}^{y+c-1} b_j)\n\nWe can distribute the summation over i and the addition:\nAns = max_c max_{x,y} [ sum_{i=x}^{x+c-1} (b_i * c) + sum_{i=x}^{x+c-1} sum_{j=y}^{y+c} b_j) ]\nSince the latter summand doesn’t depend on i, we can sum it explicitly:\nAns = max_c max_{x,y} [ sum_{i=x}^{x+c-1} (b_i * c) + sum_{j=y}^{y+c-1} (b_j * c) ]\nIt seems that both summands are independent and we can maximise over x and y separately:\nAns = max_c [ max_x sum_{i=x}^{x+c-1} (b_i * c) + max_y sum_{j=y}^{y+c-1} (b_j * c) ]\nThe summands are now equivalent (up to variable names), so their maximiser is the same. Hence:\nAns = 2 max_{c,x} c sum_{i=x}^{x+c-1} b_i\n\nThe sum of b_i can be expressed using prefix sums s, and we can substitute z = x+c:\nAns = 2 max_{x<z} (z-x) (s_z - s_x) Suddenly we have something that we can interpret geometrically in a very straightforward way: we have n+1 points of form (i,s_i), and we seek a maximum area rectangle having two of these points as top-right and bottom-left corners explicitly. How to solve such problems? First we identify the set of all candidates for the bottom-left corner. It is evident that if (a,b) and (c,d) are both candidates, and c>=a and d>=b, then all rectangles using (a,b) are at least as good as those using (c,d), thus (c,d) can be discarded. Using stack, we can find such pruned set of candidates for the bottom-left corner. The same argument with inverted inequality works for the top-right corner.\n\nHaving two sets of points, L and R, we can naively find the maximum area rectangle in O(n^2), but that is of course too slow. The crucial observation is that if the optimal top-right corner for L[i] is R[j], then for all k > j the optimal top-right corner is R[l] where l > j, i.e. the index of the optimal solution is monotone. This can be easily proved by contradiction by drawing a picture and arguing about the sum of areas of rectangles L[i]R[j] and L[k]R[l] versus the sum of L[i]R[l] and L[k]R[j]. This property can be exploited to find the solution in O(n log n) using divide and conquer approach. For details, refer to problem D at http://www.csc.kth.se/~austrin/icpc/finals2017solutions.pdf.\n\nThere is one extra complication though. It may happen that all entries in b are negative. Then the sets L and R are equal, and the above divide-and-conquer solution returns 0 corresponding to an empty matrix. However, the submatrix needs to have size at least 1 (as per the problem statement). In that case, we need to output 2 max b_i instead of zero.\n\nSolution in C++:\n```\nclass MaxSquare {\nvector<pair<int,ll>> L, R;\nvector<pair<int,ll>> normalize(vector<pair<int,ll>> v) {\nvector<pair<int,ll>> ret;\nfor (int i = 0; i < v.size(); i++) { while (ret.size() > 0 && ret[ret.size()-1].second <= v[i].second) {\nret.pop_back();\n}\nret.push_back(v[i]);\n}\nreturn ret;\n}\nvector<pair<int,ll>> invert(vector<pair<int,ll>> v) {\nvector<pair<int,ll>> ret;\nfor (int i = v.size()-1; i >= 0; i--) ret.push_back({-v[i].first, -v[i].second});\nreturn ret;\n}\nll solve(int left, int right, int lo, int hi) {\nint mid = (left+right)/2, bestI = -1;\nll best = -1;\nfor (int i = lo; i < hi; i++) { ll cur = (L[mid].first-R[i].first)*(L[mid].second-R[i].second); if (cur > best) {\nbest = cur;\nbestI = i;\n}\n}\nif (left < mid) {\nbest = max(best, solve(left, mid, lo, bestI+1));\n}\nif (mid+1 < right) {\nbest = max(best, solve(mid+1, right, bestI, hi));\n}\nreturn best;\n}\nvector getB(int n, ull s, int q, int o, vector x, vector y) {\nvector b(n);\nfor (int i = 0; i < n; ++i) { b[i] = (s>>20) % q + o;\ns = (s*25214903917L + 11) & 0x7ffffffffffff;\n}\nfor (int i = 0; i < x.size(); ++i) b[x[i]-1] = y[i];\nreturn b;\n}\npublic:\nll getMaxSum(int n, ll s, int q, int o, vector x, vector y) {\nvector b = getB(n, s, q, o, x, y);\nvector<pair<int,ll>> X;\nll tot = 0;\nX.push_back({0,0LL});\nfor (int i = 0; i < n; ++i) {\ntot += b[i];\nX.push_back({i+1, tot});\n}\nL = invert(normalize(invert(X)));\nR = normalize(X);\nll ans = 2*solve(0, L.size(), 0, R.size());\nif (ans == 0) {\nans = b[0];\nfor (int i = 0; i < n; ++i) {\nans = max(ans, (ll)b[i]);\n}\nans *= 2;\n}\nreturn ans;\n}\n};\n```\n\nWe thought we were looking for the largest square, while in reality, the goal was to find the largest rectangle! The total time complexity is O(n log n).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6gHA1WnDWUuz1ZtHAncxg3","type":"Entry","createdAt":"2020-04-20T12:42:14.533Z","updatedAt":"2020-04-20T12:42:14.533Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"majk","tcHandle":"majk"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-735-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5gCnY7ZYi1K6gR7dtgCol6","type":"Entry","createdAt":"2020-04-20T12:41:38.897Z","updatedAt":"2026-03-01T22:49:18.890Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":34,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 736","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2018-08-16T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 736 Editorials\n\n## Div2 Easy: A0Paper\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15005)\n\nIn this task, there are many possible solutions. One of them simply greedily combines as many A(i+1) papers into A(i) as possible, for i decreasing. If there are any A0 papers after the process, the answer is clearly “Possible”, otherwise it is “Impossible”. This solution runs in O(n).\n\n```\nclass A0Paper {\nstring canBuild(vector<int> a) {\nfor (int i = a.size()-1; i > 0; --i) a[i-1] += a[i]/2;\nreturn a[0] ? \"Possible\" : \"Impossible\";\n}\n}\n```\n\nAnother possibility is to sum the areas of the papers in stock (multiplied by 2^20, so they are integers instead of doubles). If the total area is at least 1 square meter, it is always possible to build an A0. Keep in mind that 32-bit integers might overflow using this approach.\n\n## Div2 Medium: Reroll\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15004)\n\nThe limits are small enough so that we can try all possible subsets. For each subset, we can calculate the range of values the reroll can produce as the sum of ranges of all individual dice. For a die that is left as is, the range is [a_i, a_i], and for a rerolled die it is [1,6]. If target is inside this range, then it is achievable. This solution works in O(n * 2^n).\nThere is in fact a greedy solution. Without loss of generality let target be larger than the current sum. While this is the case, remove the smallest die and replace it with a 6. Once the current sum is larger or equal to target, we are done. Similarly, if the target is smaller than the current sum, we replace the dice with the largest roll with ones.\n\n```\nclass A0Paper {\nint minimumDice(int target, vector<int> rolls) {\nint N = rolls.size();\nint total = 0;\nfor (int roll: rolls) total += roll;\nsort(rolls.begin(),rolls.end());\nif (target == total) return 0;\nelse if (target > total) {\nfor (int i = 0; i < N; ++i) {\nif (total += 6 - rolls[i] >= target) return i+1;\n}\n} else {\nfor (int i = 0; i < N; ++i) {\nif (total += 1 - rolls[N-i-1] <= target) return i+1;\n}\n}\n}\n}\n```\n\nThe complexity of this approach is O(n log n) or O(n) if sorting counting sort is used.\n\n## Div2 Hard: MazeWithKeys\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14944)\n\nLet’s try all possible starting points, and for each of them we determine whether the target is reachable.\nIf there were no keys, we could have solved the graph using any graph traversal algorithm, such as DFS. How do keys and doors affect the problem? Let’s break down the cases:\n\nWe reach a key k, but we have not visited the door K yet: remember in a global variable (i.e. bitset) that the key k has been found\n\nWe reach the door K, but we have not found the key k yet: remember in a global variable (i.e. bitset) that the door K has been found and do not traverse the neighbours of this vertex\n\nWe reach the door K and a key k has been found: continue the DFS as normal\n\nWe reach a key k and the door K has already been found: start the DFS from the door K\n\nThis algorithm works as the edges are undirected, and thus if a key k and the door K are both reachable, we can always select a path that first visits the key and then the door, thus unlocking the door. The steps above ensure that the DFS continues from the door vertex only after the appropriate key has been found.\nIf we reach the target point from a given start point, we know that such level would be doable, and we can count all the doable levels. Note that all boring levels are also doable, so we just need to subtract the number of boring levels to get the answer.\nTo count the number of boring levels, we run DFS from the target point, ignoring all doors. All reachable cells represent starting points that would create a boring level.\n\n```\npublic class MazeWithKeys {\nvector<string> a;\nint R, C;\nvector<int> doorR, doorC;\nvector<bool> hasKey, hasDoor;\nvector<vector<bool>> visited;\nbool dfs(int r, int c) {\nif (r < 0 || r >= R || c < 0 || c >= C || visited[r][c]) return false;\nchar w = a[r][c];\nif (w == '#') return false;\nif (w == '*') return true;\nif (w >= 'A' && w <= 'Z') {\nhasDoor[w-'A'] = true;\nif (!hasKey[w-'A']) return false;\n}\nvisited[r][c] = true;\nif (w >= 'a' && w <= 'z') {\nif (!hasKey[w-'a'] && hasDoor[w-'a']) {\nhasKey[w-'a'] = true;\nif (dfs(doorR[w-'a'], doorC[w-'a'])) return true;\n} else {\nhasKey[w-'a'] = true;\n}\n}\nreturn dfs(r+1, c) || dfs(r-1, c) || dfs(r, c-1) || dfs(r, c+1);\n}\nint dfs2(int r, int c) {\nif (r < 0 || r >= R || c < 0 || c >= C || visited[r][c]) return 0;\nchar w = a[r][c];\nif (w >= 'A' && w <= 'Z') return 0;\nif (w == '#') return 0;\nvisited[r][c] = true;\nreturn (w=='.') + dfs2(r+1,c) + dfs2(r-1,c) + dfs2(r,c-1) + dfs2(r,c+1);\n}\nint startingPoints(vector<string> a) {\nthis.a = a;\nR = a.size(); C = a[0].size();\nint ans = 0;\ndoorR = doorC = vector<int>(26);\nvisited = vector<vector<bool>>(R, vector<bool>(C,false));\nhasKey = hasDoor = vector<bool>(26, false);\nfor (int r = 0; r < R; ++r) {\nfor (int c = 0; c < C; ++c) {\nchar w = a[r][c];\nif (w >= 'A' && w <= 'Z') {\ndoorR[w-'A'] = r;\ndoorC[w-'A'] = c;\n} else if (w == '*') {\nans -= reachable(r,c);\n}\n}\n}\nfor (int r = 0; r < R; ++r) {\nfor (int c = 0; c < C; ++c) {\nif (a[r][c] != '.') continue;\nfor (int i = 0; i < 26; ++i) hasKey[i] = hasDoor[i] = false;\nfor (int i = 0; i < R; ++i)\nfor (int j = 0; j < C; ++j) visited[i][j] = false;\nif (dfs(r,c)) ans++;\n}\n}\nreturn ans;\n}\n}\n```\n\nIf we store the locations of all doors in an array so that we don’t have to look for them each time we find a key, simulating one starting point takes O(RC) time, and there are at most O(RC) of them. Hence the total complexity is O(R^2 C^2).\n\n## Div1 Easy: DigitRotation\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14958)\n\nEvaluation of a large integer in modular arithmetic can be done using Horner’s schema in O(N). We can try all possible triples of indices, generate the respective rotated number and sum all evaluations, but that would be too slow. Notice that each rotated number differs from the original number only at most 3 indices. We can thus generate all triples of indices and calculate their difference from the original number. To do that in O(1), we simply need to precompute all powers of 10.\n\n```\nconstexpr int MOD = 998244353;\nclass DigitRotation {\nint sumRotations(string s) {\nint N = s.size();\nvector<Field<998244353>> W(N, 1);\nfor (int i = N-2; i >= 0; --i) W[i] = 10 * W[i+1];\nField<998244353> sum = 0, ans = 0;\nfor (int i = 0; i < N; ++i) sum = 10 * sum + (S[i]-'0');\nfor (int a = 0; a < N; ++a) {\nfor (int b = a+1; b < N; ++b) {\nfor (int c = b+1; c < N; ++c) {\nif (a == 0 && S[c] == '0') continue;\nint d = S[a]-'0', e = S[b]-'0', f = S[c]-'0';\nauto cur = (f-d)*W[a] + (d-e)*W[b] + (e-f)*W[c];\nans += sum + cur;\n}\n}\n}\nreturn ans;\n}\n}\n```\n\nThe time complexity of the above is O(N^3).\n\n## Div1 Medium: MinDegreeSubgraph\n[Problem Details\n](https://archive.topcoder.com/ProblemStatement/pm/14951)\nThe smallest graph (in terms of the number of edges) that is locally k-dense is a clique on k+1 vertices. Thus, if m ```<``` k(k+1)/2, the answer is clearly NONE.\nBy induction on n we can prove that all graphs having m ```>=``` t(n,k) := k(k+1)/2 + (n-(k+1))(k-1) edges are localy k-dense. The base case where n = k+1 is trivial, as it is a k+1-clique. Consider a graph G with ```>```k+1 vertices and let v be the vertex of minimum degree. If deg(v) >= k, we are done. Otherwise, remove v from G to form G’. G has n’ = n - 1 vertices and at least m’ >= m - (k-1) ```>=``` k(k+1)/2 + (n’-(k+1))(k-1) = t(n’,k) vertices. By induction, G’ is locally k-dense.\nOn the other hand, for m ```<``` t(n,k) we can construct a graph G with n vertices, m edges and no mindegree k subgraph. Clearly it suffices to show that there is such graph with t(n,k) - 1 edges, as graphs with fewer edges can be obtained simply by removing edges. Start with a (k-1)-clique on vertices 1,..,k-1. Connect each vertex with index k,..,n to each of the vertices 1,..,k-1. There are exactly t(n,k)-1 edges in this graph. Additionally, there are only k-1 vertices with degree at least k, so G is not locally k-dense.\n\nThis means that if m ```<``` t(n,k), the answer is SOME and if m ```>=``` t(n,k), the answer is ALL.\n\n```\nclass MinDegreeSubgraph {\nstring exists(int n, ll m, int k) {\nif (m < ll(k) * (k+1) / 2) return \"NONE\";\nelse if (m < ll(k) * (k+1) / 2 + ll(n - (k+1))*(k-1)) return \"SOME\";\nelse return \"ALL\";\n}\n}\n```\n\nThe time complexity is O(1).\n\n## Div1 Hard: Subpolygon\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14952)\n\nIt is evident that as P is convex, each choice of W yields a different convex polygon Q. We need to sum the areas across all such polygons.\n\nRecall that one can compute the area of the polygon as half of the sum of X[i]*Y[i+1] - X[i+1]*Y[i], where (X[0],Y[0]), (X[1],Y[1]), ... , (X[M],Y[M]) = (X[0],Y[0]) are the coordinates of vertices in counter-clockwise order.\n\nConsider an edge between P[i] and P[i+j] separately. If we knew the number of subpolygons in which it appears, we could calculate its contribution towards the sum of areas. In order for this edge to appear in Q, none of the vertices of the form P[i+k] (0 < k < j) may be present in Q, and at least one of the vertices of form P[i+k] (j ```<``` k ```<``` N) has to be present in Q (so that Q does not degenerate to a line segment). There are thus 2^{N-j-1}-1 such polygons.\n\nIf we precompute all powers of 2, we can compute the sum of areas in O(n^2). To make this faster, note that the total area is, up to some multiplicative factors, a sum of two convolutions and can be thus computed with FFT.\n\nIn the sample source below, the FFT implementation is omitted for brevity. Also note that the template class Field is used for modular arithmetic (i.e. performing all additions, subtractions and multiplication modulo given prime, and using modular exponentiation for division).\n\n```\nclass Subpolygon {\npublic:\nint sumOfAreas(int n) {\nvector<Field<998244353>> x(8*n), y(8*n), revX(8*n), revY(8*n);\n// generate polygon P\nfor (int i = 0; i < n; ++i) {\nx[i+1] = x[i] + (n-i);\ny[i+1] = y[i] + i;\n}\nfor (int i = 0; i < n; ++i) {\nx[n+i+1] = x[n+i] - i;\ny[n+i+1] = y[n+i] + (n-i);\n}\nfor (int i = 0; i < n; ++i) {\nx[2*n+i+1] = x[2*n+i] - (n-i);\ny[2*n+i+1] = y[2*n+i] - i;\n}\nfor (int i = 0; i < n; ++i) {\nx[3*n+i+1] = x[3*n+i] + i;\ny[3*n+i+1] = y[3*n+i] - (n-i);\n}\n// concatenate x (resp. y) with itself, and let revX,revY be reverse of x,y\nfor (int i = 0; i < 4 * n; ++i) {\nx[4*n+i] = revX[4*n-1-i] = x[i];\ny[4*n+i] = revY[4*n-1-i] = y[i];\n}\n// convolve x with revY, y with revX\nfft(x); fft(y); fft(revX); fft(revY);\nfor (int i = 0; i < x.size(); ++i) {\nx[i] *= revY[i];\ny[i] *= revX[i];\n}\nfftInverse(x); fftInverse(y);\n// calculate answer\nField<998244353> ans = 0, p = 1;\nfor (int i = 8*n-3; i >= 4*n; --i) {\nans += p*(y[i]-x[i]);\np = 2*p+1;\n}\nreturn ans/2;\n}\n};\n```\n\nThe total complexity is O(n log n).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6gHA1WnDWUuz1ZtHAncxg3","type":"Entry","createdAt":"2020-04-20T12:42:14.533Z","updatedAt":"2020-04-20T12:42:14.533Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"majk","tcHandle":"majk"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-736-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nJj6kyJhu8z0zKQqDFlB1","type":"Entry","createdAt":"2020-04-20T12:42:12.814Z","updatedAt":"2026-03-01T22:40:15.945Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":44,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 739","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2018-10-10T00:00:00.000Z","readTime":"30 min","content":"SRM 739 was held on October 10th. Thanks to [Blue.Mary](https://www.topcoder.com/members/Blue.Mary) for the problems and [majk](https://www.topcoder.com/members/majk) for testing the round and writing the editorials.\n\n## HungryCowsEasy - Div. 2 Easy\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15099)\n\nThe limits are small, so we can afford iterating over all cow-barn pairs. For each such pair, we calculate the cow’s distance from the barn. For a fixed cow, we select the barn with the smallest distance. There can be at most two such barns, and if there are two, we pick the one with smaller x-coordinate.\n\n```\nclass HungryCowsEasy {\npublic:\nvector findFood(vector cowPositions, vector barnPositions) {\nvector ans;\nfor (int cow: cowPositions) {\nint best = 0;\nfor (int i = 0; i < barnPositions.size(); ++i) { int curPos = barnPositions[i]; int bestPos = barnPositions[best]; if (abs(curPos-cow) > abs(bestPos-cow))\nbest = i;\nif (abs(curPos-cow) == abs(bestPos-cow) && curPos < bestPos))\nbest = i;\n}\nans.push_back(best);\n}\nreturn ans;\n}\n};\n```\n\nThe complexity of this approach is O(n^2). It can also be solved in O(n log n) or even in O(n) if both arrays would be initially sorted.\n\n## ForumPostMedium - Div. 2 Medium\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15095)\n\nWe start by converting the timestamps into a format that is easier to work with: the number of seconds from the midnight. Consider the difference between the two timestamps. We can observe that each potential label is used on a single interval. One can thus use few simple if statements.\n\nOne slight complication is that the post might be from a previous day. In that case, the number of seconds between the (yesterday’s) midnight and the posting time is larger than the number of seconds between the (today’s) midnight and the current time. In that case, we need to add 86400 (the number of seconds in a day) to the difference.\n\n```\nclass ForumPostMedium {\npublic:\nstring getShownPostTime(string currentTime, string exactPostTime) {\nstringstream ct(currentTime), ept(exactPostTime);\nint h, m, s; char c, d;\nct >> h >> c >> m >> d >> s;\nint t1 = 3600*h + 60*m + s;\nept >> h >> c >> m >> d >> s;\nint t2 = 3600*h + 60*m + s;\nint diff = t1 - t2;\nif (diff < 0) diff += 24 * 60 * 60;\nif (diff < 60) return \"few seconds ago\";\nelse if (diff < 60 * 60) {\nstringstream ans;\nans << diff / 60 << \" minutes ago\";\nreturn ans.str();\n} else {\nstringstream ans;\nans << diff / 60 / 60 << \" hours ago\";\nreturn ans.str();\n}\n}\n};\n```\n\nThe complexity of this approach is O(1).\n\n## CheckPolygon - Div. 2 Hard\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15098)\n\nIn this task, one needs to carefully translate the requirements from words into code. To prevent any nasty surprises, we should perform all computations on integers, and avoid floats.\nFirst, a few definitions:\n\n```\ntypedef pair Point;\n#define x first\n#define y second\n```\n\nWe use a simple orientation test, that returns positive value for left hand turn, negative value for right hand turn, and zero for collinear points.\n\n```\n\nint orientation(Point a,, Point b, Point c) {\nauto o = (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nreturn (o>0) - (o```<```0);\n}\nbool collinear(Point a, Point b, Point c) {\nreturn orientation(a, b, c) == 0;\n}\n\n```\n\nNext we need a test to check whether a point lies on segment. To check that, all three points must be collinear, and both the x and y-coordinates of the point on the segment has to be within the bounding box of the segment:\n\n```\n\nbool onSegment(Point a, Point b, Point c) {\nreturn orientation(a, c, b) == 0\n&& ((c.x <= max(a.x, b.x) && c.x >= min(a.x, b.x))\n&& (c.y <= max(a.y, b.y) && c.y >= min(a.y, b.y)));\n}\n\n```\n\nTo determine whether two segments intersect, we first check whether any of the four points lies on the other segment. Then, we can use the fact that the segments intersect if and only if the points a and b are in different half-planes determined by the line cd, and the points c and d are in different half-planes determined by the line ab. This condition is easily checked using orientation tests:\n\n```\nbool segmentsIntersect(Point a, Point b, Point c, Point d) {\nreturn onSegment(a, b, c) || onSegment(a, b, d)\n|| onSegment(c, d, a) || onSegment(c, d, b)\n|| (orientation(a, b, c) != orientation(a, b, d)\n&& orientation(c, d, a) != orientation(c, d, b))\n}\n```\n\nNext we need a method to calculate the area. Since all the points are at integer coordinates, the area is an integer or a half of an integer, so we can again perform all calculations in integers.\n\n```\n\nll doubleSignedArea(int N, vector P) const {\nll area = 0;\nfor (int i = 0; i < N; ++i) area += P[i].x * P[i+1].y - P[i+1].x * P[i].y;\nreturn area;\n}\n\n```\n\nAnd now we put everything together. We verify two things:\nNo three consecutive points are collinear\nNo two non-consecutive line segments intersect.\nIf both conditions are satisfied we report the area.\n\n```\nclass CheckPolygon {\npublic:\nstring check(vector X, vector Y) {\nint N = X.size();\nvector P(N+2);\nfor (int i = 0; i < N; ++i) P[i] = {X[i], Y[i]};\nP[N] = P[0]; P[N+1] = P[1];\nfor (int i = 0; i < N; ++i) {\nif (collinear(P[i], P[i+1], P[i+2])) return \"Not simple\";\nfor (int j = i+2; j < N; ++j) {\nif (i == 0 && j == N-1) continue;\nif (segmentsIntersect(P[i], P[i+1], P[j], P[j+1]))\nreturn \"Not simple\";\n}\n}\nll area = abs(doubleSignedArea(N, P));\nstringstream s;\ns << area/2 << '.' << \"05\"[area%2];\nreturn s.str();\n}\n};\n```\n\nThe complexity of this approach is clearly O(n^2).\n\n## ForumPostEasy - Div. 1 Easy\n[Problem Details\n](https://archive.topcoder.com/ProblemStatement/pm/15096)\nThe obvious thing to do in this task is to try every possible starting time and see whether it matches the observations. The property of being the lexicographically smallest time equals to being the closest time to midnight. Note that we should parse the input just once to avoid having too large constant in the time complexity.\n\n```\nclass ForumPostEasy {\npublic:\nstring getCurrentTime(vector exactPostTime, vector showPostTime){\nvector Times, Result;\nfor (int i = 0; i < exactPostTime.size(); ++i) { stringstream ept(exactPostTime[i]); int h, m, s; char c, d; ept >> h >> c >> m >> d >> s;\nint t = 3600*h + 60*m + s;\nTimes.push_back(t);\nchar ch = showPostTime[i][showPostTime[i].size()-6];\nif (ch == 'd') Result.push_back(0);\nelse {\nstringstream spt(showPostTime[i]);\nint d; spt >> d;\nif (ch == 'e') Result.push_back(d);\nelse Result.push_back(-d);\n}\n}\nfor (int t = 0; t < 86400; ++t) {\nbool ok = true;\nfor (int i = 0; i < exactPostTime.size() && ok; ++i) {\nint exp = 0, diff = t - Times[i];\nif (diff < 0) diff += 86400; if (diff >= 3600) exp = -(diff / 3600);\nelse if (diff >= 60) exp = diff / 60;\nok &= exp == Result[i];\n}\nif (ok) {\nstringstream ans;\nans << t / 36000 << (t / 3600)%10 << ':'\n<< (t / 600)%6 << (t / 60)%10 << ':' << (t / 10) % 6 << t%10;\nreturn ans.str();\n}\n}\nreturn \"impossible\";\n}\n};\n```\n\nThe complexity of this approach is O(t n), where t is the number of seconds in a day.\n\n## HungryCowsMedium - Div. 1 Medium\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15100)\n\nWe can binary search on the answer. How do we check whether the cows can make it in time? First note that if cow has appetite a_i and a barn has coordinate x_j, then the cow cannot possibly eat at this barn if a_i + x_j``` >``` t. For this reason, we sort all the barns by their increasing coordinate, and all cows by their decreasing appetite and use the following greedy algorithm.\n\nWe pick k such that sum_i=1^k a_i ```<=``` t - x_1. Then k of the cows with the most appetite will eat their full portion in the first barn. If there is time left in this barn, we take the k+1-th cow and use the remaining capacity. To have the maximum flexibility, it is clear that this is the first cow that should eat. In the next barn, this half-fed cow needs to eat last, and reduces the capacity accordingly.\n\nTo show that this strategy is indeed optimal, one needs to use the exchange argument to show that we can avoid the following configurations in an optimal solution:\na cow that eats at both i-th and j-th barn where j-i >= 2\n\ntwo cows that eat at both i-th and i+1-th barn\ncows a_i ```>``` a_j eating (at least partially) at barns x_k ```>``` x_l, respectively\n\n```\nclass HungryCowsMedium {\npublic:\nll getWellFedTime(vector C, vector B) {\nsort(C.begin(),C.end());\nsort(B.begin(),B.end());\nreturn binary_search_smallest(0LL, ll(4e11), [&](ll T) {\nauto cow = C.rbegin(); ll time = 0;\nfor (auto barn = B.begin(); barn != B.end() && cow != C.rend(); ++barn) {\nif (*cow > T - *barn) return false;\ntime += T - *barn - *cow;\nwhile (++cow != C.rend() && *cow <= time) time -= *cow;\n}\nreturn cow == C.rend();\n});\n}\n};\n```\n\n## MakePolygon - Div. 1 Hard\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15097)\n\nA bit of trial and error suggests that on an infinite grid, the optimal solution has area (N-2)/2. The question is how to put it into a grid that is relatively small, and how to avoid the neighbouring segments to be collinear. One approach would be to make an inward spiral, such as this one with 572 points, built from blocks of 8 points in a 2x5 rectangle.\n\nIf fewer than 500 points are requested, we may omit some of the points from either side. Keep in mind that this may introduce two collinear consecutive segments, i.e. when we remove the four points at the inner end of a spiral. To combat this, we may either remove some points from both ends of a spiral and check whether the conditions hold, or we may be more careful in the spiral construction. The approach used in the solution below is to not generate all the six points in a rectangle if we are approaching the correct number of points.\n\nTo do that in a manageable fashion, we grow two sides of the polygon, called left and right, in alternating fashion, and stop when the needed amount of points is reached. Afterwards, the left and right side of the polygon are merged together.\n\n```\nclass MakePolygon {\npublic:\nint N;\nvector L, R;\nbool space(int n = 0) {\nreturn (L.size() + R.size() + n< N); } void left(int x, int y) { if (space() && (L.empty() || L.back() != 100*x+y) && x >= 1 && x <= 25 && y >= 1 && y <= 25) L.push_back(100*x+y); } void right(int x, int y) { if (space() && (R.empty() || R.back() != 100*x+y) && x >= 1 && x <= 25 && y >= 1 && y <= 25) R.push_back(100*x+y);\n}\nvoid yway(int x, int y, int d, int end) {\nbool beg = true;\nwhile (y != end) {\nleft(x, y);\nright(x+d, y);\nif (!beg && space(4)) left(x-d, y);\nif (!beg && space(3)) left(x, y+d);\nif (!beg && space(5)) right(x+d+d, y);\nif (!beg && space(5) && y+d+d != end) right(x+d+d+d, y+d);\nleft(x+d, y+d);\nright(x+d+d, y+d);\ny += d+d;\nbeg = false;\n}\n}\nvoid xway(int x, int y, int d, int end) {\nbool beg = true;\nwhile (x != end) {\nif (!beg && space(4)) right(x, y-d-d);\nif (!beg && space(4)) left(x, y+d);\nleft(x, y);\nright(x, y-d);\nright(x+d, y-d-d);\nif (!beg && space(5) && x+d+d != end) right(x+d, y-d-d-d);\nleft(x+d, y-d);\nif (space(4)) left(x+d, y);\nx += d+d;\nbeg = false;\n}\n}\nvector make(int N) {\nthis->N = N;\nfor (int j = 0; j <= 8; j += 4) {\nyway(1+j, 1+max(j-2,0), 1, 25-j); left(2+j, 25-j);\nxway(3+j, 25-j, 1, 25-j); left(25-j, 24-j);\nyway(25-j, 23-j, -1, 1+j); left(24-j, 1+j);\nxway(23-j, 1+j, -1, 5+j); left(5+j, 2+j);\n}\nreverse(L.begin(),L.end());\nL.insert(L.end(), R.begin(), R.end());\nreturn L;\n}\n};\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6gHA1WnDWUuz1ZtHAncxg3","type":"Entry","createdAt":"2020-04-20T12:42:14.533Z","updatedAt":"2020-04-20T12:42:14.533Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"majk","tcHandle":"majk"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-739-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3oeSsmUsDt8LeAmX5f41he","type":"Entry","createdAt":"2020-04-20T12:42:12.906Z","updatedAt":"2026-03-01T22:26:06.923Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":47,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 741","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2018-10-31T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 741 Editorials\n\nSRM 741 was held on 30th October. The problem set was prepared by [Blue.Mary](https://profiles.topcoder.com/Blue.Mary). Thanks to [misof](https://profiles.topcoder.com/misof) for testing and preparing the editorials. This was the last SRM in stage 1 of TCO19 Algorithm Qualification. Congratulations to [tourist](https://profiles.topcoder.com/tourist) for qualifying for TCO19 Algorithm Finals!\nMatch Result and Overview.\n\n## DigitStringDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15143)\n\nAs is usually the case in the easy problem in Division 2, the constraints are so small that any correct solution will pass. And as is usually the case, the easiest way to write a correct solution is to use brute force.\n\nIn this problem, brute force looks as follows: We’ll generate all possible substrings of S. We can do this simply by trying all possibilities for the indices of its beginning and end. For each of the substrings, we will check whether it starts with a non-zero digit, and then we convert it to an integer and compare it to X.\n\nIn order to convert a string to an integer, you can either use a built-in function (most languages will have one), or you can iterate over the string one character at a time, as follows:\n\n```\ndef string_to_int(S):\n   answer = 0\n   for c in S:\n   answer = 10*answer + ord(c) - ord('0')\n   return answer\n```\n\nHere is a full working implementation:\n\n```\ndef count(S,X):\n\n   answer = 0\n\n   for z in range( len(S) ):\n\n       for k in range( z+1, len(S)+1 ):\n\n           N = S[z:k]\n\n           if N[0] == '0': continue\n\n           if int(N) > X: answer += 1\n\n   return answer\n```\n\n## SimpleMathProblemDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15147)\n\nThe function value f(n) is defined as the sum of g(n,p) over all primes p. However, if p > n, then clearly p does not divide n, which means that g(n,p) is zero. Thus, when computing f(n) we only care about primes that are less than or equal to n.\n\nThe most straightforward way to solve this task was to actually compute the functions f and g as specified in the statement. Computing g is easy: we simply compute powers of p until we are about to exceed n. This runs in O(log n) time, which is very fast. (In the worst case, for n=444,777 and p=2, the function will still make fewer than 20 iterations.)\n\n```\nlong long g(long long n, long long p) {\n\n   // assumes that we already checked that p divides n\n\n   long long answer = 1;\n\n   while (answer * p <= n) answer *= p;\n\n   return answer;\n\n}\n\n```\n\nNow we need to implement f. In order to compute f(n), we need to sum all non-zero g(n,p). In other words, we need to find all primes p that divide n, and we need to compute g for each of them. How can we do that quickly?\n\nOne simple way to find all prime factors of n (and, in fact, the full factorization of n) is to use one simple observation: Among all the primes in n’s prime factorization there can be at most one that is bigger than the square root of n. Why? Because already if you take two such primes, their product is obviously more than n.\n\nBased on this observation, we can now write the following implementation of f:\n\n```\nlong long f(int n) {\n\n   long long answer = 0;\n\n   int original_n = n;\n\n   for (int d=2; d*d <= n; ++d) {\n\n       if (n % d == 0) {\n\n           while (n % d == 0) n /= d;\n\n           answer += g(original_n,d);\n\n       }\n\n   }\n\n   if (n > 1) answer += g(original_n,n);\n\n   return answer;\n\n}\n```\n\nIf we don’t count the calls to g, this implementation of f obviously runs in O(sqrt(n)). Thus, for any n ```<=``` 444,777 it will only require at most sqrt(444,777) <= 667 iterations, and usually it will be even fewer than that.\n\nTwo things to note in the above implementation: First, whenever we find a d that actually divides n, we can be sure that this must be a prime number. It cannot be the product of smaller prime numbers, because we already tried all of those and we divided n by each of those, so the current value of n isn’t divisible by anything smaller than d. Second, note that the value of n changes during the computation, and that new, smaller n is then used as the upper bound for the cycle. This is still correct, because the same argument still applies: the value that remained in n is either a prime, or it still has a divisor that is at most equal to its own square root.\n\nTo finish the solution, we now just run a simple for-cycle to compute the sum f(1) + … + f(X).\n\nAnother reasonably simple solution is based on the following steps:\n\nUse the [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) (or a primality test similar to the algorithm used above) to generate all primes up to X.\n\nFor each prime p in that set, go through n=p, 2p, 3p, … until you reach X, and for each such n compute g(n,p) and add it to the total.\n\nThere are much faster solutions, but those were not needed to get accepted in the Division 2 version of this problem. If you want to see them, one will be presented below.\n\n## BoardCoveringDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15145)\n\nThe main observation needed to solve this problem is that regardless of the shape and orientation of a tromino, its perimeter is always 8. Hence, each tromino is adjacent to at most 8 other unit squares. And as we have 10 available colors, we can color the trominoes greedily. More precisely, we can do the following:\n\n```\nfor each tromino on the given board (in any order):\n\n   look at the colors already used on squares adjacent to this tromino\n\n   pick a color that is not among them\n\n   use that color for this tromino\n\n```\n\nAll that remains is to implement the above algorithm in a painless way. Let’s do one more iteration of writing pseudocode, but now with more details.\n\n```\nfor each row r:\n\n   for each column c:\n\n       if the square at (r,c) belongs to an uncolored tromino:\n\n           find the rest of the tromino\n\n           find all squares adjacent to those\n\n           collect all their colors, etc.\n```\n\nIn order to find the rest of the tromino, we can use any standard graph search (e.g., BFS or DFS), but I opted for a different technique: I wrote a function that would generate all adjacent cells to a given cell by simply trying all four directions. Then, you can generate the tromino by essentially iterating this function twice. More precisely, you take all the neighbors of the original cell that share the same color in the input, and then you take all their neighbors with the same property, and you have the tromino. As a bonus, you can then use the same function in the next step, only now you take the cells that had a different color in the input.\n\nFull implementation:\n\n```\ndef neighbors(board, r, c, same=True):\n\n   '''\n\n   if \"same\", returns neighbors of the square (r,c) that have the same color\n\n   otherwise, returns neighbors of the square (r,c) that have another color\n\n   '''\n\n   answer = set()\n\n   for nr, nc in [ (r-1,c), (r+1,c), (r,c-1), (r,c+1) ]:\n\n       if not (0 <= nr < len(board) and 0 <= nc < len(board[0])):\n\n           continue\n\n       if same:\n\n           if board[r][c] == board[nr][nc]: answer.add( (nr,nc) )\n\n       else:\n\n           if board[r][c] != board[nr][nc]: answer.add( (nr,nc) )\n\n   return answer\n\ndef spread(board, cells, same=True):\n\n   '''\n\n   if \"same\", returns the cells from \"cells\" + their same-color neighbors\n\n   otherwise, returns the other-colored neighbors of cells from \"cells\"\n\n   '''\n\n   new_cells = cells.copy() if same else set()\n\n   for r,c in cells: new_cells |= neighbors(board,r,c,same)\n\n   return new_cells\n\ndef get_tromino(board, r, c):\n\n   cells = set([ (r,c) ])\n\n   cells = spread(board, cells)\n\n   cells = spread(board, cells)\n\n   return cells\n\ndef make(board):\n\n   R, C = len(board), len(board[0])\n\n   digits = '0123456789'\n\n   answer = [ [ None for c in range(C) ] for r in range(R) ]\n\n   for r in range(R):\n\n       for c in range(C):\n\n           if board[r][c] == '#': answer[r][c] = '#'\n\n           if answer[r][c] is not None: continue\n\n           tromino = get_tromino(board, r, c)\n\n           neighbors = spread(board, tromino, False)\n\n           colors_seen = set( answer[rr][cc] for rr, cc in neighbors )\n\n           i = 0\n\n           while digits[i] in colors_seen: i += 1\n\n           for rr, cc in tromino: answer[rr][cc] = digits[i]\n\n   return [ ''.join(row) for row in answer ]\n\n```\n\nExercise: Above, we have shown that 10 colors are enough. However, this algorithm would actually work with fewer than 10 colors. What is the smallest number of colors C for which the above algorithm still works? And is that number of colors worst-case optimal, or is there another algorithm that will always find a coloring with fewer than C colors?\n\n## DigitStringDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15142)\n\nThere are 2^47 ways to erase characters from a 47-character string, and we cannot afford to check all of them. Thus, we need some clever way of counting.\n\nAlmost all the ways to erase characters will usually be good. As long as we make sure that the first character we leave is not a ‘0’ and that we leave at least 10 characters, we will certainly have a number that’s big enough (as the largest valid X has only 9 digits). However, this observation is still not enough to get an algorithm that would be fast enough: there are (47 choose 9) = 1,362,649,145 ways to choose which 9 of 47 characters we should leave, and in general we would need to examine each of those, even if we could handle all the bigger numbers by some formula.\n\nAnother line of thought would be to try some dynamic programming. Imagine that we go through the input string from the left to the right, and for each character we’ll recursively try out both possibilities, one after another: either we keep it or we erase it. How can we describe our state somewhere in the middle of this recursive search? One possibility looks as follows. We need to specify:\n\n- How many input characters we already processed.\n- How many of them we kept.\n- If we kept at most nine, what is the number they form.\n\nSadly, the above is still too slow, as for a random string of digits we can eventually get very many different 9-digit numbers, so we still have way too many states.\n\nLuckily, this approach can still be saved, we just need to make one more observation. Suppose X = 456789 and you already kept three digits. The state where your current number is “123” and the state where it is “455” are exactly the same -- in either case, you need any 4 digits to be bigger than X, but no 3 digits will be enough. Similarly, “457” and “989” are equivalent in that any 3 appended digits will give you a number bigger than X. Inbetween there is a third case: “456”, in other words, the digits we kept so far form a prefix of X.\n\nThus, we can reduce our state space as follows. Let D be the number of digits of X. Then, each state can be described by the following:\n\n- a = How many input characters we already processed.\n- b = How many of them we kept.\n- c = 0/1/2, where:\n- c = 0 means that the number we kept is smaller than the number formed by the first b digits of X\n- c = 1 means that it is equal\n- c = 2 means that it is bigger (and we also use this state whenever b > D).\n\nThis leaves us with just 47*47*3 states, and for each of them we can compute the answer simply by trying out two possibilities: whether to keep or to erase the next character of the input string.\n\nIn my implementation I used a slightly different approach that is easier to code. I simply noticed that, for example, if you have X = 456789, then any prefix that is between “457” and “4566”, inclusive, is equivalent. Then, I just implemented the previous solution, but whenever my current number falls between two prefixes of X, before doing memoization I simply change it to (the shorter prefix of X) + 1. This is implemented in the function “fix” below.\n\n```\nclass DigitStringDiv1:\n\n   def fix(self, value, limit):\n\n       while True:\n\n           if value > limit: return limit+1\n\n           if value == limit: return limit\n\n           limit //= 10\n\n   def solve(self, where, took):\n\n       if where == len(self.S): return 1 if took > self.X else 0\n\n       key = (where, took)\n\n       if key in self.memo: return self.memo[key]\n\n       self.memo[key] = self.solve( where+1, took )\n\n       if took > 0 or self.S[where] != '0':\n\n           new_took = self.fix( 10*took + int( self.S[where] ), self.X )\n\n           self.memo[key] += self.solve( where+1, new_took )\n\n       return self.memo[key]\n\n   def count(self, S, X):\n\n       self.S, self.X, self.memo = S, X, {}\n\n       return self.solve(0,0)\n```\n\n## BoardCoveringDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15144)\n\nThis problem is a generalization of Golomb’s famous problem: show that any square board with side length 2^k and one black cell can be tiled. That version has a short and beautiful recursive solution, and if you don’t know it, try solving that problem before this one.\n\nAn obvious necessary condition for a solution to exist is that the number of squares on the n times n board must be of the form 3k+1 for some k. In other words, n cannot be divisible by 3. It turns out that this condition is also sufficient -- all remaining boards can be tiled. Even better: all rectangles that have both dimensions at least 2 and area of the form 3k+1 can be tiled.\n\nA good strategy for problems like this one is to reduce the bigger problems to smaller ones: find a way to take any large instance and construct a partial solution (in our case, a partial tiling) in such a way that the part that remains to be solved is another valid and solvable instance. If you can do that, you can then take an arbitrarily large instance and apply the above steps repeatedly, until you get one of finitely many constant-size instances that are too small for the rule to apply.\n\nAnother good strategy: when left with finitely many cases, before you solve them manually, use symmetry to reduce their number. In our case, we can flip the board diagonally, horizontally, and/or vertically to get it into one of very few “canonical positions”.\n\nFor the first part of this solution, note that if you have to tile a large rectangle, one thing you can do is choose a side that is far from the black square, and tile the first 3 rows/columns along that side by laying down a sequence of I-shaped trominoes. This leaves you with a smaller rectangle to tile. If you repeat steps of this form, you will eventually be left with one of finitely many tiny rectangles.\n\nThe pseudocode of the resulting solution follows. (R and C denote the number of rows and columns of the current board, rb and cb denote the coordinates of the black square within that board.)\n\nwhile True:\n\n   if R ```>=``` 5 and you can tile the first or the last three rows, do so\n\n   if C ```>=``` 5 and you can tile the first or the last three columns, do so\n\n   if you didn’t tile anything new, break\n\nlet “board” denote the part that remains to be tiled\n\nflip the board horizontally and vertically, if needed, to get the black cell into its upper left quarter\n\nflip the board diagonally if (R > C) or (R == C and rb > cb)\n\nat this moment, (R,C,rb,cb) must be one of the following:\n\n   (1,1,0,0), (2,2,0,0), (4,4,0,0), (4,4,0,1), (4,4,1,1), (2,5,0,2), (5,5,2,2)\n\nfor each of those cases, construct a solution by hand\n\nflip the manually-constructed solution to undo the flips you did above\n\nonce you have the full tiling, solve the Div2 version of this task (i.e., just color the trominoes greedily, always using the smallest available color)\n\nCan you find a solution with fewer cases that need to be solved by hand? There certainly are such solutions. The main reason why I picked this one was that it’s conceptually as simple as can be, even if it may require a bit more manual work.\n\n## SimpleMathProblemDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15146)\n\nObviously, this is a problem about primes. Also obviously, 3,333,377,777 is quite a large number.\n\nAfter parsing the problem statement it’s quite obvious that the sum f(1) + … + f(X) only involves primes up to X, and one possible strategy is to consider each of those primes separately. Our hopes die in a fire as soon as a quick query to Wolfram Alpha confirms what we already estimated: there are over 159 million primes in that range and we cannot afford to generate them and consider each of them separately.\n\nOn the other hand, the square root of X is small enough (less than 60,000) and the number of primes up to sqrt(max X) is less than 6,000. This observation gives us a possible line of attack:\n\n1. Find all primes up to sqrt(X).\n2. For each of these primes, count its contribution to the result.\n3. Do something magical to find the contribution of all those larger primes.\n\nWell, steps 1 and 2 are easy, but what about step 3? The intuition why we can be hopeful that this approach can succeed is that these primes are “easier” than the ones in the general case: if you have a prime p > sqrt(X), p^2 is already too large, and therefore each n that is divisible by p only contributes p to the total. In other words, the contribution of this p to the sum of all f(n) is simply (p times (the number of n divisible by p)).\n\nThus, the sum we need is sum( p*(X div p) ) over all primes p in (sqrt(X),X]. The question remains: how can we find this sum without finding all of the primes?\n\nLet’s split these primes into smaller groups according to the value of (X div p). For each of these groups, we will compute the sum of primes it contains, and we will then multiply their sum by the corresponding value.\n\nThe value of (X div p) lies in the interval [1,p). For d > 1, the primes such that X div p = d lie in the interval [X/d,X/(d-1)). (Both endpoints are reals, not necessarily integers.)\n\nLet S(n) denote the sum of all primes that are less than or equal to n. We can compute the sum of primes in each of our intervals by computing S(n) for the sqrt(X) values of n that are of the form X/d, and taking differences.\n\nAdditionally, let T(n,x) denote the sum of all numbers between 1 and n that do not have any factor between 2 and x, inclusive. Clearly, S(n) = T(n,n-1), but a more clever way is to say S(n) = T(n,p) + S(p) - 1, where p is the largest prime <= sqrt(n). The values S(p) we need in this step can be easily precomputed, so all we need is T(n,p).\n\nA clever way to compute these values is based on the following recurrences:\n\nT(n,1) = n(n+1)/2\n\nT(n,p) = T(n,p’) - p*T(n/p,p), where p’ is the biggest prime smaller than p, or 1 if there is no such prime\n\n(For the recursive step, we need to subtract the sum of all numbers that are <=n and whose smallest prime factor is exactly p. When we divide each of these numbers by p, we get precisely the numbers that are <=n/p and whose smallest factor is p or more. Again, note that the first argument in T(n/p,p) is a real, not necessarily an integer.)\n\nIf we precompute answers with n <= sqrt(X), the remaining states are rather sparse. There are sqrt(X) possible values for the first argument: X, X/2, …, X/floor(sqrt(X)). If the first argument is n, for the second one we only need to consider primes up to sqrt(n). Summing up those, we can show that the total number of states we’ll need to evaluate is O(X^(¾) / log(X)).\n\nProblem author’s code follows.\n\n```\nlong calc(long X, long p){\n\nlong p1 = p, res = 0;\n\nwhile(true){\n\nlong p2 = p1 * p;\n\nif(p2 > X){\n\nres += (X / p - p1 / p + 1) * p1;\n\nbreak;\n\n}else{\n\nres += (p1 - p1 / p) * p1;\n\np1 = p2;\n\n}\n\n}\n\nreturn res;\n\n}\n\nlong f2(long X){\n\nif(X % 2 == 0)return X / 2 * (X+1);\n\nreturn (X+1)/2 * X;\n\n}\n\nlong calculate(long X){\n\nlong n = X;\n\nif(n == 1)return 0;\n\nint m = (int)Math.sqrt((double)n + 0.5);\n\nlong[] A = new long[m + 1];\n\nlong[] B = new long[m + 1];\n\nboolean[] fg = new boolean[m + 1];\n\nint[] primes = new int[99999];\n\nint nprime = 0;\n\nfor(int i=2; i<=m; i++){\n\nif(!fg[i])primes[nprime++] = i;\n\nfor(int j=0; j<nprime; j++){\n\nint x = i*primes[j];\n\nif(x > m)break;\n\nfg[x] = true;\n\nif(i%primes[j]==0)break;\n\n}\n\n}\n\nfor(int i=1; i<=m; i++){\n\nA[i] = f2(i)-1;\n\nB[i] = f2(n/i)-1;\n\n}\n\nlong res = 0;\n\nfor(int t = 0; t < nprime; t++){\n\nint p = primes[t];\n\nif(p > m)break;\n\nres += calc(n, p);\n\nlong d = A[p-1];\n\nlong p2 = (long)p * p;\n\nlong to1 = n / p2;\n\nif(to1 > m)to1 = m;\n\nint to = (int)to1;\n\nint mid = (int)(m / p);\n\nfor(int i=1; i <= mid; i++)\n\nB[i] -= (B[i*p] - d) * p;\n\nlong tmp = n/p;\n\nfor(int i=mid+1; i <= to; i++)\n\nB[i] -= (A[(int)(tmp / i)] - d) * p;\n\nfor(int i=m; i>=p2; i--)\n\nA[i] -= (A[i/p]-d) * p;\n\n}\n\nlong cur = A[m];\n\nfor(int i=m; i>=1; i--){\n\nres += (B[i] - cur) * i;\n\ncur = B[i];\n\n}\n\nreturn res;\n\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-741-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3DkU8osqL7BG1liDiSdtwo","type":"Entry","createdAt":"2020-04-20T12:42:12.956Z","updatedAt":"2026-03-01T18:57:22.674Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":31,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 742","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Haskell"],"creationDate":"2018-12-03T00:00:00.000Z","readTime":"15 min","content":"# Single Round Match 742 Editorials\n\nI participated on SRM 742 Div II and, inspired by my brother's editorial of SRM 739, decided to present my solutions here!\n\nDuring SRM I was solving tasks in C++ but, since I am currently learning Haskell, I will also present my solutions in Haskell.\n\n## BirthdayCandy (250)\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15213)\n\nTo figure out how many candies will Elisa get if she picks specific candy bag, we do the whole number division with (K + 1) to learn how many rounds of giving candies Elisa will do. Then, we take the rest of the candies (which is remainder from the whole division with (K + 1) and sum it up with the number of rounds and that is the total number of candies Elisa would get from that bag of candies. We do this for every bag of candies and return the biggest number.\n\n### C++\n```\n#include <vector>\nusing namespace std;\nclass BirthdayCandy {\npublic:\nint mostCandy(int K, vector <int> candy) {\nint maxCandy = -1;\nfor (int i = 0; i < (int) candy.size(); i++) {\nconst int numCandy = candy[i] / (K + 1) + candy[i] % (K + 1);\nif (numCandy > maxCandy) maxCandy = numCandy;\n}\nreturn maxCandy;\n}\n};\n```\n\n### Haskell\n\nIt is really easy to describe this solution in Haskell, resulting in just one line of logic!\nmodule BirthdayCandy (mostCandy) where\n```\nmostCandy :: Int -> [Int] -> Int\nmostCandy k = maximum . map (\\c -> c `div` (k + 1) + c `mod` (k + 1))\n```\n\n## SixteenQueens (500)\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15227)\n\nAt first, this one seems hard, if we want to make sure that we arrange queens in an optimal way so that the biggest amount of them can fit on the board.\n\nHowever, if we look at the constraints (board size and the maximal number of queens), we can figure out that the board is so big that we can just put queens one by one in a greedy manner on it and there will always be enough space for all of them.\n\nTherefore, we go with the greedy solution where we, for each queen that we want to add, go through all the fields on the board until we find the first field that is available (not under attack by queens that are already on the board).\n\nThen we put the new queen on the board and continue with the next queen.\nTo figure out if the field is under attack we check that it is not on the same diagonal, row or column as any other queen.\n\nNice way to check if two fields are on the same diagonal is by checking if the absolute difference of their row indexes is equal to the absolute difference of their column indexes. If it is, they are on the same diagonal, otherwise, they are not.\n\n### C++\n```\n#include <vector>\n#include <cstdlib>\nusing namespace std;\nclass SixteenQueens {\npublic:\nvector <int> addQueens(vector <int> row, vector <int> col, int add) {\nvector<int> result;\nfor (int i = 0; i < add; i++) { // For each queen that we want to add.\nbool done = false;\nfor (int r = 0; r < 50 && !done; r++) { // Let's try every field on the board. Every row.\nfor (int c = 0; c < 50 && !done; c++) { // And every column.\nbool fieldOk = true; // Is field ok to put queen on it?\n// Check if any of previous queens is compromising the field.\nfor (int j = 0; j < (int) row.size() && fieldOk; j++) {\nif (r == row[j] || c == col[j] || (abs(r - row[j]) == abs(c - col[j]))) {\nfieldOk = false; break;\n}\n}\nif (fieldOk) { // If field is ok to go, put queen on it.\nrow.push_back(r); col.push_back(c); // Add to queens on board.\nresult.push_back(r); result.push_back(c); // Add to results.\ndone = true;\n}\n}\n}\n}\nreturn result;\n}\n};\n```\n\n### Haskell\n\nThis problem can naturally be described recursively, which results in a very elegant solution in Haskell.\n\n```\nmodule SixteenQueens (addQueens) where\naddQueens :: [Int] -> [Int] -> Int -> [Int]\naddQueens row col 0 = []\naddQueens row col add = rAdd:cAdd:(addQueens (rAdd:row) (cAdd:col) (add - 1))\nwhere (rAdd, cAdd):_ = [(r, c) | r <- [0..49], c <- [0..49], not (isUnderAttack (r, c))]\nisUnderAttack (r, c) = any (\\(r', c') -> r == r' || c == c' || abs (r - r') == abs (c - c')) (zip row col)\n```\n\n## ResistorFactory (1000)\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15226)\n\nThis task I was not able to finish during the SRM - I did come up with the solution and started implementing it, but “thinking part” took me a long time and I did not have enough time left to finish it. I finished it later and confirmed in the practice room that it works correctly.\nWhile the problem is in itself simple - combine resistors to achieve wanted value - the solution is not so obvious.\n\nThe way problem is stated made me consider if there is a dynamic programming solution, however, I concluded that search space is just too big and I could not see any smart way to narrow down that search. There are just too many choices - resistor values can be real numbers, we can do series or parallel, we can combine any two resistors that we have built so far.\n\nTherefore, I decided to somehow simplify the situation.\n\n__Series doubles, parallel halves__\n\nFirst, we can observe that if we put a resistor in series with itself, we get a resistor with double the resistance, and if we put it in parallel, we get a resistor with half the resistance. This means that if we start with a resistor of resistance R, we know how to easily create resistors of resistance 2^x * R where x is an integer.\n\nSince we start with a resistor of 10^9 nano ohm (all the values from now on I will express in nano-ohms), we can create 2 * 10^9 resistor by putting it in series with itself, or we can create 0.5 * 10^9 resistor by putting it in parallel with itself. We can then repeat this process with newly created resistors to create smaller and bigger resistors.\n\n__Creating an inventory__\n\nNext, we can observe that if we have an inventory of resistors with various values, we can just put some of them in series and probably get pretty close to the target value. But, what kind of values should those be, so that we can actually do that?\n\n1. We need a resistor of small enough value that we can achieve any possible target value with high enough precision. Precision defined in the problem is 1 nano ohm.\n2. We need resistors to have big enough values so that we don't need to combine too many resistors in series since limit stated by the problem is 1000 commands, which means that we can't combine more than 1000 resistors.\n\nWe start our inventory with the only resistor we have at the beginning, resistor #0 with a resistance of 10^9 nano-ohms.\n\nCombining the observations so far, we can see that if we repeatedly create smaller and bigger resistors as described before (by doubling and halving), we will cover the space of possible target resistor values (from 0 to 10^18 nano-ohms) with values that are logarithmically (base 2) spaced.\n\nTo cover that space densely enough and to also be sure that we have small enough resistor to always be able to obtain the needed precision, we can keep halving the smallest resistor in the inventory and doubling the biggest resistor in the inventory until the smallest resistor is 2^-30 * 10^9 (~ 0.001) nano-ohms and the biggest resistor is 2^29 * 10^9 (~0.54 * 10^18) nano-ohms.\n\nNow, let's observe the commands needed to build such inventory.\nFirst, let's build resistors from 2 * 10^9 to 2^29 * 10^9, that is 29 resistors. We can do this by repeatedly putting the last resistor in inventory in series with itself, 29 times.\nThis results in following commands:\n[(0, 0, 0), (1, 1, 0), ..., (27, 27, 0), (28, 28, 0)]\n\nNext, let's build resistors from 2^(-1) * 10^9 to 2^(-30) * 10^9, that is 30 resistors. The first resistor we build by putting the resistor #0 in parallel with itself and then we repeatedly put the last resistor in inventory in parallel with itself, 29 times.\nThis expands our list of commands to a total of 59 commands:\n[(0, 0, 0), (1, 1, 0), ..., (27, 27, 0), (28, 28, 0), (0, 0, 1), (30, 30, 1), (31, 31, 1), ..., (59, 59, 1)]\n\nValues of created resistors (in ohms, not in nano-ohms!):\n[2^1, 2^2, ..., 2^28, 2^29, 2^-1, 2^-2, 2^-3, ..., 2^-30]\n\nDoes this inventory satisfy our needs from before?\n\nThe smallest resistor is smaller than required precision, so that is ok. The only question that remains is, are we sure that we can always build target resistor with less than 1000 - 59 = 941 commands by using this inventory of resistors that we created?\n\n__Building target resistor from the inventory__\n\nFirst, let's see how we can use our resistor inventory to build the target resistor.\nThe problem states that the last command in our list of commands has to be the one constructing target resistor.\n\nWith inventory just freshly built, the last command is currently the one that constructs resistor of 2^-30 ohms (~0.93 nano-ohms).\n\nIf that is not close enough to target resistor, we are going to add to it, in series, another resistor from inventory that will bring us as close as possible to target resistor (which is the biggest resistor that is smaller than the difference between target resistor value and the last resistor in inventory). We are going to repeat this process until we construct the resistor that is close enough to target resistor, and that is it!\n\nNow, to answer the question from before, if we can guarantee that we are not going to need more than 1000 commands in total.\n\nSince distance between our inventory resistors is logarithmic with base 2 it means that with each resistor we add to series while building target resistor as described above we are halving the mistake between our current best resistor and target resistor, which means that a few dozen steps (<= 60) will be always enough to build it!\nThis means we are in total never going to have more than 59 + 60 = 119 commands, which is way below the limit of 1000.\n\nThat is all! Although slightly complex, this solution performs very well in terms of speed and is reliable. I do wonder if there is a simpler solution or solution that returns the smallest number of commands but have not thought of one yet.\n\n### C++\n```\n#include <vector>\nusing namespace std;\nclass ResistorFactory {\npublic:\nvector <int> construct(long long nanoOhms) {\nvector<int> commands;\nvector<double> values;\nvalues.push_back(1000000000.0); // Product 0 is 10^9 ohm.\nfor (int i = 0; i <= 28; i++) { // Products 1 to 29, each next is 2 times bigger.\ncommands.push_back(i); commands.push_back(i); commands.push_back(0);\nvalues.push_back(((double) values[values.size() - 1]) * 2);\n}\n// Product 30, which is 10^9 / 2 (product #0 / 2).\ncommands.push_back(0); commands.push_back(0); commands.push_back(1);\nvalues.push_back(values[0] / 2);\nfor (int i = 30; i <= 58; i++) { // Products 31 to 59. each is 2 times smaller.\ncommands.push_back(i); commands.push_back(i); commands.push_back(1);\nvalues.push_back(((double) values[values.size() - 1]) / 2);\n}\n// Inventory is built! Now we use our inventory to build the final resistor.\ndouble remaining = nanoOhms - values[values.size() - 1]; // Difference between what we have and target.\nwhile (remaining >= 1) {\nint bestIdx = -1; // Biggest resistor that is smaller than remaining amount.\nfor (int i = 0; i < (int) values.size(); i++) {\nif (values[i] <= remaining && (bestIdx == -1 || remaining - values[i] < remaining - values[bestIdx])) {\nbestIdx = i;\n}\n}\ncommands.push_back(values.size() - 1); commands.push_back(bestIdx); commands.push_back(0);\nvalues.push_back(values[values.size() - 1] + values[bestIdx]);\nremaining -= values[bestIdx];\n}\nreturn commands;\n}\n};\n```\n\n### Haskell (v1, more expressive)\n\nFirst Haskell version I came up with ended up pretty big, due to me writing very expressive code. This comes natural when writing Haskell because it is so easy to define functions and data types.\n```\nmodule ResistorFactory (construct) where\nimport Data.List (foldl', maximumBy)\nprecisionInNanoOhm = 1 :: Double\ndata ResistorBuild = Parallel Resistor Resistor | Series Resistor Resistor | OnePiece\ndata Resistor = Resistor { getResistorId :: Int, getValueInNanoOhm :: Double, getBuild :: ResistorBuild }\nresistorToCommand :: Resistor -> (Int, Int, Int) -- Transforms resistor into format expected by Topcoder as result.\nresistorToCommand (Resistor _ _ (Series r1 r2)) = (getResistorId r1, getResistorId r2, 0)\nresistorToCommand (Resistor _ _ (Parallel r1 r2)) = (getResistorId r1, getResistorId r2, 1)\nresistorToCommand _ = error \"Can't be transformed to command!\"\ncreateFromSeries :: Int -> Resistor -> Resistor -> Resistor\ncreateFromSeries id r1 r2 = Resistor id (getValueInNanoOhm r1 + getValueInNanoOhm r2) (Series r1 r2)\ncreateFromParallel :: Int -> Resistor -> Resistor -> Resistor\ncreateFromParallel id r1 r2 = Resistor id (v1 * v2 / (v1 + v2)) (Parallel r1 r2)\nwhere (v1, v2) = (getValueInNanoOhm r1, getValueInNanoOhm r2)\ntype Inventory = [Resistor]\nresistor0 = Resistor 0 (10^9) OnePiece -- This is the resistor we start with, 1 ohm.\ninitialInventory :: Inventory\ninitialInventory = [resistor0] -- Initial resistor.\n-: (extendInventory createFromSeries [1..29]) -- Big resistors (> 10^9 nano ohm).\n-: ((createFromParallel 30 resistor0 resistor0):) -- First small resistor.\n-: (extendInventory createFromParallel [31..59]) -- Other small resistors (< 10^9 nano ohm).\nwhere\n-- For each of given ids, it takes last resistor from inventory, creates new one with that id from it and\n-- adds it to the end of that same inventory, repeating the process.\nextendInventory create ids inv = foldl' (\\i@(r:_) id -> (create id r r):i) inv ids\na -: f = f a\nconstruct :: Integer -> [(Int, Int, Int)]\nconstruct target = transformResult $ construct' initialInventory (fromIntegral target)\nwhere transformResult = map resistorToCommand . tail . reverse\n-- Given initial inventory and value of target resistor, it will return inventory in which\n-- last resistor has that value (within defined precision).\nconstruct' :: Inventory -> Double -> Inventory\nconstruct' inv@(lastResistor:_) target = if diff < precisionInNanoOhm\nthen inv -- We are done.\nelse construct' (newResistor:inv) target\nwhere\ndiff = target - (getValueInNanoOhm lastResistor)\nclosestResistor = maximumBy (\\r1 r2 -> compare (getValueInNanoOhm r1) (getValueInNanoOhm r2))\n$ filter (\\r -> getValueInNanoOhm r <= diff) inv\nnewResistor = createFromSeries (getResistorId lastResistor + 1) lastResistor closestResistor\n```\n\n### Haskell (v2, less expressive)\n\nI also refactored it to make it shorter but less expressive and therefore much more similar to C++ version. I prefer the first, more expressive version.\n\n```\nmodule ResistorFactory (construct) where\nimport Data.List (foldl', maximumBy)\ninitialInventory :: [(Int, Int, Int, Double)]\ninitialInventory = [(undefined, undefined, undefined, 10^9)] -- Initial resistor.\n-: (extendInventory (\\id v -> (id, id, 0, v * 2)) [0..28]) -- Big resistors (> 10^9 nano ohm).\n-: ((0, 0, 1, 10^9 / 2):) -: (extendInventory (\\id v -> (id, id, 1, v / 2)) [30..58]) -- Small resistors.\nwhere extendInventory create ids inv = foldl' (\\i@((_,_,_,v):_) id -> (create id v):i) inv ids\na -: f = f a\nconstruct :: Integer -> [(Int, Int, Int)]\nconstruct target = transformResult $ construct' initialInventory (fromIntegral target)\nwhere transformResult = map (\\(id1, id2, c, v) -> (id1, id2, c)) . tail . reverse\nconstruct' :: [(Int, Int, Int, Double)] -> Double -> [(Int, Int, Int, Double)]\nconstruct' inv@(lastRes:_) target = if diff < 1 then inv else construct' (newRes:inv) target\nwhere lenInv = length inv\ndiff = target - (value lastRes)\n(bestResId, bestRes) = maximumBy (\\(_, r1) (_, r2) -> compare (value r1) (value r2))\n$ filter (\\(_, r) -> value r <= diff) $ zip [lenInv - 1, lenInv - 2 .. 0] inv\nnewRes = (lenInv - 1, bestResId, 0, value lastRes + value bestRes)\nvalue (_,_,_,v) = v\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3nBIhGZw5ZXrZFWFXCB6u4","type":"Entry","createdAt":"2020-04-20T12:42:13.015Z","updatedAt":"2020-04-20T12:42:13.015Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Martinsos","tcHandle":"Martinsos"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-742-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7By8AXrUBzgLzHfyf9vVQQ","type":"Entry","createdAt":"2020-04-20T12:42:13.126Z","updatedAt":"2026-03-01T18:48:17.081Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 743","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java"],"creationDate":"2018-12-11T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 743 Editorials\n\n## PlayingWithPlanks - Div2 Easy\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14664)\n\nThe intended solution for this problem is simple -- test whether C(pieces+1, 2) is at most __plankLength__ or not. If it is bigger, return “impossible”, and otherwise return “possible”.\n\nWe now sketch why this approach is correct.\n\nObserve that if C(__pieces__+1, 2) ```>``` plankLength then we can not construct a valid solution. That is, even if all the assigned lengths are the smallest possible (the i-th piece having length i), their sum is C(__pieces__+1, 2).\n\nOn the other hand, if C(__pieces__+1, 2) ```<=``` plankLength, we can set lengths for first __pieces__-1 pieces to be from 1 through pieces-1, and the last piece to have length plankLength-C(__pieces__, 2) ```>=``` __pieces__.\n\nCode in Java:\n\n```\npublic String canItBeDone(int plankLength, int pieces) {\n\nif (pieces * (pieces + 1) / 2 <= plankLength)\n\nreturn \"possible\";\n\nreturn \"impossible\";\n\n}\n```\n\n## FriendlyRooks - Div2 Medium\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14205)\n\nThis task is a graph theory problem. Namely, consider the graph in which the vertex set consists of the rooks. Two vertices, i.e., two rooks, are connected by an edge iff for those two rooks all the three conditions are satisfied (the rooks are in the same row or in the same column, and there are no other rooks between them).\n\nIt is not hard to see that in this graph all the rooks that are in one connected component have to be of the same color. To see that, assume that two rooks in the same component have different colors and consider a shortest path between differently colored rooks. On this shortest path there exists an edge whose endpoints have different colors, which violates friendly coloring.\n\nSimilarly, if two rooks are not in the same component, then they can be colored by different colors.\n\nNow this tasks comes down to building such graph. The final output is the number of connected components that this graph contains.\n\nTo count the number of connected components one can simply run DFS or BFS and that would be more than sufficient to solve this problem in time.  \n\nNote: Observe that out of those three conditions, the third condition (the one that says that there should be no rooks between two rooks attacking each other) also can be omitted and this task would not get changed. So, for the sake of easier implementation we can as well just ignore this constraint.\n\nCode in Java:\n```\n\nprivate int[][] vec = undefined;\n\nprivate int n, m;\n\nprivate boolean[][] done;\n\nprivate boolean possible(int i, int j) {\n\nreturn i > -1 && j > -1 && i < n && j < m;\n\n}\n\nprivate String[] board;\n\nprivate void mark(int i, int j) {\n\ndone[i][j] = true;\n\nfor (int k = 0; k < 4; k++) {\n\nint ni = i;\n\nint nj = j;\n\nfor (int t = 0; t < Math.max(n, m); t++) {\n\nni += vec[k][0];\n\nnj += vec[k][1];\n\nif (possible(ni, nj) && board[ni].charAt(nj) == 'R' && !done[ni][nj]) {\n\nmark(ni, nj);\n\nBreak;\n\n}\n\n}\n\n}\n\n}\n\npublic int getMinFriendlyColoring(String[] board) {\n\nthis.board = board;\n\nn = board.length;\n\nm = board[0].length();\n\ndone = new boolean[n][m];\n\nfor (int i = 0; i < n; i++)\n\nArrays.fill(done[i], false);\n\nint ret = 0;\n\nfor (int i = 0; i < n; i++)\n\nfor (int j = 0; j < m; j++)\n\nif (board[i].charAt(j) == 'R' && !done[i][j]) {\n\nret++;\n\nmark(i, j);\n\n}\n\nreturn ret;\n\n}\n```\n\n## MaximizingGCD - Div2 Hard and Div1 Easy\n[Problem Details\n](https://archive.topcoder.com/ProblemStatement/pm/15211)\n\nWe reduce this task to one that for a given g decides whether there is a pairing C such that each number of C is divisible by g. This question can be solved as follows.\n\n__Testing whether g divides each number of some pairing:__\n\nFor a given g, compute A[i]%g for each i. Then, the number of i's such that A[i]%g == 0 has to be even. If g is even, then the number of i's such that A[i]%g == g/2 has to be even as well. For all the other modulos of g, the number of i's and the number of j's such that A[i]%g == k and A[j]%g == g-k has to be the same.\n\nSo, we now know how to decide whether there exists a pairing that certifies that the output to the problem is at least g. But how to find all the relevant values of g for which we should run the above procedure? One choice is to try all the values 1 through 2 * 10^9 in place of g, but that would be too slow. Next we discuss how to select relevant but small number of candidates for g.\n\n__A small number of relevant g’s:__\n\nObserve that A[0] has to be paired with some element of A. So, the final output has to divide A[0]+A[i] for some i. In our solution, for each of the divisors d of A[0]+A[i] we ask whether there exists a pairing as described above (for g = d). Luckly, the number of positive divisors of an integer X is at most 2 * sqrt(X).\n\nIn our case, that is at most 2 * sqrt(2 * 10^9) many divisors of A[0]+A[i], for any fixed i. Since there are at most 30 such candidates A[0]+A[i], the total number of divisors of interest is at most 30 * 2 * sqrt(2 * 10^9). For each of those divisors we invoke the procedure described above. The largest of those candidates for which the procedure above reports that there exists the corresponding pairing is the output of the solution.\n\nCode in Java:\n\n```\nprivate ArrayList <Integer> candidates;\n\npublic int maximumGCDPairing(int[] A) {\n\nint n = A.length;\n\ncandidates = new ArrayList < Integer > ();\n\nfor (int i = 1; i < n; i++) {\n\nint val = A[0] + A[i];\n\nint d = 1;\n\nwhile (d * d <= val) {\n\nif (val % d == 0) {\n\ncandidates.add(d);\n\ncandidates.add(val / d);\n\n}\n\nd++;\n\n}\n\n}\n\nint ret = -1;\n\nfor (Integer candidate: candidates) {\n\nif (candidate < ret) Continue; ArrayList < Integer > rems = new ArrayList < Integer > ();\n\nint cntZero = 0, cntHalf = 0;\n\nfor (int val: A) {\n\nif (val % candidate == 0)\n\ncntZero++;\n\nelse if (2 * (val % candidate) == candidate)\n\ncntHalf++;\n\nelse\n\nrems.add(val % candidate);\n\n}\n\nif (cntZero % 2 == 0 && cntHalf % 2 == 0) {\n\n// at this points, it holds rems.size() % 2 == 0\n\nCollections.sort(rems);\n\nboolean OK = true;\n\nfor (int i = 0; i < rems.size() / 2; i++)\n\nif (rems.get(i) + rems.get(rems.size() - i - 1) != candidate) {\n\nOK = false;\n\nbreak;\n\n}\n\nif (OK)\n\nret = candidate;\n\n}\n\n}\n\nreturn ret;\n\n}\n```\n\n## ExpectedSum - Div1 Medium\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15233)\n\nWe solve this problem by using dynamic programming. We define dp state by the triples (idx, B, L) with the following meaning\n\ndp[idx][B][L] = the solution to the problem where:\n\n1. The signs for indices 0 … idx-1 are already chosen (i.e., they are deterministic). Let F[i] be the value of the i-th index. Note that F[i] = sequence[i] or F[i] = -sequence[i].\n2. The largest sum of a contiguous subsequence of F[0 … idx-1] is B.\n3. The largest sum of a contiguous subsequence of F[0 … idx-1] that contain F[idx-1] is L.\n\nThe output to this problem is dp[0][0][0].\n\nLet n be the length of sequence. Then, as the boundary condition, we have\n\ndp[n][B][L] = B, for any L\n\nIt is also not hard to define the transitions from one to another state. Namely, from state (idx, B, L) there are two possible transitions.\n\n1. Either we set F[idx] = sequence[idx], which happens with probability 1-probMinus[idx]/100. Then we define L1 = L + sequence[idx] and transition to (idx + 1, max(B, L1), L1).\n2. Or, we set F[idx] = -sequence[idx], which happens with probability probMinus[idx]/100. Then we define L2 = L - sequence[idx] and transition to (idx + 1, B, max(L2, 0)).\n\nFinally, we have\n\ndp[idx][B][L] = (1-probMinus[idx]/100) * dp[idx + 1][max(B, L1)][L1] + probMinus[idx]/100 * dp[idx + 1][B][max(L2, 0)]\n\nNote that since each element ranges from 0 to 50 and it never pays off to have subarrays of negative value, there are at most 2501 possibilities for the second and the third dimension of dp. sequence is of length at most 50, so there are at most 50 possibilities for first dimension. Furthermore, from each state we make only two transitions. So, the overall running time of the solution above is 2 * 50 * 2501 * 2501, which runs in time. However, defining the full dp as described above would require too much memory.\n\nTo reduce the memory, we use a standard trick. Instead of storing all the 50 coordinates for the first dimension of dp at each step of the algorithm, we store only two consecutive ones. This is possible as to feel dp[idx] we only need information from dp[idx + 1]. This would be sufficient to cut the space by factor of 25 which is good enough to store this compressed dp table in memory.\n\n__Alternative explanation (courtesy of misof):__\n\nAnother point of view is as follows. We can read the input from left to right and run Kadane's algorithm in parallel on all possible sequences. After each step, the dp values simply represent the probabilities with which each state of the algorithm was reached. Here, state is the pair\n\n(best solution so far, best solution that ends at the end of what we processed).\n\nCode in C++:\n\n```\npublic double solve(int[] sequence, int[] probMinus) {\n\ndouble[][][] pp = new double[2][2501][2501];\n\nint N = sequence.length;\n\nint S = 0;\n\nfor (int n = 0; n < N; ++n) S += sequence[n];\n\nfor (int a = 0; a <= S; ++a)\n\nfor (int b = 0; b <= S; ++b)\n\npp[0][a][b] = 0;\n\npp[0][0][0] = 1;\n\nfor (int n = 0; n < N; ++n) {\n\nint old = n % 2, nju = 1 - old;\n\nfor (int r = 0; r <= S; ++r)\n\nfor (int s = 0; s <= S; ++s)\n\npp[nju][r][s] = 0;\n\nfor (int r = 0; r <= S; ++r)\n\nfor (int s = 0; s <= S; ++s)\n\nif (pp[old][r][s] > 0) {\n\ndouble pM = probMinus[n] / 100.;\n\nint nr1 = r + sequence[n];\n\nint ns1 = Math.max(s, nr1);\n\npp[nju][nr1][ns1] += (1 - pM) * pp[old][r][s];\n\nint nr2 = Math.max(0, r - sequence[n]);\n\nint ns2 = Math.max(s, nr2);\n\npp[nju][nr2][ns2] += pM * pp[old][r][s];\n\n  }\n\n}\n\ndouble answer = 0.;\n\nfor (int r = 0; r <= S; ++r)\n\nfor (int s = 0; s <= S; ++s)\n\nanswer += s * pp[N % 2][r][s];\n\nreturn answer;\n\n}\n```\n\n## PermuteTheArray - Div1 Hard\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14835)\n\nThis is a mix of graph theory and dynamic programming. We split the explanation in two parts. First, we describe how to test whether there exists any permutation satisfying the constraints. Then we show how to use this procedure to construct the lexicographically smallest one.\n\n__Verifying whether there exists any permutation:__\n\nMake a graph on n vertices, vertex i corresponding to the i-th index of the output. Two vertices u and v are connected iff there exists i such that x[i]==u and y[i]==v. If d[i]==1, then color the edge {u, v} in red and otherwise color {u, v} in blue.\n\nNow, for every component, we start from an arbitrary vertex and assign label 0 to it. Then we run DFS to assign labels to the other vertices as well. If two vertices are connected by the blue edge, then they should have the same labels; otherwise, one vertex should have label 0 and the other one label 1. This also implies that the same label within the same component denotes vertices of the same parity. If at any point we discover an edge that does not follow these rules, we conclude that there is no such array P.\n\nOnce we have all the 0-1 labels, for every component we count the number of labels being 0 and the number of labels being 1. For component comp, let those counts be cnt0[comp] and cnt1[comp]. Then, to each comp we should either assign cnt0[comp] even and cnt1[comp] odd numbers of val; or the other way around, i.e., we should assign cnt0[comp] odd and cnt1[comp] even numbers of val. Moreover, we should make these assignments for all the components simultaneously, and each element of val should be assigned to exactly one component. If this is not possible to achieve, then there is no required P.\n\nLet E be the number of even and O be the number of odd numbers of val. We perform a dynamic programming to check whether there is a way to assign E and O across the components as described. This is a standard DP problem that can be implemented to run in O(E * number_of_components) time.\n\nWe now describe how to reconstruct the lexicographically smallest P.\n\n__Reconstruction of lexicographically smallest P:__\n\nWe begin by explaining how to reconstruct P[0]. Let comp be the component containing vertex 0. Without loss of generality, assume that vertex 0 is labeled by 0 in comp. Let S_even be the smallest even and S_odd be the smallest odd number of val. (If S_even or S_odd does not exist, set its value to infinity.) Assume that S_even < S_odd. Then, we check whether there is a permutation P such that P[0]=S_even. To check that, we test whether we can assign cnt0 and cnt1 of the components other than comp so that the total number of even values and the total number of odd values of val in this assignments is E-cnt0[comp] and O-cnt1[comp], respectively. Here we are subtracting cnt0[comp] from E (and also cnt1[comp] from O) as we are assuming that all the vertices of comp having the same parity as vertex 0 can be assigned to have even values of val.\n\nIf there does not exist such assignment, then we set P[0]=S_odd. Note that to verify whether such assignment exists we can use the same method as we used in the first part.\n\nWhen we set the value of P[0] (that is S_even or S_odd), then we mark which vertices in comp should be set to even values and which to odd values. Notice that this is uniquely determined once we decide the parity of vertex 0. Note: at this point we only mark the parity of the remaining vertices in comp, but not assign any values to them yet.\n\nThe analogous approach is applied if S_odd ```<``` S_even.\n\nThe rest of the reconstruction of P is obtained in a similar way. Namely, assume that so far we have reconstructed P[0], …, P[idx - 1], and next we want to reconstruct P[idx]. If the parity of vertex idx was already decided, then we let P[idx] be the smallest unused value of val which has the same parity as vertex idx.\n\nIf the parity of vertex idx has not been decided yet, then we apply the same procedure over idx as we applied over vertex 0 above. We only have to take into account that some of the components has been processed already.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-743-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2NLGdCc3RDpIGCXsPCgmpd","type":"Entry","createdAt":"2020-04-20T12:42:14.467Z","updatedAt":"2026-03-01T18:18:17.287Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":61,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 744 Detailed","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Haskell"],"creationDate":"2018-12-20T00:00:00.000Z","readTime":"15 min","content":"# Single Round Match 744 Detailed Editorial\n\nSRM 744 was held on December 14th, 2018. The original editorial can be found here. I am currently learning Haskell so I decided to solve all tasks in it as well and then compare to my original C++ solutions.\n\n## ThreePartSplit - Div 2 Easy\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15235)\n\nShort problem statement: We are given a half open interval [a, d) which contains n = d - a elements. We need to divide it into three parts such each of them has at least n div 3 elements. We need to return the “middle” interval as [b, c) (so half open again).\n\nSolution: A simple and quick task that can be solved analytically, we just need to be careful not to mess up +-1 indices. There also multiple possible solutions, but maybe the most straightforward one (at least for me) was to assign n div 3 elements to the first two parts and then whatever is left to the third part.\n\nE.g. if we were given [0, 8) as a starting interval, that means we have numbers 0, 1, 2, 3, 4, 5, 6, 7. If we divided them as described above, we’d end up with intervals\n[0, 1], [2, 3], [4, 5, 6, 7] where we “crammed” all the extra stuff into the last interval.\nThere are also other valid solutions, e.g. we could’ve put 3 elements in each interval. So if you are using some editor plugin which compares against the example test cases (like Vimcoder) don’t worry if it reports some of your solutions as wrong.\n\n### C++\n```\nclass ThreePartSplit\n{\npublic:\nvector <int> split(int a, int d) {\nint minIntervalSize = (d - a) / 3;\nreturn {a + minIntervalSize, a + 2 * minIntervalSize};\n}\n};\n```\n\nIt was really cool for me to learn here how we can construct and return vector in a single line, very clean and readable.\n\n### Haskell\n```\nthreePartSplit :: Int -> Int -> (Int, Int)\nthreePartSplit a d = (a + minIntervalSize, a + 2 * minIntervalSize)\nwhere minIntervalSize = (d - a) `div` 3\n```\n\n### Comparison\n\n| Language   | Lines      | 100 runs    |\n| ---------- | ---------- | ----------  |\n| C++        | 8          | TBD         |\n| Haskell    | 3          | TBD         |\n\nAlthough Haskell solutions has a bit less lines than C++ one (mostly due to C++ class plumbing), I would say expresiveness-wise solutions are the same. Since it is O(1) analytical solution, we don’t need any looping or mapping or data structures, and with this concise way of creating a vector C++ solution is also very nice to read.\n\n## MagicNumbersAgain - Div 2 Medium\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15212)\n\nShort problem statement: Number is magic if it is a perfect square and if its digits alternate in a fashion of greater, smaller, greater, smaller, … (e.g. 1 3 2 17 4 2 3). Given [A, B] interval, find out how many magic numbers it contains.\n\nSolution: The naive solution would be to check for each number between A and B whether it is a magic number or not. However, due to the constraints (interval can have up to 10\n10 elements), we can see it would not be fast enough in all the possible cases.\nBut if we could be a bit smarter and somehow first find all the perfect squares in [A, B] and then only examine them instead of every number in the interval, would that be more performant? Sure it would, and since we will need to examine at most 105 squares (since 105 hits the upper range bound when squared), we can be sure it is going to be fast enough.\nFinding squares is also not a problem, we can just keep iterating over the roots and generate them until we go over the upper range bound.\n\nC++\n```\nclass MagicNumbersAgain\n{\npublic:\nbool isMagic(long long num) {\n// Obtain digits of a number.\nvector<int> digits;\nwhile (num > 0) {\ndigits.push_back(num % 10);\nnum /= 10;\n}\nreverse(digits.begin(), digits.end());\n// Perform the check on the digits.\nfor (int i = 1; i < digits.size(); i++) {\nif (i % 2 == 1) {\nif (digits[i] <= digits[i - 1]) return false;\n} else {\nif (digits[i] >= digits[i - 1]) return false;\n}\n}\nreturn true;\n}\nint count(long long A, long long B) {\n// Find all squares in [1, B].\nvector<long long> allSquares;\nfor (long long root = 1; root * root <= B; root++) {\nallSquares.push_back(root * root);\n}\n// Check for every square if in [A, B] and magic.\nint magicCount = 0;\nfor (int i = 0; i < allSquares.size(); i++) {\nlong long square = allSquares[i];\nif (square >= A && square <= B && isMagic(square)) magicCount++;\n}\nreturn magicCount;\n}\n};\n```\n\nA cool trick I learnt here is to generate all the squares from 1 up to B (or even up to the upper limit) and then later just check if it is in the required range. This frees us of doing the work of figuring out what is the first square in the range. Theoretically speaking it is not optimal since we are doing extra work, but here we can afford it and it keeps the code cleaner and less error-prone.\n\nUnfortunately I haven’t used this trick during the competition and made a mistake in just a situation described above (finding first square >= A) and my solution failed. So it is a good lesson for the future.\n\n### Haskell\n```\ncount :: Int -> Int -> Int\ncount a b = length $ filter isMagic $ squares a b\nsquares a b = takeWhile (<=b) $ dropWhile (<a) $ map (^2) [1..]\ndigits :: Int -> [Int]\ndigits 0 = []\ndigits num = digits (num `div` 10) ++ [num `mod` 10]\nisMagic :: Int -> Bool\nisMagic num = and $ map check triplets\nwhere\ndigs = digits num\n-- Produces (digit, prevDigit, index) triplets.\ntriplets = zip3 (drop 1 digs) digs [1..]\n-- Checks whether greater, smaller progression holds.\ncheck (dig, prevDig, idx)\n| idx `mod` 2 == 1 = dig > prevDig\n| otherwise = dig < prevDig\n```\n\n### Comparison\n| Language   | Lines      | 100 runs    |\n| ---------- | ---------- | ----------  |\n| C++        | 40          | TBD         |\n| Haskell    | 19          | TBD         |\n\nI really enjoyed writing this Haskell solution - I love how concise is the count function and how cleanly it breaks the problem into the subproblems that can be addressed (and tested) separately. I especially like squares function - how it starts with an infinite list and then we just “trim” it from the both sides until we get the desired result. This way of thinking makes it much easier for me to reason and thus much harder to introduce “off-1” type of bugs.\n\nWhat I find as most different compared to C++ solution is the situation where we have to check the digits, and compare each digit with the previous digit. Since we don’t do looping as in C++ we have to in advance construct all the “checks” with all the information needed.\n\n## ModularQuadrant - Div 2 Hard\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15236)\n\nShort problem statement: We are given an infinite, zero-indexed square grid. Each cell contains\nmax(row, column) mod 3 value. Given a rectangle in that grid, return the sum of its cells.\nSolution: The naive solution would be to go over all the cells in the given rectangle, calculate the values and sum it all together. However, since both width and height of the rectangle can be up to 109, it would be way to slow (we’d need to traverse over 1018 cells in the worst case).\nSo we need to be smarter and somehow use the properties of this grid to our advantage. Let’s examine the portion of the grid of size 10 x 10:\n\n![SRM 744 1](//images.ctfassets.net/piwi0eufbb2g/76BBGSIjjbKVLfqsf21f0Y/99ea7a7d1cfe10c18dae1c6e0771efc4/SRM_744_1.webp)\n\nI emphasized the diagonal and the red box is an example of rectangle for which we want to calculate the sum of its cells.\nWe can notice several things here:\n\n- 0 1 2 pattern repeating itself due to mod 3\n- The grid is symmetrical in respect to the diagonal (i-th row == i-th column)\n\nMy first approach was to calculate sum of each row separately and then sum that. I could calculate the sum of row in O(1) (observe the patten in a row - number is repeated until the diagonal and then starts cycling), but we still have 109 rows so that was too slow (one test case that took ~6s kept failing).\n\nSo we need to be even smarter than that - if calculating a row in O(1) is possible, is there also some kind of a rectangle whose sum we could calculate in O(1)?\nIf we could calculate sum of any rectangle that has upper left corner in 0, 0 fast enough, that would be great, because then we use that to calculate sum of any rectangle in the following way:\n\n```\ncalcRectSum(r1, r2, c1, c2) = calcRect00Sum(r2, c2) - calcRect00Sum(r2, c1 - 1) - calcRect00Sum(r1 - 1, c2) + calcRect00Sum(r1 - 1, c1 - 1)\n```\n\n![SRM 744 2](//images.ctfassets.net/piwi0eufbb2g/1U5GGGZZdAQAXUiNFpfFvy/a16885d32d2a09cb908b76ac2c9354c9/SRM_744_2.webp)\n\nThis image should also illustrate what is going on in the formula above (I apologize for the colored mess). If we want to calculate sum of the red box (in the first image) we start with a big purple rectangle and then from it substract the green and blue one. We can see the only thing that is left is what was original a red rectangle. Also, as blue and green rectangles intersect we’ve subtracted that part twice, so we have to add it once to fix that.\n\nThat’s it, we’ve managed to express the area of any rectangle with only the rectangles that start in the 0, 0, upper left corner. So now we only have to find out how to efficiently calculate sum of such a rectangle (calcRect00Sum method from above).\n\nIf we look at such a rectangle, we can divide it into two parts - square starting at (0, 0) (green) and the rest of it (orange).\n\n![SRM 744 3](//images.ctfassets.net/piwi0eufbb2g/4bbD5wGl6P1P48L7aglJd5/f4771a7132ead914fe98c51605dcfe7a/SRM_744_3.webp)\n\nCalculating a square sum - we can see that numbers are progressing in amount as odd numbers,\n1, 3, 5, 7, 9, ... and sum like that we can calculate in O(1) so we can use that. Let’s take a look at a bit bigger example of a square starting at (0, 0):\n\n![SRM 744 4](//images.ctfassets.net/piwi0eufbb2g/2b3MSZeqmAt9XSc1oh9gU3/34c5920e61e682c46eadfa07bcbdd6ad/SRM_744_4.webp)\n\nHere we can see that the square consists of “L-shaped” layers (colored in the image) that progress in the amount of cells as odd numbers (1, 3, 5, 7, ...), which is shown by numbers above the columns in the image.\n\nWe can also see that for a particular value (0, 1, 2) that the number of cells in the layer progresses by 6 (e.g. first we have 3 1s, than 9, than 15, …) - because of this period of 3, we have to “skip” two other numbers before coming to the next occurrence of the one that is observed.\nSo the sum of the square in the image above can be calculated as:\n0 * (1 + 7 + 13) + 1 * (3 + 9) + 2 * (5 + 11) = 44\n\nWe can generalize that to multiplying each value (0, 1, 2) with a sum of series that starts at a particular number, has a step of 6 and has number of elements that is equal to the number of “layers” this value has in the square.\n\nIf we can calculate the sum of this series in O(1) (and we can, check the seriesSum method in the code below), that means this whole calculation is done in O(1), which is exactly what we were aiming for.\n\nCalculating the rest - we see it has a repeating pattern in a row so we can use that to calculate the sum.\n\n### C++\n```\nclass ModularQuadrant\n{\npublic:\nlong long seriesSum(int start, int step, int length) {\nint end = start + (length - 1) * step;\nlong long sum = (long long)(start + end) * (length / 2);\nif (length % 2 == 1) sum += (start + end) / 2;\nreturn sum;\n}\nlong long calcSquare00Sum(int a) {\n// Number occurrences of 1.\nlong long onesOcc = a / 3 + (a % 3 == 2 ? 1 : 0);\n// Number occurrences of 2.\nlong long twosOcc = a / 3;\nlong long onesSum = seriesSum(3, 6, onesOcc);\nlong long twosSum = 2 * seriesSum(5, 6, twosOcc);\nreturn onesSum + twosSum;\n}\nlong long calcRectRightOfDiagonalSum(int startCol, int length, int height) {\nlong long rowSum = (length / 3) * (long long)3;\n// Add remainder part.\nint currVal = startCol % 3;\nfor (int i = 0; i < (length % 3); i++) {\nrowSum += currVal;\ncurrVal = (currVal + 1) % 3;\n}\nreturn rowSum * height;\n}\nlong long calcRect00Sum(int r, int c) {\n// The grid is symmetrical so it is the same.\nif (r > c) return calcRect00Sum(c, r);\nreturn calcSquare00Sum(r + 1) + calcRectRightOfDiagonalSum(r + 1, c - r, r + 1);\n}\nlong long sum(int r1, int r2, int c1, int c2)\n{\nreturn calcRect00Sum(r2, c2) - calcRect00Sum(r2, c1 - 1) - calcRect00Sum(r1 - 1, c2)\n+ calcRect00Sum(r1 - 1, c1 - 1);\n}\n};\n```\n\n### Haskell\n```\nseriesSum :: Int -> Int -> Int -> Int\nseriesSum start step length = (start + end) * (length `div` 2) + middleIfOdd\nwhere\nend = start + (length - 1) * step\n-- If there is odd number of elements, we have to add a middle element.\nmiddleIfOdd = if length `mod` 2 == 1 then (start + end) `div` 2 else 0\ncalcSquare00Sum :: Int -> Int\ncalcSquare00Sum a = (seriesSum 3 6 onesOcc) + 2 * (seriesSum 5 6 twosOcc)\nwhere\nonesOcc = a `div` 3 + if a `mod` 3 == 2 then 1 else 0\ntwosOcc = a `div` 3\ncalcRectRightOfDiagonalSum startCol length height = rowSum * height\nwhere\nrowSum = (length `div` 3) * 3 + remains\nstartValue = startCol `mod` 3\nremains = sum $ map (\\r -> (startValue + (r-1)) `mod` 3)[1..(length `mod` 3)]\ncalcRect00Sum :: Int -> Int -> Int\ncalcRect00Sum r c\n| r > c = calcRect00Sum c r\n| otherwise = calcSquare00Sum (r + 1) + calcRectRightOfDiagonalSum (r + 1) (c - r) (r + 1)\nrectSum :: Int -> Int -> Int -> Int -> Int\nrectSum r1 r2 c1 c2 = totalRect - leftRect - topRect + intersectRect\nwhere\ntotalRect = calcRect00Sum r2 c2\nleftRect = calcRect00Sum r2 (c1 - 1)\ntopRect = calcRect00Sum (r1 - 1) c2\nintersectRect = calcRect00Sum (r1 -1) (c1 - 1)\n```\n\n### Comparison\n| Language   | Lines      | 100 runs    |\n| ---------- | ---------- | ----------  |\n| C++        | 52         | TBD         |\n| Haskell    | 31         | TBD         |\n\nImplementing Haskell solution was pretty straightforward to implement from the C++ solution, we already divided the problem nicely into functions so we could just implement them in Haskell.\nThe Haskell solution is naturally shorter due to more dense syntax, but the logic stayed pretty much the same. The final function in Haskell solution, rectSum, I had to rename because\nsum is a method that comes in Haskell’s standard library.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4cOs5oeBGycngtasBNTaoh","type":"Entry","createdAt":"2020-04-20T12:42:13.520Z","updatedAt":"2020-04-20T12:42:13.520Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Matija","tcHandle":"Matija"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-744-detailed-editorial/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5HV8m8eFK99EYISudKu4g1","type":"Entry","createdAt":"2020-04-20T12:42:13.119Z","updatedAt":"2026-02-25T14:48:45.813Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":57,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 744","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2018-12-14T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 744 Editorials\n\nThe match was held on December 14th. The problem set and editorials were prepared by __[boba5551](https://profiles.topcoder.com/boba5551)__.\n\n## Div2 Easy - ThreePartSplit\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15235)\n\nDefine k = (d-a) div 3. We set b = a + k and c = a + 2*k. From the construction of b and c, we have that [a,b) and [b,c) have length k each. Now, the only part left is to verify that interval [c,d) has length at least k. If it wouldn’t be the case, then the sum of lengths of [a, b), [b, c) and [c, d) would be less than 3 * k. But this is a contradiction with the fact that d-a ```>=``` 3k.\n\n```\npublic int[] split(int a, int d) {\nint minLength = (d - a) / 3;\nreturn new int[] {\na + minLength, a + 2 * minLength\n};\n}\n```\n\n## Div2 Medium - MagicNumbersAgain\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15212)\n\nWe split the explanation in two parts: we explain how to verify the second condition, and then we discuss how to implement the first condition efficiently.\n\n__The second condition of being magic number:__\n\nWe assume that v is a square of an integer, and now we want to check whether it is magic or not. We can achieve that by the following simple procedure, that directly implements the statement of the condition:\n\n```\nprivate boolean isMagic(long v) {\nArrayList < Long > digs = new ArrayList < Long > ();\nwhile (v > 0) {\ndigs.add(v % 10);\nv /= 10;\n}\nboolean OK = true;\nboolean odd = true;\nfor (int i = digs.size() - 1; i > 0; i--) {\nif (odd && digs.get(i) >= digs.get(i - 1))\nOK = false;\nif (!odd && digs.get(i) <= digs.get(i - 1))\nOK = false;\nodd ^= true;\n}\nreturn OK;\n}\n```\n\nImplementing the first condition efficiently for all the numbers in [A,B]:\n\nOur next goal is to run the above procedure isMagic on all the squares between __A__ and __B__. Since __A__ and __B__ can be as big as 10^10, it would be too slow to test each of the number from that interval whether it is a square or not. However, if for each Y that “makes sense” we test whether Y^2 is between __A__ and __B__, then we obtain significantly more efficient solution. Namely, if v is between __A__ and __B__ and v=Y*Y, then Y is at most 10^5. So, we iterate over all such values of Y, and whenever Y*Y is between __A__ and __B__ we invoke the procedure above. The code in Java follows:\n\n```\npublic int count(long A, long B) {\nint ret = 0;\nfor (long v = 1; v * v <= B; v++) if (v * v >= A && isMagic(v * v))\nret++;\nreturn ret;\n}\n```\n\n## Div2 Hard and Div1 Easy - ModularQuadrant\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15236)\n\nLet cnt(r,c) be a procedure that calculates the sum of rectangle [0,r] x [0,c]. Then, the final output is cnt(__r2__+1,__c2__+1) - cnt(__r1__,__c2__+1) - cnt(__r2__+1,__c1__) + cnt(__r1__,__c1__)\n\nCalculating the sum of rectangle [0,r] x [0,c]:\n\nWithout loss of generality, assume that r ```<``` c (as the grid is symmetric with respect to r=c). Next, we divide the rectangle [0, r] x [0, c] into two parts: square in the corner r x r and vertical bars to the right of this square.\n\nTo handle the square, we observe that they have very regular form. This is how the first 6x6 part of infinite grid looks like:\n\n2 2 2 2 2 2\n\n1 1 1 1 1 2\n\n0 0 0 0 1 2\n\n2 2 2 0 1 2\n\n1 1 2 0 1 2\n\n0 1 2 0 1 2\n\nOn the other hand, each bar to the right of the square consists of the same number. And those numbers are a subset of the infinite sequences 0, 1, 2 (repeat).\n\nSo, we separately handle the square and separately handle the bars. Formulas for each of those cases can be derived relatively easily. One such implementation is provided below.\n\nCode in C++ (courtesy of [majk](https://profiles.topcoder.com/majk)):\n\n```\nll cnt(int r, int c) {\nif (r > c) swap(r, c);\nll x = r - r % 3;\nll y = c - x;\ny -= y % 3;\nreturn 4 * x / 3 + x * x + (c % 3 == 2) * r + y * r + (x + 1) * (r % 3 == 2);\n}\nll sum(int r1, int r2, int c1, int c2) {\nreturn cnt(r2 + 1, c2 + 1) - cnt(r1, c2 + 1) - cnt(r2 + 1, c1) + cnt(r1, c1);\n}\n\n```\n\n## Div1 Medium - UniformingMatrix\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15210)\n\nThe main point here is to observe that flipping rows and columns is almost independent. Namely, consider an operation applied on __M__(i, j). The problem statement says that we flip the i-th row by not changing M(i, j), and then we flip the j-th column by not changing __M__(i, j). But exactly the same outcome would be achieved by flipping the entire row i (including __M__(i, j)), and then flipping the entire column j. This observations allows us to perform row and column flips almost separately.\n\nThe second observation that we make is that applying the entire-row flipping operation on a row for even number of times does not change that row. Also, flipping odd many times the entire row results in the same state of the row as by applying the operation only once. The same holds for entire-column operations. Hence, what matters is the parity of the number of times an operations is applied on a row/column.\n\nFinally, observe that the order in which the entire-row and entire-column operations are performed does not matter.\n\nSo, we apply entire-row operations first. Consider separately the cases in which the first row is flipped zero times (i.e., an even number of times) and flipped once (i.e., an odd number of times). After flipping the entire first row for b many times (where b equals 0 or 1), and before applying entire-column operations, perform entire-row operations on each of the other rows so that they are the same as the first row. If it is not possible to achieve, than our choice of flipping the first row b many times does not lead to all-ones matrix.\n\nOnce all the rows are the same, we apply the column operations. Applying a column operation is now trivial -- the j-column should be entirely flipped iff M(0, j) equals ‘0’.\n\nAt the end, we check whether the parity of the applied entire-row and entire-column operations is the same. If it is the same, the output is “possible”, and otherwise our choice of b does not lead to all-ones matrix.\n\nIf no choice of b leads to all-ones matrix, output “impossible”.\n\nCode in Java:\n\n```\nprivate String[] M;\nprivate int n, m;\nprivate void flipRow(int i) {\nchar[] newRow = new char[m];\nfor (int j = 0; j < m; j++)\nif (M[i].charAt(j) == '0')\nnewRow[j] = '1';\nelse\nnewRow[j] = '0';\nM[i] = new String(newRow);\n}\npublic String isPossible(String[] MM) {\nM = MM;\nn = M.length;\nm = M[0].length();\nString[] origM = new String[n];\nfor (int i = 0; i < n; i++)\norigM[i] = M[i];\nfor (int changes = 0; changes < 2; changes++) {\nint cntRow = changes;\nfor (int i = 1; i < n; i++) {\nif (M[0].charAt(0) == M[i].charAt(0))\ncontinue;\ncntRow++;\nflipRow(i);\n}\nint cntCol = 0;\nboolean OK = true;\nfor (int j = 0; j < m; j++) {\nif (M[0].charAt(j) == '0')\ncntCol++;\nfor (int i = 1; i < n; i++)\nif (M[0].charAt(j) != M[i].charAt(j))\nOK = false;\n}\ncntRow %= 2;\ncntCol %= 2;\nif (OK && cntRow == cntCol)\nreturn \"possible\";\nfor (int i = 0; i < n; i++)\nM[i] = origM[i];\nflipRow(0);\n}\nreturn \"impossible\";\n}\n```\n\n## Div1 Hard - CoverTreePaths\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14587)\n\nThere are two natural approaches for this problem -- satisfy demands in top-down fashion (i.e., starting from the root and moving towards the leaves), and satisfy demands in bottom-up fashion (i.e., starting from the leaves and moving towards the root). The official solution takes the bottom-up approach, that we describe next.\n\nInitially, we set v[i] = 0 for each vertex i, and update v in n steps. After the k-th step we maintain the following invariant: if v[i] = 0 for each i ```<``` __n__ - k, then the remaining entries of v are set so to minimize the cost and satisfy demands of the vertices i ```>=``` __n__ - k.\n\nAssume that we have executed k steps, and now we are executing the (k+1)-step. Let i = n - (k + 1).\n\nIf i is a leaf, then we set v[i] = __d__[i]. (This value might be updated later.)\n\nIf i is a non-leaf, in this step we will eventually have to set v[i] >= d[i], as the only way to satisfy the demand of i is to let v[i] being at least __d__[i]. Also, the descendants of i have already satisfied their demands even if v[i] equals 0. So, when we increase v[i], it means that some of v[j], where j is a descendant of i, could potentially be reduced. But v[j] of which descendants?\n\nWe repeat the following:\n\nLet S_i be the set of all descendants of i such that for each descendant w all the values of the vertices on the path between w and i (excluding w and i) is zero.\n\n1. If v[i] >= d[i] and sum_{w in S_i} c[w] < c[i]\n2. Update v[w] = v[w] - 1 for each w in S_i\n3. Update v[i] = v[i] + 1.\n4. break\n\nClearly, this process does maintain the invariant that the demands of all the vertices [i+1, n-1] are satisfied. Furthermore, the demand of vertex i is satisfied as well, as the updates will continue as long as v[i] < __d__[i]. But, is the choice of S_i the best one?\n\nNamely, consider the following example. Vertex i has a direct child 2, and 2 has two direct children 0 and 1. Assume that each v[0], v[1] and v[2] is at least 1. When we increase v[i] by 1, instead of decreasing v[2] by 1 we could have as well decreased v[0] and v[1] by 1 without violating the demands. But, would decreasing v[0] and v[1] reduce the cost even further than decreasing only v[2]? If it would reduce the cost even further, then it would mean that c[0]+c[1] > c[2]. But now this violates our invariant that after the step when we processed vertex 2 the values were set optimally assuming that the unprocessed vertices have value 0. Namely, if c[0]+c[1]```>```c[2], an optimal solution should not keep both v[0] and v[1] positive as it pays off to increase v[2] by 1 and decrease each v[0] and v[1] by 1.\n\nIt is easy to generalize this argument in the following way. If we assume that in Step 1 it is better to choose a set of descendants {x_1, …, x_r} of w instead of w in S_i (and all the vertices x have positive v[x]), than it would imply that c[x_1]+...+c[x_r] > c[w]. But, again as before, this would contradict the invariant that when processing w the values in v are set optimally. (Notice that after a vertex i is processed and its value v[i] is set, in the further steps it never increases.)\n\nTo implement these steps efficiently, the official solution maintains a heap for each S_i together with the total cost of all the vertices that are in S_i. The heap for S_i is ordered by the current values of the vertices. In that way, after we update v[i] and need to reduce v[w] of w in S_i, it is easy to find the vertex in S_i that has the smallest value. Once v[w] get reduced to zero due to the updates, then we merge S_i and S_w. To do that efficiently, we should make sure to merge smaller to the larger heap.\nThe full implementation in Java is provided below.\n\n``` \nprivate class Pair implements Comparable {\npublic long first;\npublic int second;\nPair(long first, int second) {\nthis.first = first;\nthis.second = second;\n}\npublic int compareTo(Pair pair) {\nif (this.first < pair.first) return -1; else if (this.first > pair.first)\nreturn 1;\nelse {\nif (this.second < pair.second) return -1; else if (this.second > pair.second)\nreturn 1;\nreturn 0;\n}\n}\n}\nprivate ArrayList children[];\nprivate PriorityQueue heap[];\nprivate long[] sumOfCosts;\nprivate long[] valueToSubtract;\nprivate long[] value;\nprivate long totalCost;\nprivate long[] d, c, p;\nprivate void mergeFirstToSecondHeap(int f, int s) {\nwhile (heap[f].size() > 0) {\nPair p = heap[f].poll();\np.first = p.first - valueToSubtract[f] + valueToSubtract[s];\nheap[s].add(p);\n}\n}\npublic long minimumCost(int n, int[] op, int[] od, int[] oc, int[] params){\nd = new long[n];\nc = new long[n];\np = new long[n];\nfor (int i = 0; i < od.length; i++) {\nd[i] = od[i];\nc[i] = oc[i];\nif (i < op.length)\np[i] = op[i];\n}\nint t = od.length;\nfor (int i = t - 1; i <= n - 2; i++)\np[i] = (params[0] * p[i-1] + params[1]) % (i+1);\nfor (int i = t; i <= n - 1; i++)\nd[i] = 1 + ((params[2] * d[i-1] + params[3]) % params[4]);\nfor (int i = t; i <= n - 1; i++)\nc[i] = 1 + ((params[5] * c[i-1] + params[6]) % params[7]);\nchildren = new ArrayList[n];\nfor (int i = 0; i < n; i++)\nchildren[i] = new ArrayList();\nfor (int i = 0; i < n - 1; i++) children[(int)p[i]].add(i + 1); totalCost = 0; heap = new PriorityQueue[n]; sumOfCosts = new long[n]; valueToSubtract = new long[n]; value = new long[n]; for (int v = n - 1; v > -1; v--) {\nsumOfCosts[v] = 0;\nvalue[v] = 0;\nheap[v] = new PriorityQueue();\nfor (Integer child : children[v]) {\nsumOfCosts[v] += c[child];\nheap[v].add(new Pair(value[child], child));\n}\nlong increaseBy;\nwhile (true) {\nif (heap[v].size() == 0) {\nif (d[v] <= value[v])\nbreak;\nincreaseBy = d[v] - value[v];\n}\nelse if (c[v] < sumOfCosts[v])\nincreaseBy = heap[v].peek().first - valueToSubtract[v];\nelse if (value[v] < d[v])\nincreaseBy = Math.min(d[v] - value[v], heap[v].peek().first - valueToSubtract[v]);\nelse\nbreak;\ntotalCost += increaseBy * c[v];\ntotalCost -= increaseBy * sumOfCosts[v];\nvalue[v] += increaseBy;\nvalueToSubtract[v] += increaseBy;\nArrayList toMerge = new ArrayList();\nwhile (heap[v].size() > 0 && heap[v].peek().first == valueToSubtract[v]) {\nPair p = heap[v].poll();\ntoMerge.add(p);\nsumOfCosts[v] -= c[p.second];\n}\n// Merge the heaps.\nfor (Pair p : toMerge) {\nint u = p.second;\nsumOfCosts[v] += sumOfCosts[u];\nif (heap[u].size() <= heap[v].size())\nmergeFirstToSecondHeap(u, v);\nelse {\nmergeFirstToSecondHeap(v, u);\nheap[v] = heap[u];\nvalueToSubtract[v] = valueToSubtract[u];\n}\n}\n}\n}\nreturn totalCost;\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-744-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"12j1nM0nxCztTLnCzJActT","type":"Entry","createdAt":"2020-04-20T12:41:36.583Z","updatedAt":"2026-02-23T23:28:13.251Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":53,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 713","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java"],"creationDate":"2017-05-04T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 713 Editorials\n\nWe now have some of the SRM 713 Editorials published. We are awaiting or reviewing the submissions for some of them. If you would like to contribute an editorial for those problems you may do so by submitting to their respective challenge.\n\nThanks to __[stni](https://profiles.topcoder.com/stni)__, __[pakhandi](https://profiles.topcoder.com/pakhandi)__, __[marcose18](https://profiles.topcoder.com/marcose18)__ , __[GoogleHireMe](https://profiles.topcoder.com/GoogleHireMe)__ for contributing to the SRM 713 editorials.\n\n## Single Round Match 713 Round 1 - Division II, Level One SymmetryDetection by pakhandi\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14574)\n\nThe problem can be solved by traversing the matrix and checking for symmetry in a greedy / ad-hoc way.\nLet us first solve the problem for the vertical-symmetry.\nWe want to check if, for every cell [i][j], if it is equal to [i][cols - j - 1]. In this case we don't need to visit every cell. We only need to check this condition for cells in all the rows but only half the columns. The proof of this optimization is very trivial and is left as an exercise for the reader.\nFor the horizontal-symmetry, we can use the same method for all the columns but half the rows, comparing [i][j] with [rows - i - 1][j].\nThe method is very similar to what is used for checking palindrome.\nPlease check the implementation below for details.\n```\nclass SymmetryDetection\n{\npublic:\nstring detect(vector board)\n{\nbool h = 1, v = 1;\nint rows = board.size();\nint cols = board[0].size();\nfor(int i = 0; i < rows; i++)\n{\nfor(int j = 0; j <= cols / 2; j++)\n{\nif(board[i][j] != board[i][cols - j - 1])\n{\nv = 0;\n}\n}\n}\nfor(int i = 0; i <= rows / 2; i++)\n{\nfor(int j = 0; j < cols; j++)\n{\nif(board[i][j] != board[rows - i - 1][j])\n{\nh = 0;\n}\n}\n}\nif(h && v)\n{\nreturn \"Both\";\n}\nelse if(h)\n{\nreturn \"Horizontally symmetric\";\n}\nelse if(v)\n{\nreturn \"Vertically symmetric\";\n}\nelse\n{\nreturn \"Neither\";\n}\n}\n};\n```\n\n## Single Round Match 713 Round 1 - Division II, Level Two PowerEquationEasy by marcose18\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14573)\n\nIn this question we will iterate through all the values & it’s powers which are less than n.\nNow we will calculate answer for a number i & it’s powers in one go. Now for some power of i, let’s assume i ^ x we have to calculate all such values where (i ^ x) ^ c = (i ^ y) ^ d such that c, d & i ^ y ```<=``` n. Now clearly x, y ```<=``` maxpow where i ^ maxpow ```<=``` n while i ^ (maxpow + 1) > n.\n\nAlso (i ^ x) ^ c = (i ^ y) ^ d implies x * c = y * d. In short (x / y) = (d / c).\nSo for fixed values of x, y we have to find c & d such that it satisfies above equation while it is also ```<=``` n. So to find such c & d, reduce x & y to it’s lowest form by dividing both x & y by gcd(x, y).\n\nNow it’s easy to see that total possible values = n / max(tempx, tempy) where tempx & tempy are x / gcd & y / gcd respectively. Do the above for all values of i and add it to answer. One final thing to note here is if i ```>``` sqrt(n) then it contains no power that is less than n i.e i ^ x = i ^ y only for x = y = 1. So each of them will contribute n to the final answer and thus we will loop only upto sqrt(n) instead of n.\n\nBelow is the code of above explanation.\n\nHere HashSet is used to keep track of visited numbers and their powers.\n\n```\nimport java.util.*;\nimport java.util.regex.*;\nimport java.text.*;\nimport java.math.*;\npublic class PowerEquationEasy {\n// Calculating gcd of two numbers.\nstatic int gcd(int a, int b) {\nif (a < b) {\nint temp = a;\na = b;\nb = temp;\n}\nif (b == 0) return a;\nreturn gcd(b, a % b);\n}\npublic int count(int n) {\nlong ans = n * 1L * n;\nlong mod = (long) 1E9 + 7;\nans %= mod;\nHashSet set = new HashSet<>();\n// Iterate through all values but not those which are stored in the hashset which are nothing but powers of earlier values and we have calculated answers for them before.\nfor (int i = 2; i * i <= n; i++) {\nif (set.contains(i)) continue;\nint maxpow = 0;\nint temp = i;\nwhile (temp <= n) {\n++maxpow;\nset.add(temp);\ntemp *= i;\n}\n// Find the answer for all x & y such that (i ^ x) ^ c = (i ^ y) ^ d.\nfor (int x = 1; x <= maxpow; x++)\nfor (int y = 1; y <= maxpow; y++) { int g = gcd(x, y); int tempx = x / g, tempy = y / g; ans += n / Math.max(tempx, tempy); while (ans >= mod) ans -= mod;\n}\n}\n// All numbers greater than sqrt(n) will have no power that is less than n and for each of them there will be ‘n’ identities.\nans += (n - set.size() - 1) * 1L * n;\nans %= mod;\nreturn (int) ans;\n}\n}\n\n```\n\n## Single Round Match 713 Round 1 - Division II, Level Three DFSCountEasy by GoogleHireMe\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14589)\n\nIn this problem, you have to calculate number of different paths to traverse the graph using depth first search.\n\nFirst of all, let’s try to set the possible upper bound for the answer. There are exactly N! (n-factorial) permutations of numbers from 1 to N. All of those sequences will be valid when we have a complete graph.\n\nSo, the maximal possible answer can reach 13! = 6227020800, and this means that a brute force (trying all the possible paths) wouldn’t fit into time bounds.\nTo solve this problem, we can use dynamic programming.\n\nIn every dynamic programming problem you have to detect four things:\n\na) define a state\n\nb) find a way to split the problem into subproblems\n\nc) define the base state: the subproblem for which you know the solution immediately, without splitting it into subproblems.\n\nd) find a way to combine the subproblems’ solutions to get the solution of the main problem\n\nLet’s tackle this step by step:\n\na) Let’s define our problem’s state as a pair of <start_node, available_nodes>, where start_node is the node from which we start building the path, and available_nodes - set of nodes which are not yet visited. Then, to find the solution to the initial problem, we would have to sum up all solutions of subproblems with all possible start nodes when all nodes as available.\n\nLet’s consider the following example:\n\nnode 1 is not available (since it was visited before) and start_node is 2;\n\nState: start_node=2, available_nodes={3, 4, 5, 6, 7, 8, 9}\n\n![SRM 713 01](//images.ctfassets.net/piwi0eufbb2g/58njTIA86X7xrOJwQ6jxm6/74d7a28f0bb83dcf724314f6e7093c72/SRM_713_01.webp)\n\nb) To split the problem into subproblems, we can just try to extend our existing path and make a one DFS call to one of the available\n\nIn the example, we can go to the next possible subproblems (2 is no longer available, start_node highlighted with blue color):\n\n![SRM 713 02](//images.ctfassets.net/piwi0eufbb2g/4IqKOb0I6TwLznImQHS7xd/3514d5cf0322e1ff4dd4eebb914856d1/SRM_713_02.webp)\n\n![SRM713 03](//images.ctfassets.net/piwi0eufbb2g/3M0SDaqXEt130XTdR1KsdO/5a6c26820e5b2d27a40e598989d28ff2/SRM713_03.webp)\n\n![SRM713 04](//images.ctfassets.net/piwi0eufbb2g/1fPK75bmwibkinSgCGxJpm/c94195fa88f4f75de313bc7d664fe93e/SRM713_04.webp)\n\n![SRM713 05](//images.ctfassets.net/piwi0eufbb2g/5HIYpuCYGVYawo109HnX7p/352d7dc4a45c5c55d274f7617ffa73bf/SRM713_05.webp)\n\nc) The base state can be the state with only one available node - it means that there is nowhere else to go, and the answer is 1 (only that node, and that’s the end).\nd) Now, we have to find a way to combine the solutions to the subproblems. And this is the place where things get really interesting:\n\nThe first thing we should notice is that once we decided which child to go next, all other children that are connected (directly or via available nodes) will not be available once the dfs() will return, since they will be marked as used in one of the dfs()’s subcalls of the call on that child.\n\nFor instance, in the example above, when we call dfs for node 3 from the node 2, it will mark nodes 4, 5 and 6 as used. Thus, after the end of the call, we wouldn’t be able to call dfs for the node 6 from the node 2 anymore.\n\nLet’s call the subset of the “reachable” nodes as the component.\n\nIn the example above, once we consider node 2 as start_node and node 1 as unavailable, we will have to components: consisting of nodes {3, 4, 5, 6} and {7, 8, 9}.\nSince you can pick only one node per component to move to, the number of dfs() calls from the start_node equals to the number of components in that state.\n\nSince the components are independent from each other, the result for the given state will be the multiplication of number of paths for all components separately.\n\nAlso, because of the independance of those components (you cannot reach one from another), we can do those above mentioned dfs() calls in any order, that means that we have to multiply the result by K! (k-factorial) where K is the number of components for the current state.\nOne more thing we still have to consider - what if one component contains more than one neighbour of the start_node. Since we can “enter” the component only once (after that all nodes of the component will be marked as used), the number of different paths for the component will be the sum of those subproblems with different children as start_node.\n\nA few notes on the implementation: the recursive solution looks nice, however, to avoid solving the same subproblem multiple times, it’s important to implement this recursion with memoization of the answers for every state previously calculated. We can achieve this with map data structure.\n\nIn my solution I use breadth first search to find the components.\n\nAlso, I use the bitmask to represent available nodes instead of the set, since the number of the nodes is small, and bit operations are generally “cheaper” (in terms of performance) than the operations on the set. Here, 1 on the ith position of the binary representation of the mask variable means that the ith node is in available_nodes set.\n\nComplexity:\n\nLet n be equal to the number of nodes.\n\nIn the worst case, for every state (2^n * n) we will perform breadth first search ( O(n*n)) for every neighbor (n).\n\nThus O(2^n * n * n * n^2) = O( 2^n * n^4 )\n\nTo sum up, the solution will look like follows:\n```\n#include <string>\n#include <vector>\n#include <map>\n#include <queue>\nusing namespace std;\nclass DFSCountEasy {\nint n;\nvector<string> G;\nmap<pair<int, int>, long long> cache;\nlong long f(int mask, int v) {\n// Remove current node from the available nodes\nmask = mask & (~(1 << v));\nif (cache.count({mask, v})) {\n// The solution for this subproblem was calculated before\nreturn cache[{mask, v}];\n}\nmap<int, long long> components;\nfor (int i = 0; i < n; i++) {\nif (G[v][i] == 'Y' && (mask & (1 << i))) {\n// BFS for child i\nqueue<int> q;\nq.push(i);\n// Bitmask for the set of nodes included in the corresponding component\nint submask = 1 << i;\nwhile (!q.empty()) {\nint u = q.front();\nq.pop();\nfor (int j = 0; j < n; j++)\nif (mask & (1 << j)) {\nif (G[u][j] == 'Y' && !(submask & (1 << j))) {\nsubmask |= 1 << j;\nq.push(j);\n}\n}\n}\ncomponents[submask] += f(submask, i);\n}\n}\nlong long res = 1;\nfor (auto x : components) res *= x.second;\nfor (int i = 0; i < components.size(); i++) res *= i + 1;\nreturn cache[{mask, v}] = res;\n}\npublic:\nlong long count(vector<string> _G) {\nG = _G;\nn = G.size();\nlong long res = 0;\nfor (int i = 0; i < n; i++) res += f((1 << n) - 1, i);\nreturn res;\n}\n};\n```\n\n## Single Round Match 713 Round 1 - Division I, Level One PowerEquation by stni\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14573)\n\n If a=c, b=d, we have n*n identities.\nHere, 1^1=1^2=1^3=...=1^n,----(n-1)\n1^2=1^1=1^3=...=1^n,----(n-1)\n...\n1^n=1^1=1^2=...=1^(n-1) ----(n-1)\nFor a=1 and b=1,\nwe need to add another n*n-1.\nSo we already have n*(2*n-1) identities obviously.\nFor a != c:\nWithout loss of generality, we say ac.\nFor all integers not power of other integers p,\nlet a=p^i, c=p^j\nnumber of c we can choose from equals to\nnumber of powers of least common multiple(LCM) of a and c.\nj/gcd(i,j) is the min distance between powers of LCM,\nn/(j/gcd(i,j)) is the number of such identities in [1..n]\nmultiply 2 for symmetry of a-c, b-d\nComplexity is O(n)\n\n```\n#include<set>\nusing namespace std;\ntypedef long long ll;\nconst ll mod=1e9+7;\nll gcd(ll a,ll b){\nreturn a?gcd(b%a,a):b;\n}\nclass PowerEquation{\npublic:\nint count(int n0){\nll n=n0;\nset<ll>se; //all power bases\nll ans=n*(n*2-1)%mod;\nfor(ll p=2;p*p<=n;p++){\nif(se.count(p))\ncontinue; //we already calculated p's base\nll t=p;\nll k=0;//number of powers of t\nwhile(t<=n){\nse.insert(t);\nt*=p;\nk++;\n}\nfor(ll i=1;i<=k;i++){\nfor(ll j=i+1;j<=k;j++){\nans+=n/(j/gcd(i,j))*2;\nans%=mod;\n}\n}\n}\nreturn (int)ans;\n}\n};\n\n```\n## Single Round Match 713 Round 1 - Division I, Level Two DFSCount by stni\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14588)\n\nWe use an 15-bit integer to remember which nodes we visited during the dfs process. If we have visited the i-th node, we set the i-th bit to 1. If it is not visited, the i-th bit is set to 0. We need a dfs function with two parameters.\n\nThe parameters being an integer as the 15-bit integer and an integer which keeps the last visited node.\n\nIn dfs:\n\nIf all nodes connected to the last node are visited -there is only 1 way to do dfs which is \"to do nothing and return\".\n\nIf there is a node i connected to this node and not visited,  -we can append i to p.\n\nWe dfs with node i as last visited node, get the number of ways we can do dfs, and 15-bit visited nodes. We get the second integer which shows the nodes we visited from i. If we do the dfs again from last node with parameter visited being the newly returned visited integer.\n\nThe ways to do dfs from last node is to multiply these 2 returned values because 2 orders exist. Suppose nodes visited in the first dfs are n1, nodes visited in the second dfs are n2.\n\nWe can visit n1 then visit n2, so after i we append n1 then n2 to p.\n\nWe can also visit n2 then n1, so after i we append n2 then n1 to p.\n\nThey all start from last node, and n1 includes node i. If we have a set of nodes not visited and we visited node last, the number of ways we can do dfs is always the same. So we memoize that in a 2D vector to avoid repeated calculations. The first dimension is all 15-bit integer which stores the visited nodes, size 1<<n, The second dimension is 15, which is the last node we visited.\n\nWe have n nodes, each has n potential positions.\nComplexity is O(n^2)\n\n```\n#include<vector>\n#include<array>\n#include<string>\nusing namespace std;\ntypedef long long ll;\nvector<string>G;\nvector<array<pair<ll,ll>, 15>>mem;\nclass DFSCountEasy{\npublic:\npair<ll,ll> dfs(ll visited, ll last){\nif(mem[visited][last].second)return mem[visited][last];\npair<ll,ll> r(0,0);\nfor(int i=0;i<G.size();i++){\nif((last!=G.size()&&G[last][i]=='N')||(visited&(1ll<<i)))continue;\npair<ll,ll>t1=dfs(visited|(1<<i), i);\npair<ll,ll>t2=dfs(t1.second,last);\nr.first+=t1.first*t2.first;\nr.second=t1.second|t2.second;\n}\nif(r.second==0){\nr=make_pair(1, visited);\n}\nreturn mem[visited][last]=r;\n}\nll count(vectorG){\n::G=G;\nmem.clear();\nmem.resize(1<<G.size());\npair<ll,ll> r=dfs(0,G.size());\nreturn r.first;\n}\n};\n\n```\n\n## Single Round Match 713 Round 1 - Division I, Level Three CoinsQuery\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/14572)\n\nWe are awaiting the submission for the following editorial. If you would like to contribute an editorial for this problem you may do so by submitting to this challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-713-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2Za1IjpWC9KMeZYrWS1Zr0","type":"Entry","createdAt":"2020-04-20T12:42:12.823Z","updatedAt":"2026-02-17T00:02:49.691Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":46,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 738","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2018-09-30T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 738 Editorials\n\nThe round was held on 30th Sept, 2018. Thanks to [wild_hamster ](https://profiles.topcoder.com/wild_hamster)for the interesting problem set and editorials. Thanks to [Petr](https://profiles.topcoder.com/petr) for recording his screen during the round. Click here to see Petr's screencast of the round.\n\n## Div2Easy: DriveTheCarEasy\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15106)\n\nIncreasing speed by speed __i__ before the second moments __i__ leads to increase speed by speedi during S-momentsi+1 seconds. So for each pair speedi, momentsi we need to add __S-moments i+1__ * __speed__ __i__ to the answer.\nCode:\n\n```\npublic class DriveTheCarEasy {\npublic long calculateDistance(int S, int N, int[] speed_changes, int[] moments) {\nlong ans = 0;\nfor (int i = 0; i < N; i++)\nans += (long)(S - moments[i] + 1) * speed_changes[i];\nreturn ans;\n}\n```\n\nTime complexity O(N).\n\n## Div2Medium: EnergySource\n[Problem Details\n](https://archive.topcoder.com/ProblemStatement/pm/15107)\nThere can be at most 10^5 possible divisions under given constraints. We can generate all of them recursively. For each division, we can take every element not equal to 1 and try to split this element it into g > 1 new elements and go recursively to the new generated division if we didn't already visit it recursively. Doing it straightforward will not fit in TL, so there are possible ways to fit in TL:\n1. Precalculate all values from 1 to 90 inclusive.\n2. Remember not all the elements of the division, but for each distinct element, we can remember the only number of occurrences of it in a division.\n3. Precalculate divisors of each number from 1 to 90 and for each element in the division we can try to split it only in the number of divisors parts.\n\n```\nimport java.util.*;\npublic class EnergySource {\nlong ans1 = 0;\nlong ans2 = 0;\nint itr = 0;\nArrayList[] divisors = new ArrayList[105];\nArrayList g = new ArrayList();\nHashSet f = new HashSet();\nint[] get_idx = new int[105];\nint[] cur_divisors = new int[105];\nlong get() {\nint sz = g.size();\nlong ans = 0, mul = 1;\nfor (int i = sz-1; i>= 0; i--) {\nans += mul*(g.get(i)+1);\nmul *= (cur_divisors[sz-i-1]+2);\n}\nreturn ans;\n}\nvoid go() {\nitr++;\nif (f.contains(get())) {\nreturn;\n}\nf.add(get());\nans1++;\nlong cur = 1;\nfor (int i = 1; i < g.size(); i++) {\nfor (int j = 0; j < g.get(i); j++)\ncur *= cur_divisors[i];\n}\nans2 += cur;\nfor (int i = 1; i < g.size(); i++) { if (g.get(i) > 0) {\nfor (int j = 1; j < divisors[cur_divisors[i]].size(); j++) {\nint cur_div = divisors[cur_divisors[i]].get(j);\nint diff = cur_divisors[i]/cur_div;\ng.set(get_idx[diff], g.get(get_idx[diff]) + cur_div);\ng.set(i, g.get(i)-1);\ngo();\ng.set(i, g.get(i)+1);\ng.set(get_idx[diff], g.get(get_idx[diff]) - cur_div);\n}\n}\n}\n}\nvoid solve(int n) {\nfor (int i = 1; i < divisors[n].size(); i++) {\ng.add(0);\n}\ng.add(1);\nfor (int i = 0; i < divisors[n].size(); i++) {\nget_idx[divisors[n].get(i)] = i;\ncur_divisors[i] = divisors[n].get(i);\n}\ngo();\n}\npublic long[] countDifferentSources(int power) {\nfor (int n = 1; n<= 100; n++) {\ndivisors[n] = new ArrayList();\nfor (int i = 1; i<= n; i++)\nif (n % i == 0) {\ndivisors[n].add(i);\n}\n}\nsolve(power);\nlong[] ans = {ans1, ans2};\nSystem.out.println(f.size());\nreturn ans;\n}\n}\n```\n\n## Div2Hard: MovingByPoints\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15108)\n\nFor any pair of points (x1, y1), (x2, y2) the minimal number of added points between them needed to get from one point to another not using another given points is equal to |x2-x1|+|y2-y1|-1.\nLet¢s define every point as node of graph and make edge between any pair of points with distance equal to distance between points. After that we can use Dijkstra to find the shortest path between 1 and N.\n\n```\npublic class MovingByPoints {\nint d[][] = new int[1005][];\nint w[] = new int[1005];\nint used[] = new int[1005];\nint Abs(int x) {\nreturn (x>0?x:-x);\n}\npublic int countMinimumPoints(int N, int[] X, int[] Y) {\nfor (int i = 0; i < N; i++)\nd[i] = new int[1005];\nfor (int i = 0; i < N; i++)\nfor (int j = 0; j < N; j++)\nd[i][j] = Math.max(0, Abs(X[j] - X[i]) + Abs(Y[j] - Y[i]) - 1);\nfor (int i = 0; i < N; i++)\nw[i] = 1000000000;\nw[0] = 0;\nfor (int i = 0; i < N; i++) {\nint min1 = 1000000000;\nint idx = -1;\nfor (int j = 0; j < N; j++) {\nif (used[j] == 0 && w[j] < min1) {\nmin1 = w[j];\nidx = j;\n}\n}\nused[idx] = 1;\nfor (int j = 0; j < N; j++) {\nw[j] = Math.min(w[j], w[idx] + d[idx][j]);\n}\n}\nreturn w[N-1];\n}\npublic String checkData(int N, int[] X, int[] Y) {\nif (N < 1 || N > 500) {\nreturn \"N must be between 1 and 500, inclusive.\";\n}\nif (X.length != N || Y.length != N) {\nreturn \"X and Y must have exactly N elements.\";\n}\nfor (int i = 0; i < N; i++) {\nif (X[i] < 1 || X[i] > 1000000 || Y[i] < 1 || Y[i] > 1000000) {\nreturn \"Each element of X and Y must be between 1 and 10^6, inclusive.\";\n}\n}\nreturn \"\";\n}\n}\n```\n\nTime complexity O(N^2)\n\n## Div1Easy: FindThePerfectTriangle\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15109)\n\nWe can notice, that if one of the sides of the triangle will be irrational number, than perimeter will be irrational too. So we need to find all possible such vectors (vx, vy), where vx^2+vy^2 = k^2) (for some positive integer k £ P, vx and vy are integers). We will call such vectors good vectors.\n\nThere will be not many such vectors(not more than 10^4). We can construct two sides of the triangle using good vectors (vx1, vy1) and (vx2, vy2) on such set of points:\n0, 0, vx1, vy1, vx1+vx2, vy1+vy2 ((vx1+vx2, vy1+vy2) must be also good vector).\n\nIn that way we can construct all possible triangles with integer coordinates, integer area and integer perimeter. After that we can check if (P, S) belongs to that possible triangles.\n\n```\npublic class FindThePerfectTriangle {\nint[] a = new int[1005000];\nint[][] good = new int[1005][];\nint mx[] = new int[5005];\nint my[] = new int[5005];\nint segment_sz = 0;\nint Abs(int x) {\nreturn (x>0?x:-x);\n}\nint S(int x1, int y1, int x2, int y2, int x3, int y3) {\nint ans = (x1+x2)*(y1-y2)+(x2+x3)*(y2-y3)+(x3+x1)*(y3-y1);\nreturn Abs(ans);\n}\npublic int[] constructTriangle(int area, int perimeter) {\nfor (int i = 0; i <= 1000000; i++)\na[i] = 0;\nfor (int i = 1; i <= 1000; i++) {\na[i*i] = i;\n}\nfor (int i = 0; i <= 1000; i++) {\ngood[i] = new int[1005];\nfor (int j = 0; j <= 1000; j++) {\ngood[i][j] = 0;\n}\n}\nfor (int i = 0; i <= 1000; i++) {\nfor (int j = 0; j <= 1000; j++) {\nint x = i*i + j*j;\nif (x <= 1000000 && a[x] > 0) {\nmx[segment_sz] = i;\nmy[segment_sz] = j;\ngood[i][j] = good[j][i] = a[x];\nsegment_sz++;\n}\n}\n}\nfor (int i = 0; i < segment_sz; i++) {\nfor (int j = 0; j< segment_sz; j++) { int x1 = mx[i] + mx[j]; int y1 = my[i] + my[j]; int ar = S(0, 0, mx[i], my[i], x1, y1); if (ar > 0 && ar % 2 == 0 && x1 <= 1000 && y1 <= 1000 && good[x1][y1] > 0) {\nint P = good[mx[i]][my[i]] + good[mx[j]][my[j]] + good[x1][y1];\nif (P == perimeter && ar/2 == area) {\nint[] ans = {1, 1, mx[i]+1, my[i]+1, x1+1, y1+1};\nreturn ans;\n}\n}\nx1 = mx[i] - mx[j];\ny1 = my[i] + my[j];\nar = S(0, 0, mx[i], my[i], x1, y1);\nif (ar > 0 && ar % 2 == 0 && Abs(x1) <= 1000 && y1 <= 1000 && good[Abs(x1)][y1] > 0) {\nint P = good[mx[i]][my[i]] + good[mx[j]][my[j]] + good[Abs(x1)][y1];\nif (P == perimeter && ar/2 == area) {\nint x = Math.max(1, -x1+1);\nint[] ans = {x, x, mx[i]+x, my[i]+x, x1+x, y1+x};\nreturn ans;\n}\n}\n}\n}\nint[] ans = {};\nreturn ans;\n}\nint find_int_dist(int x1, int y1, int x2, int y2) {\nint dist = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);\nfor (int i = 1; i <= 5000; i++) if (i*i == dist) return i; return -1; } boolean in_range(int x) { return (x >= 0 && x <= 3000);\n}\n}\n```\n\n## Div1Medium: LightBulbGame\n[Problem Details\n](https://archive.topcoder.com/ProblemStatement/pm/15112)\nAs this is a combinatorial game and the state space is too large to solve it using brute force, we have to look for a more clever solution. One of the traditional tools that often works is the Sprague-Grundy theory that can be efficiently applied whenever the game can be split into a collection of independent smaller games.\n\nThe main challenge in this problem was to realize that this is indeed the case here. At the first glance, this is not obvious because it seems that the lightbulbs cannot be independent if you can sometimes turn two of them off in one move.\n\nImagine that instead of lightbulbs we play the game with pebbles: add a pebble instead of turning the lightbulb on, and remove a pebble instead of turning it off. Then, \"just turning lightbulb L off\" is the same as \"just removing the pebble from L\". I now claim that \"turning off L and toggling L'\" is equivalent to \"moving a pebble from L to L'\".\n\nWhy is that the case? If I turned L' on, the equivalence is obvious. If I turned L' off, I now have two different situations: in the lightbulb game the lightbulb is off, while in the pebble game I now have two pebbles at L'.\n\nWhy are these two situations equivalent? Because the two pebbles at the same location can safely be ignored, as if they weren¢t there. More precisely, imagine the two pebbles are not there and find out which player has the winning strategy. That player still has a winning strategy if we add those two pebbles back. Said strategy: follow the original strategy with the original pebbles, and copy your opponent's moves on the two extra pebbles.\n\nThus, we can use simple dynamic programming to compute the Sprague-Grundy value for each lit lightbulb, xor them to get the Sprague-Grundy value of the entire board, and then we can examine all\npossible first moves and evaluate each of them independently.\n\n```\nimport java.util.*;\npublic class LightbulbGame {\npublic int countWinningMoves(String[] board) {\nint R = board.length, C = board[0].length();\nint[][] SG = new int[R][C];\nfor (int r=R-1; r>=0; --r) for (int c=C-1; c>=0; --c) {\nHashSet reachable = new HashSet();\nreachable.add(0);\nfor (int nr=r+1; nr<R; ++nr) reachable.add( SG[nr][c] );\nfor (int nc=c+1; nc<C; ++nc) reachable.add( SG[r][nc] );\nSG[r][c] = 0;\nwhile (reachable.contains(SG[r][c])) ++SG[r][c];\n}\nint sg = 0;\nfor (int r=0; r<R; ++r) for (int c=0; c<C; ++c) if (board[r].charAt(c) == '1') sg ^= SG[r][c];\nint answer = 0;\nfor (int r=0; r<R; ++r) for (int c=0; c<C; ++c) if (board[r].charAt(c) == '1') {\nint needed = sg ^ SG[r][c];\nif (needed == 0) ++answer;\nfor (int nr=r+1; nr<R; ++nr) if (SG[nr][c] == needed) ++answer;\nfor (int nc=c+1; nc<C; ++nc) if (SG[r][nc] == needed) ++answer;\n}\nreturn answer;\n}\n}\n```\n\n## Div1Hard: DriveTheCarHard\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15110)\n\nWe can notice, that increasing speed before i-th second(0-indexed) by K meters/second leads to increasing passed distance in the end by (totalTime-i)* K.\nSo we have obvious dynamic programming solution with O(distance^2*log(distance)) time complexity:\nlet dp[distance][time] be optimal answer for time seconds and distance meters, then for each non-negative K we can update dp[time+1][distance+(time+1)* K] with min(dp[time+1][distance+(time+1)*K], dp[time][distance] + K^2).\n\nBut it is not fast enough under given constraints. So we can do following optimizations:\n\nLet¢s define array a where a[i] means increasing speed by a[i] before second with number i.\nWe can notice that when (time+1)* time/2 ³ distance, we can construct an array of increasing speed for each second consisting only with zeros and ones that will lead to moving for exactly distance meters in time seconds.\n\nAfter constructing it we can improve the amount of fuel greedily by trying to add 2 at the start of the array.\n\nIt can be proven that it is never optimal to add 3 for that case.\nWe can also observe that for time>= 261 and distance £ 30000 we can construct an array of increasing speed for each second consisting only with zeros and ones without even adding 2 to the array and calculate the answer as the number of ones in the array.\n\nThis is because:\n1. You can always take a smaller value in the last iteration of the adding one to the array to produce the exact distance you need. That solution is clearly the optimal solution that only uses speedup by 1.\n2. For these constraints you never need to increase your speed by more than 1. This is because for time ³ 261 even if you use the above greedy for distance = 30000, the three largest unused effects of a speedup by 1 will still be at least as large as the effect of changing the speedup at the beginning from 1 to 2.\n\nNow we need to solve the problem for (time+1)* time/2 < distance. Let's try to solve this problem in non-integer values:\nIf we need to move for distance meters in time seconds, the total distance travelled will be equal to\n```time*x1 + (time-1)* x2 + (time-2)*x3 + ... + 1*xtime,```\nfor time*x1 meters will be wasted x1^2 fuel, for (time-1)* x2 will be wasted x2^2 fuel and so on.\nTo minimize the amount of used fuel we need to maximize the amount of meters travelled for 1 unit of fuel. So we need to maximize values time/x1,\n\n(time-1)/x2, (time-2)/x3, ¼, 1/xtime and they all must be equal.\n\nWe have x1 = time*x, x2 = (time-1)*x, ¼ ,xtime = 1*x, and x1*time + x2*(time-1) + ¼ + xtime*1 = distance, leading to x*(1^2+2^2+¼+time^2) = distance, and minimal amount of fuel is equal to x^2*(1^2+2^2+...+time^2) = distance^2/(1^2+...+time^2).\n\nNow we can calculate this values for all distance £ 30000 and time £ 261 and compare it with dp[time][distance] counted in O(distance^2*log(distance)) and find out that the maximum difference is 30.\n\nWe also can get that for dp[time][distance] the optimal K taken in double value in dp[time-1][distance-K*time]+K*K is equal to x1 = time* x = 6* distance/((time+1)* (2 * time+1)).\nValues of dp[time-1][distance-K*time]+K* K in double values will be monotonous sequence on segments [K, +infinity) and (-infinity, K], so we can iterate K down and up in integer while dp[time-1][distance-K*time]+K*K will be not bigger than optimal_double_solution(time, distance) + 30 and it leads to less than 10^8 operations for distance £ 3*10^4.\n\n```\npublic class DriveTheCarHard {\nint dp[][] = new int[305][];\ndouble calc(int i, int j) {\nreturn (1.*j*j/(1.*(i)*(i+1)*(2*i+1)/6));\n}\nint solve_fast(int x, int y) {\nfor (int i = 1; i <= 30000; i++)\ndp[1][i] = i*i;\nfor (int i = 2; i <= 250; i++)\nfor (int j = 1; j <= 30000; j++)\ndp[i][j] = 1000000000;\nint cnt = 0;\nfor (int i = 2; i <= 250; i++) {\nfor (int j = 0; j <= 30000; j++) { double pre = calc(i,j); int optK = (int)(6.*j/(1.*(i+1)*(2*i+1))); for (int k = optK; j-k*i >= 0; k++) {\nif (dp[i-1][j-k*i] + k*k < pre + 30) { dp[i][j] = Math.min(dp[i][j], dp[i-1][j-k*i] + k*k); } else { break; } } for (int k = optK; k >= 0; k--) {\nif (dp[i-1][j-k*i] + k*k < pre + 30) { dp[i][j] = Math.min(dp[i][j], dp[i-1][j-k*i] + k*k); cnt++; } else { break; } } } } return dp[x][y]; } int solve_over_sqrt(int T, int D) { int cur_cnt = T; int[] ones = new int[1050]; int cur_sz = 0; while (D > 0) {\nint val = Math.min(D, cur_cnt);\nD -= val;\nones[cur_sz++] = val;\ncur_cnt--;\n}\nint ans = cur_sz;\nint pnt = 0;\nint left = 0;\nwhile (true) {\nif (cur_sz < 3) break; int sz = cur_sz; if (ones[pnt]+left >= ones[sz-1] + ones[sz-2] + ones[sz-3]) {\nleft += ones[pnt];\n} else {\nbreak;\n}\nans += 3;\nwhile (ones[cur_sz-1] <= left) {\nleft -= ones[cur_sz-1];\ncur_sz--;\nans--;\n}\npnt++;\n}\nreturn ans;\n}\npublic int findMinimumFuel(int total_time, int distance) {\nfor (int i = 0; i < 300; i++)\ndp[i] = new int[30500];\nif (total_time <= 250) {\nreturn solve_fast(total_time, distance);\n}\nreturn solve_over_sqrt(total_time, distance);\n}\n};\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4ABel2vbHUvb15mFn3rKae","type":"Entry","createdAt":"2020-04-20T12:42:12.778Z","updatedAt":"2020-04-20T12:42:12.778Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"wild_hamster","tcHandle":"wild_hamster"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-738-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2PvvgbYEo6LIraJBv7pQVF","type":"Entry","createdAt":"2020-04-20T12:42:12.708Z","updatedAt":"2026-02-16T23:46:12.801Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":34,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 737","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2018-09-19T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 737 Editorials\n\n## Make737Easy\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15070)\n\nThe problem has a straightforward solution: with the constraints being so low, we can afford an O(n^3) solution that simply enumerates and checks all triples of indices.\n\n```\ndef count(S):\nanswer = 0\nfor i in range( len(S) ):\nfor j in range( i+1, len(S) ):\nfor k in range( j+1, len(S) ):\nif S[i]=='7' and S[j]=='3' and S[k] == '7':\nanswer += 1\nreturn answer\n```\n\nMore efficient solutions exist as well. In fact, the problem is solvable in linear time. The main idea of one such algorithm: For each ‘3’ we can count the number of 737-triples that contain it by multiplying the number of ‘7’s to its left and the number of ‘7’s to its right.\n\n```\ndef count_linear(S):\n# compute the following:\n# prefix[i] is the number of '7's in the first i characters of S\n# suffix[i] is the number of '7's in the last i characters of S\nN = len(S)\nprefix, suffix = [0], [0]\nfor n in range(N):\nprefix.append( prefix[-1] + (1 if S[n]=='7' else 0) )\nfor n in range(N-1,-1,-1):\nsuffix.append( suffix[-1] + (1 if S[n]=='7' else 0) )\n# use the precomputed values to calculate the number of 737-triples\nreturn sum( prefix[n] * suffix[N-n-1] for n in range(N) if S[n]=='3' )\n```\n\n## AliceAndBobMedium\n[Problem Details\n](https://archive.topcoder.com/ProblemStatement/pm/15073)\nA winning move for Alice is a move that will get Bob into a losing position. And as we know from the problem statement, losing positions are those in which the bitwise xor of all pile sizes is zero.\n\nThe pile sizes in the input are quite large, so we cannot afford to enumerate all possible moves Alice can make. In order to solve this task, we need to make one observation: for each pile there is at most one winning move.\nWhy is that the case? Consider the following example. Suppose the current pile sizes are {7, 5, 3, 4}.\n\nWhat happens if Alice chooses the pile with 7 stones? By removing some of them, she will create a new state in which the pile sizes are {x, 5, 4, 3} for some x < 7. In order for this to be a winning move, we are looking for a value x such that (x xor 5 xor 4 xor 3) = 0.\n\nNow we can easily see that there is exactly one such x: x = (5 xor 4 xor 3) = 2. In other words, Alice’s winning move is to go from {7, 5, 3, 4} to {2, 5, 3, 4}.\n\nIn the same example, suppose Alice chooses the pile with 3 stones. Using the same math as above, we can compute that the desired new pile size is x = (7 xor 5 xor 4) = 6. However, this is not a valid move for Alice: she cannot go from 3 stones to 6, as she can only remove stones.\nThis observation can easily be generalized. In order to count the winning moves for Alice, we just do the following: For each pile p, compute x = the bitwise xor of all other piles. If x < p, Alice has a winning move on this pile, otherwise she doesn’t.\n\n```\ndef count(A):\nxorall = 0\nfor a in A: xorall = xorall ^ a\nwinning = 0\nfor a in A:\nneeded = xorall ^ a\nif needed < a: winning += 1\nreturn winning\n```\n\n## SimpleMathProblem\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15075)\n\nThere are multiple ways to tackle this problem. I tried to choose one that has a small number of special cases.\n\nOur goal is to compute a^(b^c) modulo m. The two main tools for such jobs are:\nhttps://en.wikipedia.org/wiki/Euler%27s_theorem that can be used if a and m are coprime\nhttps://en.wikipedia.org/wiki/Chinese_remainder_theorem that can be used to split the computation “modulo m” into computations using other smaller moduli.\n\nOur plan of attack will be as follows. We’ll start by finding the prime factorization of m. For each p^k that is a factor of m:\n- If a is not divisible by p, we can use Euler’s theorem to compute a^(b^c) mod p^k.\n- If a is divisible by p and b^c >= k, we know that a^(b^c) mod p^k = 0.\n- If a is divisible by p and b^c < k, we can compute a^(b^c) mod p^k directly.\n\nFinally, we just use the Chinese remainder theorem to merge all partial results into one. In my code, instead of using the actual CRT I use a simple implementation that runs in O(min(modulus1,modulus2)), which is fast enough in our case.\n\n```\ndef gcd(a,b):\nif b == 0: return a\nreturn gcd(b,a%b)\ndef factor(n):\nanswer = []\nd = 2\nwhile True:\nif d*d > n: break\nwhile n % d == 0:\nanswer.append(d)\nn //= d\nd += 1\nif n > 1:\nanswer.append(n)\nreturn answer\ndef phi(n):\nanswer = n\nfor p in set(factor(n)): answer = (answer * (p-1)) // p\nreturn answer\ndef modexp(a,b,c):\nif b == 0: return 1 % c\nt = modexp(a,b//2,c)\nanswer = t*t*(a if b%2 else 1)\nreturn answer % c\ndef crt_combine(a1,m1,a2,m2):\nif m1 < m2: a1, m1, a2, m2 = a2, m2, a1, m1 for k in range(m2): if (a1 + k*m1) % m2 == a2: return a1 + k*m1, m1*m2 def calculate(a,b,c,m): answer, modulo = 0, 1 for p in set(factor(m)): curmod = 1 while m % p == 0: curmod, m = curmod*p, m//p if a%p == 0: if b == 1: newexp = 1 elif b > 1 and c <= 10: newexp = min(50,b**c)\nelse: newexp = 50\ncurans = modexp(a,newexp,curmod)\nelse:\nnewexp = modexp(b,c,phi(curmod))\ncurans = modexp(a,newexp,curmod)\nanswer, modulo = crt_combine(answer,modulo,curans,curmod)\nreturn answer\n```\n\n## AliceAndBobEasy\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15076)\n\nThe winning strategy for NIM is well-known: a position is losing if and only if the bitwise xor of all pile sizes is zero.\n\nIf we are in a losing position, there are no winning moves. If we are in a winning position, a winning move puts our opponent into a losing position. Thus, we want to make the bitwise xor of all piles be equal to zero. In other words, we need to choose one pile and make its size equal to the bitwise xor of all other piles.\n\nHence, in any given winning position there is at most one winning move on each pile. Note the “at most”. This is because sometimes the size we need is bigger than the size we have, which is not a valid move. For example, in the winning position {7, 5, 3, 4} there is no winning move on the pile with 3 stones because we would need to go to {7, 5, 6, 4} and we are not allowed to add stones.\n\nThus, for any n we see that a winning position with n piles has at most n distinct winning moves. If we can find such positions, we can be sure that they are optimal.\n\nFor odd n such positions are easy to find. For example, consider the position { 2^x + 1, 2^x + 2, …, 2^x + n } for some x such that 2^x > n. We can easily verify that there is a winning move on each pile. This is because the bitwise xor of any n-1 piles will not have the 2^x bit set (as n-1 is even), and therefore it will certainly be smaller than the current number of stones on the remaining one pile.\n\nFor even n the best we can do are positions with n-1 winning moves, for example { 1, 2^x + 1, 2^x + 2, …, 2^x + n-1 }. Using the same reasoning as above we can show that there is a winning move on each pile other than the “1” pile. All that remains is to show that we cannot do better.\nSuppose n is even and we are in a winning position. As the bitwise xor of pile size is non-zero, let x be the largest exponent of two that appears in said bitwise xor. As the total number of piles is even and the number of piles that have the x-th bit set is odd, there has to be a pile P that doesn’t have the x-th bit set. We now claim that there is no winning move on pile P.\nWhy is that? Because the bitwise xor of all other piles will match P on all bits bigger than x, and it will have the x-th bit set while P doesn’t. Thus, the bitwise xor of piles other than P is greater than P.\n\n## GroupTheNumbers\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15078)\n\nHere are some observations we can make:\nThere is an optimal solution with at most one group that has a nonpositive value. (Otherwise we can combine two such groups into one.)\n\nIn any optimal solution there is only one group with value > 1. (Same argument.)\nLet’s call x big if abs(x) > 1. In any optimal solution, all big elements are in the same group, except for at most one negative big element. (The only other place they can be is the nonpositive group, if any. It is always better to bring all positive big elements, and any pair of negative big elements from the nonpositive group into the big positive group.)\nEach “1” should optimally be a separate group. (If we have it anywhere else it’s better to take it out.)\n\nPairs of “-1”s should never be together in a group with other numbers, each such pair should be a separate group. (Same argument.)\nThis leaves us with a small finite number of cases, and we can find the optimal solution by examining all of them and picking the best one. (It is possible to make further observations, e.g., which negative number to choose as the one that is not in the “big” group, but it’s not necessary.)\n\nThus, the outline of my final solution looks as follows:\nWrite a brute force solution that works for any small constant number of elements. (We will never use it on more than 4 elements. I did it this way because to me it was simpler than the additional casework.)\n\nMerge all 0s into a single 0.\nMake each 1 a separate group.\nMake each pair of -1s a separate group, as long as you have some -1s left over.\nIf the product of all big elements is positive, make them into a group.\nIf you now have no big elements, use brute force.\nIf the product of all big elements is negative and you have a -1, try making a group of all big elements + the -1, then use brute force.\nIf the product of all big elements is negative, also try all possibilities of making a group of them that is missing one negative element, and then use brute force.\n\n## Make737Hard\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15080)\n\nWe already made a useful observation in the linear solution for Make737Easy: given any string of 7s and 3s, the number of 737-triples can be counted as sum( (7s to my left) times (7s to my right) for each 3 in the string).\n\nWe can now imagine building the desired string in two steps: first we choose the number of 7s in the string, then we choose where to insert the 3s. Once we chose the number of 7s, each gap between them comes with some specific number of 737-triples each 3 inserted into that gap will produce. For example, each 3 inserted at the marked location in 777|77 will produce 3* 2 = 6 triples.\n\nThis can now be treated as a knapsack problem: we need to choose the right number of “items” so that their sum becomes exactly the given X.\n\nMy alternate solution for this problem feels a little like cheating. The number of strings in {3,7}^373 is huge, the number of triples in each of them is always small, and the “item sizes” in the knapsack are reasonably distributed. Thus the set of correct answers should always be large and fairly dense. Hence, all I did was a clever random walk that oscillates around the desired number of triples until it hits exactly.\n\n```\nstring make(int X) {\nif (X <= 371) return '7' + string(X, '3') + '7';\nstring curr = \"\";\nwhile (int(curr.size()) < 373 && eval(curr) < X + 20000)\ncurr += ((rand() & 1) ? '7' : '3');\nint currval = eval(curr);\nwhile (true) {\nstring cand = curr;\ncand[rand() % cand.size()] = ((rand() & 1) ? '7' : '3');\nint candval = eval(cand);\nif (candval <= currval && currval < X) continue; if (candval >= currval && currval > X) continue;\ncurr = cand;\ncurrval = candval;\nif (currval == X) return curr;\n}\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-737-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"79TYp0EEcKOnRD1FEVwIzp","type":"Entry","createdAt":"2020-04-20T12:42:13.318Z","updatedAt":"2026-02-16T23:07:19.359Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":46,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 740","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2018-10-20T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 740 Editorials\n\nSRM 740 was held on Oct 20th at 12:00 UTC-4. The problems for the round were written and prepared by [misof](https://profiles.topcoder.com/misof).  the tested by . Thanks to monsoon for editorials too.\n\n__Author__: Tomasz Idziaszek ([monsoon](https://profiles.topcoder.com/monsoon))\n\n## GetAccepted\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15138)\n\nSince every negation (no matter where it appears in the sentence) changes the meaning of the question to the opposite one, we only need to count the number of negations in the sentence. The odd number of negations results in the answer “True.”, and the even number of negations — in the answer “False.”\n\nWe can do it by splitting the sentence into words and count how many words “not” we get. See the following Python program:\n```\nclass GetAccepted:\ndef answer(self, question):\nnumber_of_nots = question.split().count(\"not\")\nif number_of_nots % 2 == 1: return \"False.\"\nelse: return \"True.\"\n```\n\nWe get even simpler solution, by observing that every negation increases the length of the question by 4. Thus we can base our answer on the parity of the length of the question divided by 4. See a sample Java program:\n```\npublic class GetAccepted {\npublic String answer(String question) {\nint number_of_nots = ( question.length() - \"Do you want to get accepted?\".length() ) / 4;\nif (number_of_nots % 2 == 1) return \"False.\"; else return \"True.\";\n}\n};\n```\n\n## LongJumpCompetition\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15136)\n\nIn this problem it is enough to simulate the process described in the statement. We maintain an ordered collection of contestants, and update the order after each round.\n\n```\nstruct Contestant {\nvector<int> jumps;\nint bib;\nbool operator<(const Contestant& other) const {\n// Vectors are compared lexicographically\nif (jumps != other.jumps) return jumps > other.jumps;\nreturn bib < other.bib;\n}\nvoid add_jump(int len) {\njumps.push_back(len);\n// After adding a jump, sort jumps from the longest to the shortest\nsort(jumps.begin(), jumps.end(), greater<int>());\n}\n};\nstruct LongJumpCompetition {\nvector<int> recoverStandings(vector<int> jumpLengths) {\nint n = jumpLengths.size() / 3;\nvector<Contestant> person(n);\n// Initialize an array of contestants with no jumps\nfor (int i=0; i<n; ++i) {\nperson[i].bib = i;\n}\n// Simulate the rounds\nfor (int phase=0; phase<3; ++phase) {\nfor (int i=0; i<n; ++i) {\nperson[i].add_jump(jumpLengths[phase*n + n-1-i]);\n}\n// Re-sort the contestants to get the new standings\nsort(person.begin(), person.end());\n}\n// Report the final standings\nvector<int> order;\nfor(int i=0; i<n; ++i) {\norder.push_back(person[i].bib);\n}\nreturn order;\n}\n};\n```\n\nRather than using a struct to represent a contestant, we could use a pair (sorted vector of all person's jump lengths, person's bib number) and utilise standard comparison operators. This could result in a shorter, but a little bit more cryptic code.\nThe jump lengths are negated, to ensure that the longest jump will be at the beginning of the vector after sorting it non-decreasingly. Since both vectors and pairs are compared lexicographically  we can simply compare such representations to get the correct ordering:\n\n```                  \nstruct LongJumpCompetition {\nvector<int> recoverStandings(vector<int> jumpLengths) {\nint n = jumpLengths.size() / 3;\nvector<pair<vector<int>, int> > person(n);\nfor(int i=0; i<n; ++i) {\nperson[i].second = i;\n}\nfor(int phase=0; phase<3; ++phase) {\nfor(int i=0; i<n; ++i) {\nperson[i].first.push_back(-jumpLengths[phase*n + n-1-i]);\nsort(person[i].first.begin(), person[i].first.end());\n}\nsort(person.begin(), person.end());\n}\nvector<int> order;\nfor(int i=0; i<n; ++i) {\norder.push_back(person[i].second);\n}\nreturn order;\n}\n};\n   ```\n\n## EvenMatrices\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15140)\n\nEven matrices have an interesting property. Suppose that we were given an even matrix, but with values in the last row and last column hidden:\n0101?\n0111?\n1010?\n?????\n\nSince we know that the number of 1s in each row and columns is even, we could easily deduce the contents of the hidden cells:\n01010\n01111\n10100\n10001\n\nThus if we are given any binary matrix of size (r-1) × (c-1), we can extend it to an even matrix of size r × c.\n\nAnd vice versa, every even matrix of size r × c is uniquely determined by its top-left submatrix of size (r-1) × (c-1).\n\nThat shows that there are exactly 2^(r-1)(c-1) even matrices of size r × c.\n(Thus there is no answer to the problem if k ```>=```2^(r-1)(c-1).)\nTo obtain the k-th even matrix in lexicographic order, we can find the k-th top-left submatrix in lexicographic order, and extend it. The extension will not break ordering, since each cell in the last column and last row depends only on cells which stands before it in row major order.\nTo find the k-th submatrix, we can just examine binary expansion of number k:\n```\nstruct EvenMatrices {\nvector<string> findKth(int rows, int cols, long long k) {\n// Fill the matrix with zeros\nvector<string> ans(rows, string(cols, '0'));\n// Iterate over cells of the top-left submatrix of size (rows-1)*(cols-1)\nfor (int r=rows-2; r>=0; --r) {\nfor (int c=cols-2; c>=0; --c) {\nif (k & 1) {\n// If the corresponding bit of k is 1, change the cell (r,c) in submatrix\nans[r][c] = '1';\n// And immediately fix cells in the last column and the last row\n// to get the correct extension\nans[r][cols-1] ^= 1;\nans[rows-1][c] ^= 1;\nans[rows-1][cols-1] ^= 1;\n}\nk >>= 1;\n}\n}\n// If k is nonzero, it means that it was greater that 2**((rows-1)*(cols-1))\nreturn k > 0 ? vector<string>() : ans;\n}\n};\n```\n\n## RainForecast\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15137)\n\nWe start by calculating the probability that the Ilko's report will be broadcasted without change by the TV station.\nLet a[i] be the probability that the person i got this report without change; of course a[0] = 1.\nThere are two cases in which person i can deliver report as intended by Ilko: either she obtains correct report (with probability a[i]) and she passes it without change (with probability p = deliverProbs[i] / 100.), or she obtains incorrect report (with probability 1 - a[i]) and she passes the opposite report (with probability 1 - p).\nTherefore a[i+1] = a[i]*p + (1-a[i])*(1-p).\nShould Ilko send to the TV station the prediction of the model (r = ilkoRain / 100.), the answer to the task would be r*a + (1-r)*(1-a). But Ilko knows the whole setup and he tries to maximize the above value.\nTherefore he could do two changes:\n\nIf the success rate of the model's prediction is very poor (r < 0.5),\nhe should report the opposite forecast, to have a better accuracy.\n\nIf he supposes that people in the TV station will broadcast the opposite\nof what he tells them (a[n] ```<``` 0.5), then he should intentionally report\nthe opposite.\n\nPerforming such changes is equivalent to taking max(r, 1-r) and max(a[n], 1-a[n]).\nIt is illustrated by the following program:\n```\nstruct RainForecast {\ndouble predictRain(int ilkoRain, vector<int> deliverProbs) {\nint n = deliverProbs.size();\ndouble a = 1.0;\nfor (int i = 0; i < n; ++i) {\ndouble p = deliverProbs[i] / 100.;\na = a * p + (1 - a) * (1 - p);\n}\ndouble r = ilkoRain / 100.;\na = max(a, 1-a);\nr = max(r, 1-r);\nreturn r * a + (1 - r) * (1 - a);\n}\n};\n```\n\n## DieDesign\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15141)\n\nNote that the probability of winning depends on the following sum: for each face on our die, count how many faces on the input die has less pips. Therefore drawing more pips on a die could not make it weaker.\nThus if we find a strong die which has at most the same number of pips as the input die, we could easily transform it to a strong die which has exactly the same number of pips (by drawing missing pips arbitrarily).\nMoreover, suppose that we find an optimal solution. Look at any face of our die, suppose it has X pips.\nIf the input die has no face with X-1 pips, we can remove one pip from our face and still have a die that wins the same.\nThus, we look for a die that has at most the same number of pips as the input die, and each face of our die is either 0 or it is (some face of the input die) + 1.\nWe use dynamic programming here. The states are (number of faces painted, sum of pips used), and for each state we find\nthe winning sum.\nIf N is the maximal number of faces and P is maximal number of pips per face, we have N*N*P states, and for each states we need to consider N+1 values on a face.\nThus the time complexity is O(N^3 * P).\n```\npublic class DieDesign {\npublic int countSmaller(int val, int[] array) { int answer = 0; for (int i=0; i<array.length; ++i) if (array[i] < val) ++answer; return answer; }\npublic int sum(int[] array) { int answer = 0; for (int x : array) answer += x; return answer; }\npublic int max(int[] array) { int answer = 0; for (int x : array) answer = Math.max(answer,x); return answer; }\npublic int[] design(int[] pips) {\nint sumPips = sum(pips), maxPips = max(pips), faces = pips.length;\nHashSet<Integer> candidateSet = new HashSet<Integer>();\ncandidateSet.add(0);\nfor (int p : pips) candidateSet.add(p+1);\nint C = candidateSet.size();\nint[] candidates = new int[C];\n{ int c=0; for (int cand : candidateSet) candidates[c++] = cand; }\nint[] addsWins = new int[C];\nfor (int c=0; c<C; ++c) addsWins[c] = countSmaller( candidates[c], pips );\nint[][] mostWins = new int[faces+1][sumPips+1];\nfor (int[] row : mostWins) Arrays.fill(row,-123456789);\nmostWins[0][0] = 0;\nint maxSumSeen = 0;\nint[][] bestFace = new int[faces+1][sumPips+1];\nfor (int face=1; face<=faces; ++face) {\nint newMaxSumSeen = maxSumSeen;\nfor (int oldSum=0; oldSum<=maxSumSeen; ++oldSum) {\nif (mostWins[face-1][oldSum] < 0) continue;\nfor (int c=0; c<C; ++c) {\nint newSum = oldSum + candidates[c];\nif (newSum > sumPips) continue;\nnewMaxSumSeen = Math.max( newMaxSumSeen, newSum );\nint newWins = mostWins[face-1][oldSum] + addsWins[c];\nif (newWins > mostWins[face][newSum]) {\nmostWins[face][newSum] = newWins;\nbestFace[face][newSum] = candidates[c];\n}\n}\n}\nmaxSumSeen = newMaxSumSeen;\n}\nint bestWins = -1, bestSum = -1;\nfor (int sum=0; sum<=sumPips; ++sum) {\nif (mostWins[faces][sum] > bestWins) { bestWins = mostWins[faces][sum]; bestSum = sum; }\n}\nint[] answer = new int[faces];\nint curSum = bestSum;\nwhile (faces > 0) {\nanswer[faces-1] = bestFace[faces][curSum];\ncurSum -= bestFace[faces][curSum];\n--faces;\n}\nint remains = sumPips - sum(answer);\nanswer[0] += remains;\nreturn answer;\n}\n};\n```\n\n## LongPalindromes\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15135)\n\nLet's begin with solving an easy version of the problem.\nSuppose that we need to find the number of palindromic subsequences in a short string s[0..N-1]. We use dynamic programming approach: denote by dp[i,j] the number of palindromic subsequences of a substring s[i..j].\n\nIf letter s[i] differs from letter s[j], then we know that at most one of these letters could be included in a palindromic subsequence. There are dp[i+1,j] subsequences that do not include s[i], and dp[i,j-1] that do not include s[j].\n\nOf course, we should take care of not counting twice subsequences that do not include both s[i] and s[j], thus in this case we have dp[i+1,j] + dp[i,j-1] - dp[i+1,j-1].\nIf letters s[i] and s[j] are equal, then there are additional palindromic subsequences that include both s[i] and s[j].\nThere are dp[i+1,j-1] of them (since after removing s[i] and s[j] they should form shorter palindromic subsequences).\nFinally, we get a recurrence formula:\n```dp[i,j] = dp[i+1,j] + dp[i,j-1] - [s[i] != s[j]] * dp[i+1,j-1]```\n\nThe answer to the problem is dp[0,N-1].\nThe above algorithm calculates it in time complexity of O(N^2).\nOf course, explicitly applying it to the string from the problem is not possible, since N = repeats * n, where n is the length of the pattern and repeats could be as big as 10^9.\nSuch big value of repeats (which results in a big length of the string) suggests that the efficient solution could use fast matrix exponentiation. But how to find a suitable matrix?\nSince the most important here is the length, let's rewrite the recurrence formula in such a way that it makes more visible the length of the substring len = j-i+1:\ndp^len[i] = dp^len-1[i+1] + dp^len-1[i] - [s[i] != s[i+len-1]] * dp^len-2[i+1].\n\nThe answer to the problems is dp^N[0].\nMoreover, let's use the fact that the string s[0..N-1] is in fact a result of concatenating copies of string s[0..n-1], therefore s[i] = s[i%n]:\ndp^len[i] = dp^len-1[(i+1) % n] + dp^len-1[i] - [s[i] != s[(i+len-1) % n]] * dp^len-2[(i+1) % n].\n\nThe above formula shows that to calculate values dp^len[i] for 0 <= i < n we only need to know values dp^len-1[i] and dp^len-2[i] for 0 <= i < n. Moreover, the correspondence between them is linear, thus we could write a matrix of size 2n × 2n which multiplied by a vector of size 2n containing values dp^len-1[i], dp^len-2[i] results in a vector containing values dp^len[i], dp^len-1[i].\nThere is a small catch here: the linear formulas depends on value of len (thus for different values of len, we would get different matrices). But fortunately this value is inside expression (i+len-1)%n, thus in fact there will be only n different matrices.\nBy multiplying them all, we would get a single matrix (independent of len) which multiplied by a vector with values dp^len-1[i], dp^len-2[i], gives a vector with values dp^len-1+n[i], dp^len-2+n[i]. Raising this matrix to the power repeats, allows us to calculate dp^N[i] from dp^0[i] (all ones), dp^-1[i] (all zeros).\nThe overall time complexity is O(n^4 + n^3 log(repeats)) for calculating and multiplying n matrices of size 2n × 2n and raising such a matrix to the power repeats.\nSee the below code for details:\n\n```\n#define REP(i,n) for(int i=0;i<(n);++i)\ntypedef long long ll;\nconst int N=50, S=2*N, MOD=1000000007;\nstruct mat_t {\nint m[S][S];\n};\nstruct vec_t {\nint m[S];\n};\nmat_t mat_mult(const mat_t& A, const mat_t& B) {\nmat_t C;\nREP(i,S) REP(j,S) C.m[i][j] = 0;\nREP(i,S) REP(k,S) REP(j,S) {\nC.m[i][j] = (C.m[i][j] + ll(A.m[i][k]) * B.m[k][j]) % MOD;\n}\nreturn C;\n}\nvec_t mat_vec_mult(const mat_t& A, const vec_t& B) {\nvec_t C;\nREP(i,S) C.m[i] = 0;\nREP(i,S) REP(k,S) {\nC.m[i] = (C.m[i] + ll(A.m[i][k]) * B.m[k]) % MOD;\n}\nreturn C;\n}\nmat_t mat_pow(mat_t A, ll n) {\nmat_t ans;\nREP(i,S) REP(j,S) ans.m[i][j] = i==j;\nwhile (n) {\nif (n&1) ans = mat_mult(ans, A);\nA = mat_mult(A, A);\nn /= 2;\n}\nreturn ans;\n}\nmat_t MAT[N];\nvoid init_mats(string pattern) {\nint n = pattern.size();\nREP(m,n) REP(i,S) REP(j,S) MAT[m].m[i][j] = 0;\nREP(m,n) REP(i,n) {\nMAT[m].m[i][i] = 1;\nMAT[m].m[i][(i+1)%n] += 1;\nif (pattern[i] != pattern[(i+m)%n]) {\nMAT[m].m[i][n + (i+1)%n] += MOD-1;\n}\nMAT[m].m[n+i][i] = 1;\n}\n}\nstruct LongPalindromes {\nint count(int repeats, string pattern) {\nint n = pattern.size();\ninit_mats(pattern);\nmat_t W;\nREP(i,S) REP(j,S) W.m[i][j] = i==j;\nREP(i,n) {\nW = mat_mult(MAT[i], W);\n}\nW = mat_pow(W, repeats);\nvec_t V;\nREP(i,S) V.m[i] = 0;\nREP(i,n) V.m[i] = 1;\nV = mat_vec_mult(W, V);\nreturn V.m[0];\n}\n};\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7u469mHPmtr1Q0m5IR4uQ5","type":"Entry","createdAt":"2020-03-28T08:51:00.372Z","updatedAt":"2020-04-01T06:30:01.918Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"monsoon","tcHandle":"monsoon","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"35zK7ZbTYMEaHAQD2viKKT","type":"Asset","createdAt":"2020-04-01T06:29:58.074Z","updatedAt":"2020-04-01T06:29:58.074Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"monsoon big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/35zK7ZbTYMEaHAQD2viKKT/94c375c5ef56a6206470204f364cb3ef/monsoon_big.jpg","details":{"size":4594,"image":{"width":126,"height":140}},"fileName":"monsoon_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-740-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7i1D11ObJic7AEruGGYyYr","type":"Entry","createdAt":"2020-04-20T12:42:13.272Z","updatedAt":"2026-02-16T22:54:08.403Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":15,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 745","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["TUTORIAL"],"creationDate":"2019-01-09T00:00:00.000Z","readTime":"5 min","content":"# Single Round Match 745 Editorials\n\nThe match was held on Dec 27th and was held Fun and Unrated round for trial purposes! Thanks to [misof](https://profiles.topcoder.com/misof) for the brief editorials!\n\n__200__: return {x,y-1}\n\n__300__: Look at a maximal chain backwards. You start with a range of length n. Then, n-1 times you either remove the smallest or the largest of the numbers in the range. Thus, answer is 2^(n-1).\n\n__500__: Watch out for different representations of the empty interval. [3,3), [5,7) is a valid chain. Other than that, just check that the lengths are increasing and that each interval is contained in the previous one.\n\n__600__: Each element must be either smaller than or bigger than all previous elements. If you find one that isn't, it's invalid, otherwise its valid or maximal. It's only maximal if each element is either min(all previous)-1 or max(all previous)+1, and ends with min=0, max=len-1. A tricky case is that when you see e.g. {3,?,?} you know that it cannot be maximal any more.\n\n__800__: All chains of order n = chains that end with [0,n) + chains that don't. The second group has the same size as the first group, minus 1, because you can append [0,n) to any chain from the second group to get a chain from the first group. Size of the second group = 2*chains of order n-1 — chains of order n-2.\n\n__1000__: Greedy. Keep the number of empty intervals separately, and answer max(# of empty intervals, # of chains of nonempty intervals the greedy below builds). Keep the intervals that don't have a successor yet in a sorted set, sorted primarily by y. Process all intervals in decreasing x order. Each time you process an interval [x0,y0) put it after the interval with the largest y among the ones available.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-745-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"665XsZYCr1KYl0ZPYx9TTv","type":"Entry","createdAt":"2020-04-20T12:42:13.216Z","updatedAt":"2026-02-16T22:51:25.715Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":47,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 747","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2019-01-25T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 747 Editorials\n\nSRM 747 was held on 19th Jan, 2019. Thanks to [misof](https://profiles.topcoder.com/misof) for the problems and editorials\n\n## Sherlock\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15285)\n\nIn this problem we had to find out whether a name is similar enough to “Benedict Cumberbatch”. The solution is straightforward, we just check all the conditions listed in the problem statement. Note that the implementation can be made more pleasant if you know and use the correct string manipulation functions in your language.\n\n```\ndef howManyLetters(name, letterBank):\nreturn sum( x in letterBank for x in name )\ndef isBenedict(firstName, lastName):\nif len(firstName) < 5 or len(lastName) < 5: return False\nif firstName[0] != 'B' or lastName[0] != 'C': return False\nif howManyLetters(firstName, \"BENEDICT\") < 3: return False\nif howManyLetters(lastName, \"CUMBERBATCH\") < 5: return False\nreturn True\n```\n\n## CycleLength\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15287)\n\nEach value is uniquely determined by the previous one. Thus, once a value in the sequence repeats, the sequence has entered a cycle.\n\nAs there are only finitely many possible values (namely, exactly m), there has to be a repeated value among the first m+1 elements of the sequence.\n\nThus, probably the easiest solution looks as follows:\nGenerate the first m+1 elements. You are now guaranteed to be in the part that repeats.\nLet x be the current element. Generate following elements until x appears again, and count the steps.\n\nThat number of steps is the length of the shortest period.\nThis solution has no special cases and it needs no data structures - it needs just a constant number of variables. In the worst case it will generate about 2*m elements of the sequence, and thus its time complexity is O(m).\n```\npublic int solve(int seed, int a, int b, int m) {\nlong state = seed;\nfor (int i=0; i<m+47; ++i) state = (state*a+b) % m;\nlong goal = state;\nfor (int steps=1; ;++steps) {\nstate = (state*a+b) % m;\nif (state == goal) return steps;\n}\n}\n```\n\nAnother short solution is to use a data structure. The most appropriate one is a map in which we use the value of an element as the key. The value we store with the key is the index at which the value appeared for the first time. We then generate the sequence one element at a time, and we store all elements into that map. As soon as an element repeats, we know that we found a period. Its length can be computed as the current index (i.e., the index of the second occurrence of the repeated value) minus the index of its first occurrence (which can be retrieved from the map).\n\nFor an even smarter solution that can find the preperiod and period in optimal time, in constant space, and even without knowing an upper bound on the period length in advance, look up Floyd’s cycle-finding algorithm.\n\n## MostFrequentLastDigit\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15286)\n\nSilently, this was the most interesting problem of the round, especially for top Div1 contestants. I’ll get to the reason for this claim later.\nOf course, the problem was solvable in ways other than the one I had in mind when writing the previous paragraph. Let’s try to come up with a nice deterministic solution. One approach that might help us is a simple visualization of all possible sums of pairs. Here are all the possible sums for the sequence 1,3,1,2,2,4:\n\nWe may notice that if we have multiple copies of the same number, they each produce the same multiset of sums. In the figure these appear as identical parts of rows/columns. More precisely, if we have two numbers X and Y with the same last digit, the last digits of the sums that involve X are the same as the last digits in the sums that involve Y. That sounds like a good way to make a lot of copies of the same result.\n\nLet’s see what happens if we only use two distinct values. In our example, let’s try using three 3s and three 7s. The yellow square shows that we now have nine sums that end in a zero: each 3 combined with each 7. Out of all fifteen sums, nine end in a zero and only six end in a different digit.\n\nThat sounds promising. If we can make sure that our digit is more frequent than all other digits combined, it has to be the most frequent of all. And the figure shown above gives us an idea how to do it.\n\nHere’s the resulting algorithm:\nFind two non-zero digits x and y such that (x+y) mod 10 = d.\nCreate an array with floor(n/2) copies of x and ceil(n/2) copies of y.\nMake sure that the numbers are all distinct.\n\n__Why does it work?__\nStep 1 can always be performed. For example, if d is at least 2, we can choose x=1 and y=d-1; and we can choose (5,6) for d=1 and (4,6) for d=0.\nIn step 2 we will create an array for which the sums of many pairs will end in the digit d. Are there enough of those? If n = 2k, we have k*(2k-1) pairs and out of those k * k are good and only k*(k-1) are bad. And if n=2k+1, we have k*(2k+1) pairs and out of those k*(k+1) are good and only k * k are bad. Hence, in both cases our digit is clearly the most frequent one.\nThis is easy to do. For example, we just add 10 * i to the element at position i.\n\n## TieForMax\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15237)\n\nThis problem has multiple polynomial-time solutions. I’ll show one that’s based on computing the complementary probability -- i.e., the probability that the maximum is unique.\nWe will do a three-dimensional dynamic programming. Let ways[a][b][c] be the number of sequences of actions in which we can distribute a tokens onto b piles so that each pile has at most c tokens. These values are easy to compute. We’ll leave the base cases as an exercise and we’ll only focus on the general case. The general case is computed as follows:\nways[a][b][c] = sum( binomial[a][i] * ways[a-i][b-1][c] for i = 0..min(a,c) )\n\nWhat’s going on in the formula? We try all possibilities for the number i of tokens on the first pile. Once we have fixed i, we have binomial[a][i] ways to choose the steps in which we placed those tokens, and for each of those ways we have ways[a-i][b-1][c] ways to distribute the remaining a-i tokens onto the remaining b-1 piles in a valid way.\nNow, once we have this precomputed, we can find the probability that a unique pile is maximal: we will just iterate over all possibilities for its size. For each x we will compute the probability that the unique maximal pile has size x, and as these events are distinct, the result is simply the sum of these probabilities.\nHow many different sequences of actions will produce a result in which the unique maximal pile has size x? We have p options for which pile it is, we have binomial[t][x] ways to choose in which steps we placed a token onto this pile, and we have ways[t-x][p-1][x-1] ways to distribute the remaining tokens onto the remaining piles in such a way that all of them are smaller. Thus, the total number of valid sequences of actions is the sum of p* binomial[t][x]* ways[t-x][p-1][x-1] over all x.\nThe total number of actions is simply p^t. Hence, the correct return value of our function is 1 - (the result from the previous paragraph, divided by p^t).\nThe array “ways” has O(t*t*p) cells, and we can compute each of those in O(t) time. The final sum is negligible in comparison. Thus, our solution has the time complexity O(t^3* p) and space complexity(t^2* p).\n\n## RochesterSequences\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15288)\n\nThis problem has a fairly straightforward dynamic programming solution that is correct but too slow. The solution looks as follows: Let best[i][j] be the length of the longest NRS (nondecreasing Rochester sequence) that starts with element i and ends with element j. To compute this, we will try all the possibilities for the second element and all possibilities for the second-to-last element, and we will return the best among those. Formally, best[i][j] = 1 + max best[p][q] overall p,q such that (i < p < q < j) and S[i]+S[j] <= S[p]+S[q]. This solution works in O(n^4).\n\nCan this solution be improved? Not directly. Usually if we want to take a maximum over some possibilities, we can do it faster if we use an efficient data structure, but in this case the condition is rather ugly, as we need to select the maximum of some ugly three-dimensional subspace.\n\nIn cases like the one above it is sometimes possible to reduce the complexity by taking one dimension out into the order in which we evaluate the subproblems. This is precisely the technique that will help us solve this problem as well.\n\nBefore we apply it, we’ll think about a better visualization of the problem we are solving. Instead of using the definition from the statement, we can define NRSs as follows: an NRS is a sequence of intervals with two properties:\n\nThey are properly nested, i.e., each one lies strictly inside the previous one.\nTheir weights are nondecreasing. (Here, the weight of [i,j] is defined as S[i]+S[j].)\nThe general scheme of our solution will still be the same as above: for each interval we are trying to find the longest NRS that starts with this interval. Now comes the main trick. In standard interval DP problems we tend to sort the subproblems by length. In this case, that doesn’t help, as it still leads to the same problem as above. However, what does help is sorting the intervals by weight (and only using length as a tie-breaker).\n(Remark: Any other single dimension would also work, but as i, j are small and weights can be large, this is the most convenient way.)\n\nImagine that we have all possible intervals sorted by weight (min to max), and intervals with the same weight sorted by length (max to min). By doing this sort, we eliminated one dimension of the original problem. We are now asking for the longest sequence of intervals with the following properties:\n\nIt is a subsequence of this sequence. (This is now trivial.)\nThe intervals are properly nested.\n\nIn order to find the optimal solution, we will process our sorted sequence back to front. Whenever processing an interval, the optimal solution that starts with it can be found by taking a maximum over the solutions for all intervals that 1. have already been processed, and 2. lie strictly inside this interval.\n\nThus, we can use a data structure that can perform point updates (we just computed a new value) and rectangular queries (what is the maximum among the already computed values in this range?). One such data structure is a 2-dimensional range tree. This data structure can perform the necessary operation in O(log^2 n), and thus the total time complexity becomes O(n^2 log^2 n).\n\n## MostFrequentLastDigit revisited\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15286)\n\nThe cool thing about this problem is that it can be solved completely at random, which is quite a rare thing in programming contests :)\nMore precisely, here is a perfectly valid solution:\nwhile True:\ngenerate a random array of valid numbers\nif it has all other desired properties, return it\nHere’s the same thing actually implemented in Python.\n\n```\ndef valid_number():\nwhile True:\nx = randint(0,10**9 - 1)\nif x % 10: return x\ndef solve(n,d):\nwhile True:\nA, B = [ valid_number() for _ in range(n) ], [0]*10\nfor i in range(n):\nfor j in range(i):\nB[ (A[i]+A[j]) % 10 ] += 1\nif len(set(A)) == n and max(B) == B[d] and B.count(max(B)) == 1:\nreturn A\n```\n\nYep, that’s it. Why does it work? And, more importantly, how could one read the problem statement, come up with this approach and trust that it will work? I’ll answer these questions below. Note that I’ll intentionally skip most of the details. Everything below can be turned into exact computations, but the main point of the following text is precisely to show how to avoid those tedious computations and just make an educated guess.\n\nFirst of all, the random array will be very unlikely to contain collisions. From the birthday paradox we know that a collision becomes likely if the number of items approaches roughly the square root of the length of the array. Here, we are selecting 200 random numbers from among 900 million roughly evenly distributed ones. We should be safe, collisions should be quite rare. (Of course, this step can be skipped by the alternate easy construction where we set A[i] = randint(1,9)+10*i f*or all valid i. This guarantees no collisions and the same distribution of last digits, at the cost of having to think a little bit more.)\n\nSecond, if we just take a random array and look at the last digits of its pairwise sums, some digit will usually win. Sometimes there will be a tie for the maximum (do you see how this relates to the div1 medium problem?) but quite often the maximum should be unique. If we a) didn’t have the asymmetry introduced by banning the last digit 0, and b) ignored the possibility of ties for the maximum, each digit would be the most frequent digit in pairwise sums with probability 1/10. And that would mean that on average generating 10 valid arrays should be enough to hit one correct answer.\n\nWe now need to take into account the two factors we ignored above. How big is the bias, and how big is the possibility of a tie? When I first considered this problem, I did the following back-of-the-envelope estimates:\nIf we have x,y from {1,2,...,9}, there are clearly 9 ways to get the sum 0 and 8 ways to get any other sum.\n\nThus, for the code shown above, the expected value of B[0] is (9/81)* (the number of pairs), and for each other B[i] it is (8/81)* (the number of pairs). The number of pairs is roughly 20,000, so the expected number of 0s is about 250 higher than the expected number of any other digit.\nFor a binomial distribution with n trials the standard deviation is on the order of sqrt(n), so the actual numbers in a trial will easily go a hundred or two up or down. That is enough to a) expect that max(B[1:10]) will be unique most of the time, because the range of possible values is large enough; and b) expect that max(B[1:10]) has a reasonable chance to beat B[0].\nAnd if we need a small number of random trials to get an input for which max(B[1:10]) > B[0], we only need 9 times that many trials to get an input for which a specific B[d] is the unique maximum.\n\nIn order to train your intuition, I suggest two things. First, work out the math I did at least a bit more precisely and think about what assumptions you can and cannot make. Second, play around with the implementation to see whether and how actual data you’ll measure matches the estimates you made. If there are discrepancies, try to find out where they came from.*","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-747-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4VxJ3xPOmxtqSniIQeSbE4","type":"Entry","createdAt":"2020-04-20T12:42:13.497Z","updatedAt":"2026-02-16T22:41:00.372Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":38,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 748","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2019-01-26T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 748 Editorials\n\nThe round was held on 26th Jan, 2019. Thanks to __[misof](https://profiles.topcoder.com/misof)__ for the problems and the editorials.\n\n## CopyingHomework\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15289)\n\nIn open-ended problems like this one, the best course of action is usually choosing the solution that’s the easiest to implement. In this case, probably the easiest solution is to pick five fixed changes that sum to zero, such as (-1,-1,-1,-1,+4).\n```\ndef solve(friendsHomework):\na, b, c, d, e = friendsHomework\nreturn ( a+1, b+1, c+1, d+1, e-4 )\n```\n\n## Yllion\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15284)\n\nThis problem is also educational in that it introduces you to a little-known but very nice system to name those intermediately large numbers (by which I mean numbers huge to a layperson and still tiny to a mathematician who works with large numbers). Knuth’s system is really easy to use, and our implementation of the solution will illustrate that nicely. The only special case in the whole system is the prefix “one” that is used whenever “ten” isn’t. Other than that, everything is very logical.\n\nEach of the strings corresponds to some exponent of 10, and the exponent for the whole number is simply the sum of all those exponents. For example, if “myllion” is 10^8 and “tryllion” is 10^32, “myllion tryllion” is 10^(8+32). Thus, in order to convert a string to the exponent, we simply split the string into words and sum the exponents associated with those words.\nAnd the other conversion (exponent back to string) is just the same thing in reverse. The exponents themselves are powers of two, so we simply look at those. For example, if we want to express 10^40 as a string, we need to write 40 in binary and see which powers of two are present. In our case, 40 = 32 + 8, so the two words we’ll use are “myllion” and “tryllion”. All that remains is to concatenate them in the right order (largest last).\n\nIn my implementation (shown below) I’m using a regular expression to check which of the strings “ten”, “myriad”, etc. are present in the string. This is just me being lazy. Another possible implementation is to split() the input string into pieces and then use standard string comparison manually, or a map that directly assigns the right exponent to each of the given strings.\n\n```\nstatic String[] names = {\"ten\", \"hundred\", \"myriad\", \"myllion\", \"byllion\",\n\"tryllion\", \"quadryllion\", \"quintyllion\", \"sextyllion\", \"septyllion\",\n\"octyllion\", \"nonyllion\", \"decyllion\"};\npublic int getExponent(String a) {\nint answer = 0;\nfor (int d=0; d<names.length; ++d) {\nif (a.matches(\".*\\\\b\" + names[d] + \"\\\\b.*\")) answer += 1 << d;\n}\nreturn answer;\n}\npublic String makeNumber(int exponent) {\nString answer = \"\";\nfor (int d=1; d<names.length; ++d) {\nif ((exponent & 1<<d) != 0) answer = answer + \" \" + names[d];\n}\nif (exponent % 2 == 0) return \"one\"+answer; else return \"ten\"+answer;\n}\npublic String getPower(String a, String b) {\nreturn makeNumber( getExponent(a) + getExponent(b) );\n}\n```\n\n## EraseToGCD\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15292)\n\nThis problem is an easy exercise in dynamic programming. Imagine that you are walking along the given sequence and taking decisions which numbers to keep and which ones to erase. At any moment, your state can be described by two variables: how many elements you already processed, and if you kept any, what is their GCD.\n\n(Note that the reason why we can do this is that GCD is associative. Namely, if\nGCD(a[0],...,a[k-1]) = g, then GCD(a[0],...,a[k]) = GCD(g,a[k]).)\n\nFor each of the states described above we compute the number of ways in which it can be reached. Then, the answer is the number of ways to reach the state (I’m at the end of the whole sequence, I kept some numbers with GCD=goal.)\n\n```\npublic int countWays(int[] S, int goal) {\nint[] oldc = new int[1001];\nfor (int d=1; d<=1000; ++d) oldc[d] = 0;\nfor (int s : S) {\nint[] newc = new int[1001];\n// count ways if we erase this element\nfor (int d=1; d<=1000; ++d) newc[d] = oldc[d];\n// count ways if we append this element to a preexisting sequence\nfor (int d=1; d<=1000; ++d) { int g = gcd(d,s); newc[g] += oldc[d]; if (newc[g] >= 1_000_000_007) newc[g] -= 1_000_000_007;\n}\n// count the sequence that starts here\n++newc[s];\nif (newc[s] >= 1_000_000_007) newc[s] -= 1_000_000_007;\noldc = newc;\n}\nreturn oldc[goal];\n}\n```\n\n## UnreliableRover\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15290)\n\nHow to deal with the question marks in the input? An obvious solution would be to try all possibilities for each of them. If there are q question marks, this would give us 4^q possibilities to try. Sadly, that is too much for the constraints in this problem. The key observation is that we can be a bit smarter and try only 2^q possibilities: for each ‘?’ we will only choose whether the movement was horizontal or vertical.\n\nWhy can we do that? Why doesn’t the exact direction matter?\n\nFirst of all, note that the movements are commutative and associative. In human words, their order does not matter. If we rearrange the order of some movements, the rover will end up in the same spot. (Each movement is a vector, and the result is always the sum of those vectors.) Thus, we can rearrange the input to move all ‘?’ movements to the end.\n\nNow, let’s solve the task if there are no ‘?’s. First, clearly the two dimensions are independent. We can consider all ‘N’+’S’ movements to find where we can be in one direction and separately we can look at ‘E’+’W’ movements for the other direction. Then, any combination of those will be possible. Thus, the answer is (the number of possible x coordinates) times (the number of possible y coordinates).\n\nAnd it’s even simpler than that: in each coordinate, the reachable cells after each movement will be contiguous. This is easy to show by induction. In the beginning, there is only one cell where you can be. And if you can be exactly in any one of the cells in [x1,x2] and you are told to move by a number of steps that is in [a,b] to the right, you can end anywhere in [x1+a,x2+b]. (Same goes for moves to the left.) Also note that the length of the range grew by exactly |b-a|.\nThus, we can now process all “NEWS” commands and calculate the dimensions of the rectangle that contains the rover after the last of those commands. Note that we don’t care about its exact location, only the dimensions matter.\n\nNow we get back to the ‘?’ commands. Suppose instead of those we have some ‘H’ commands (move horizontally) and some ‘V’ commands (move vertically). Thanks to the fact that for these commands minSteps=0 we can continue in the same way. If you can be anywhere in the range [x1,x2] and you get a command “move by at most d in either direction”, you will then be able to end exactly anywhere in the range [x1-d,x2+d]. Thus, the final area will always be a rectangle. Additionally, for the ‘H’ and ‘V’ commands the center of that area always remains in the same spot.\n\nIn order to get the total area, we need to try all 2^q possibilities for which ‘?’ commands are ‘H’ commands and which are ‘V’ commands, and we need to compute the union of these rectangles. This is very simple (i.e., we don’t need general rectangle union) because 1. these rectangles all share the same center, and 2. if we sort them by width they are also sorted by height in the other direction, because the total length of all ‘?’ commands is always the same, so the more we assign to ‘H’, the less remains for ‘V’ and vice versa. Thus, essentially all we need to do is to generate 2^q points and sort them.\n\n## Rectoggle\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15294)\n\nIn order to tackle this problem, you need at least some basics of combinatorial game theory - in particular, you should already be familiar with the Sprague-Grundy values of positons. If you aren’t familiar with this concept, you probably won’t be able to follow the explanation.\nSo, we have a game in which we toggle some lights. The first observation is that this game is finite. This is because of the rule that whenever you toggle some lights, the one that is on the bottom right must go off. (Let’s assign weights to cells in such a way that the weight of a cell (r,c) is 1 + the sum of all other cells in the rectangle from (0,0) to (r,c). Then, each move decreases the total weight of lit cells.)\n\nThe second, and much more important observation is that the lit cells can be considered independent subgames. This is not obvious at all -- after all, some moves toggle multiple lit cells, right? The key observation here is as follows: Imagine that instead of toggling lights the cells of the grid are boxes. In the beginning, the lit cells turn into boxes that contain a marble. The rule for this new game: “Pick any valid rectangle such that its bottom right corner has a marble. Remove that marble and put a marble into each other cell in that rectangle.”\nThe two games are almost identical. The similarity is that the parity of marbles in the new game = the state of the light in the original game. And we can use this similarity to argue that the winning strategies for both games are essentially the same. Whoever would win from a position in the LED game, wins from the position in the marble game by playing the same moves. Whenever there are two marbles in a cell, these don’t influence the outcome because they represent two identical and independent games. The player who would be winning if the two marbles weren’t there will also win if they are there. All they need to do in addition to their original strategy is to mirror their opponent’s turns that play one of these two independent games.\nThus, we can solve the Rectoggle game in the standard way: by assigning the Sprague-Grundy value to each lit cell and then checking whether the bitwise xor of those values is zero or not.\nOf course, assigning those values isn’t trivial: we have 10^10 possible cells. The author’s solution works for larger dimensions as well, but constraints were kept low to prevent overflows and to make it easier to get accepted with a solution that is based on guessing and successfully precomputing the patterns in SG values.\n\nAs I already mentioned patterns, this was indeed one way to go. In order to find out how the game behaves, it is almost always a good idea to implement the standard solution (i.e., memoized recursion that computes the SG value of a state by trying all possible first moves from that state) and to print and examine the values for small positions.\n\nTo some surprise, one thing we can experimentally discover is that maxrows and maxcols don’t really influence the game as much as we would expect. For example, the game plays exactly the same for maxrows=4 and maxrows=7. (What that means is that even if we allow some additional moves, the winning player doesn’t need them and for some reason they don’t help the losing player not lose.)\n\nA more general version of the pattern that can be observed is as follows: the game doesn’t change if we lower maxrows and maxcols to the largest power of two that’s less than or equal to their original values. Then, the pattern of SG values is a periodically repeating maxrows*maxcols rectangle. Additionally, in that rectangle we can make two more observations: First, the values in its first row/column are powers of two (more precisely, it’s always the largest power of two that divides (index+1)), and second, the other values are uniquely determined by the first values in their row and column. That is, each row that starts “1” looks exactly the same, and so on.\n\nIf we assume that these observations are true, it is possible to precompute and store all the 17*17 different SG values we might need: essentially, just do the standard solution but only for the cells you don’t “know” yet.\n\nOf course, there is a nicer way to solve the task completely without relying on unproved assumptions. The key concepts here are “NIM multiplication” and the “Tartan theorem”. Much as the SG values can be used to argue about sums of independent games, there is also a known way to handle “products of games” in some specific sense.\n\nConsider the one-dimensional version of the game: you have a line of LEDs and only one constraint maxcols. For this version, we can easily prove by induction that the SG values match what we saw in the first line of the 2D matrix we printed above. Then, we can note that our two-dimensional game is the product of two such one-dimensional games: whenever we flip a set of cells in the 2D version, it is the carthesian product of a set we could flip in one one-dimensional game and a set we could flip in the other, and vice versa. The Tartan theorem shows that all such products of games can be solved in the same way: the SG value of a position in the 2D game is the nim-product of the SG value of the row position in the row game and of the SG value of the column position in the column game. Here, the nim-product is a specific multiplication-like function that is the same for all such games, regardless of the specific rules of the 1D games that were multiplied.\n\nFor this particular solution, a full implementation of the nim-product wasn’t necessary, because all our 1D SG values are powers of two and those are easy to nim-multiply.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-748-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7va3bgSAkekMzpULMWWvQ1","type":"Entry","createdAt":"2020-04-20T12:42:13.495Z","updatedAt":"2026-02-16T16:41:45.333Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":38,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 749","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-02-06T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 749 Editorials\n\nSRM 749 was held on 2nd Feb. Thanks to [Blue.Mary](https://profiles.topcoder.com/Blue.Mary) for the setting the problems and Vasyl[alphacom] for testing the round and penning the editorials.\n\n## Div 2 Easy - FightMonsterDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15297)\n\nIn this problem you have to find a sum of an arithmetic progression with duration terms. The k-th term (0-based) is equal to attack * (1 + level*k/100). Since the size of the given sequence is at most 100,000 the sum can be computed by simple iteration over all the terms.\n\nThe time complexity of such approach is O(duration).\n\n## Div 2 Medium - TransformBoardDiv2\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15299)\n\nIn this problem you are given an N by M binary matrix. You can perform the following operation multiple times: choose two different cells in the same row or the same column. Let A is the value in right \\ top cell and B is the value in the other chosen cell. If A=B then assign A=0, B=0, otherwise assign A=0, B=1. You are also given a target matrix and your task is to find any sequence of operations which leads to the target matrix.\n\nThere are 2^(N*M) distinct binary matrices and N*M*(N - 1 + M - 1) distinct operations. Since the matrix sizes are small there are at most 2^16 different matrices and 96 different operations.\n\nLet's build a graph which vertices are binary matrices of the given sizes and edges are operations connecting them. Now our task is to find if two given vertices belong to the same connected component and if so build any path between them. This can be done by DFS or BFS. If we run BFS from one of the vertices, we'll find a path of the minimal length, which is not required though.\n\nThe time complexity is O((N + M) * N * M * 2^(N*M)).\n\n## Div 2 Hard - CountSubarrays\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15301)\n\nIn this problem you are given an array of integers and you have to count the number of its contiguous subarrays with a product equal to the given number X modulo 744,444,499 which is a prime number.\n\nFirst, let's split the given array by 0 values it contains and get a set of subarrays with no 0 values. Each such subarrays has no 0 products. If X is 0 then the answer can be easily calculated by subtracting the number of subarrays for each of the set subarray from an overall number of subarrays. Otherwise the answer is the sum of answers for each of the set subarrays.\n\nFor each set subarray we calculate partial products modulo 744,444,499. Let a partial product at position k (1-based) is P[k] and P[0] = 1. For position k we are looking for values P[k]/X modulo 744,444,499 among P[0], P[1], ..., P[k-1]. This can be done by storing value counters in a map. Note that 1/X = X^(744,444,499-2) modulo 744,444,499 as 744,444,499 is prime.\n\nThe time complexity is O(N * log(N)).\n\n## Div 1 Easy - FightMonsterDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15296)\n\nIn this problem you are given an infinite arithmetic progression. The k-th term (0-based) is equal to attack * (1 + level*k/100). Let T be the minimal integer such that the sum of the first T terms of the given sequence is at least hp. You have to minimize a time and there are two options:\n* find T, time = T;\n* multiply any duration consecutive terms of the sequence by 5, find T, time = T+1;\n\nWe can find the minimal time independently for both options and then choose a smaller one. In order to find T we could iterate over the sequence terms and stop as soon as we have at least hp as a sum. However this approach could be too slow as hp might be as large as 10^12.\n\nSince all sequence terms are positive, a binary search can be used to find T instead. Basically at each binary search iteration we fix T and compute a partial sum using arithmetic series formulas.\n\nFor the second option note that the given progression is non decreasing. Thus it is always optimal to multiply terms with larger indices. A partial sequence sum in this case can be computed as a sum of two arithmetic series.\n\nThe time complexity is O(log(hp)).\n\nNote that you have to be careful in order to avoid integer overflows. One of the possible solutions is to use 128 bit integers.\n\n## Div 1 Medium - TransformBoardDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15298)\n\nIn this problem you are given an N by M binary matrix. You can perform the following operation multiple times: choose two different cells in the same row or the same column. Let A is the value in right \\ top cell and B is the value in the other chosen cell. If A=B then assign A=0, B=0, otherwise assign A=0, B=1. You are also given a target matrix and your task is to find any sequence of operations which leads to the target matrix.\n\nThe following two observations help to come up with a solution:\n* any two 1s can be replaced with two 0s in one or two operations;\n* 1 located at (r1, c1) and 0 located at (r2, c2) such that r1 <= r2 and c1 <= c2 can be swapped in one or two operations.\n\nLet's try to construct a solution in two stages:\n* every 1 in the target matrix corresponds to 1 in the current matrix\n* target and current matrices are the same\n\nStage 1. It's easy to see that each 1 can be only moved down and right. Let's iterate the target matrix from the top to the bottom and from the left to the right. If at position (r1, c1) target matrix contains 1 and current matrix contains 0 we have to find a free 1 in the current matrix and move it to (r1, c1). For that purpose we can consider all cells (r2, c2) such that target matrix contains 0 at (r2, c2), current matrix contains 1 at (r2, c2) and r2 <= r1, c2 <= c1. Note that greedy approach works here and it's always optimal to choose any such cell with the maximal c2.\n\nStage 2. If stage 1 is completed successfully consider all cells where target and current matrices differ. Obviously if the number of such cells is odd we can not complete stage 2. Otherwise use the first observation to get rid of all free 1s in the current matrix.\n\nNote that the total number of operations is at most the number of cells. The time complexity is O(n^2 * m^2) for the simplest implementation which can be easily optimized to O(n^2 * m).\n\n## Div 1 Hard - TurnOffLightsDiv1\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15300)\n\nIn this problem you have to find a minimal length cycle which should include a given set of vertices in a specific graph.\n\nAssume we are at a stair cell of some floor. Sometimes it makes sense to move around the floor and then get back to the initial stair cell. However we must not do it more than once for each stair cell. Moreover if we do such returns from both floor ends some its cells might be never visited. Obviously it is optimal to have the longest floor gap (continuous subinterval with no lights) unvisited.\n\nNow let's build a dynamic programming solution where a floor can be in one of four states:\n* no lights are visited\n* all lights are visited\n* only lights to the left of the longest gap are visited\n* only lights to the right of the longest gap are visited\n\nA DP state can be described as a set of floor states plus a current stair position.\n\nTransitions between states are the following:\n* move up or down if possible\n* move to the other end of the floor and mark it as visited\n* move to the corresponding floor gap and return, update the floor state.\n\nWe can use Dijkstra algorithm to find the minimal distance to the final state. Note that the answer does not exceed two times number of the given cells. Thus instead of a priority queue it is enough to have a regular deque for each possible value.\n\nThe time complexity is __O(N * 4^N)__.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"Kti40712QT55MZwopkkXi","type":"Entry","createdAt":"2020-04-20T12:42:14.134Z","updatedAt":"2020-04-20T12:42:14.134Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"vasylalphacom","tcHandle":"vasylalphacom"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-749-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"73s1VjE6rcux1GIVeHTKDA","type":"Entry","createdAt":"2020-04-20T12:42:13.589Z","updatedAt":"2026-02-16T16:22:26.379Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 750","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2019-02-08T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 750 Editorials\n\n## LexOrder\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15303)\n\nLet’s start by finding out when can the answer be “IMPOSSIBLE”. Clearly, this happens if and only if the string B is immediately after the string A in the lexicographic order. So, this is our question: given a string A, when does the next string exist and how do we find it?\nStrings that are bigger than a given string A fall into two categories: strings that start with A, and strings that don’t. For example, if A = “cat”, a string from the first category is “cathode” and a string from the second category is “ceiling”.\n\nIt should be obvious that any string from the first category is smaller than any string from the second category. This is because already within the first length(A) characters there is a difference, and that difference is in favor of the string that still matches the original string A. In our example, “cathode” < “ceiling” because on index 1 we have ‘a’ < ‘e’.\n\nThus, when looking for the next string after A, we have to look among strings that start with A. Each of these strings has the form A + (some suffix). And thanks to how string comparison works, the smaller the suffix, the smaller the whole string will be. Thus, among all strings that start with A the smallest string is A itself, and the second smallest string is obviously A+’a’.\nThis gives us a full solution that is really easy to implement: Set C = A + ‘a’. If C = B, the answer is “IMPOSSIBLE”. And if it isn’t, you just found a string C such that A < C < B, and you can return it.\n\n```\ndef between(A,B):\nC = A + ‘a’\nif C == B: return “IMPOSSIBLE”\nelse: return C\n```\n\nAddendum: You may have wondered about the way-too-general phrasing I used in the first paragraph. What’s up with “when does the next string exist”? Isn’t it obvious that in an ordering there is always a next string? Well, it isn’t. And to see why, just look at the same question in the opposite direction. Given that B = “cat”, what is the immediately previous string in lexicographic order?\n\nAnother interesting question to ponder: how far is it from “cat” to “dog”? That is, if you start with “cat” and always go to the next string in lexicographic order, after how many steps will you reach “dog”?\n\n## VisitN\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15304)\n\nThere were many different ways to solve this task. The limit of 2000 moves is quite generous and allows for many strategies.\n\nFor example, one possibility was to simply run a depth-first search (DFS) from the cell where you started. DFS will eventually visit the whole board. During DFS, you will discover each of the 900 cells exactly once, and you will leave it as finished exactly once. Thus, the total number of steps will be below 2000. To get a full solution, you just need to track the number of cells visited so far, and stop as soon as you have discovered n of them.\n\nIn our reference solution we opted for a solution with a much simpler implementation. In order to traverse the whole board we first go to the top left corner (by taking r steps north and c steps west) and then we just use a fixed pattern to visit everything (e.g., 29 steps east, step south, 29 steps west, step south, repeat). As in the above solution, this would solve the task for n = 900. If we are given a smaller value of n, all we need to do is to count the number of visited cells and stop as soon as the count reaches n.\n\n```\npublic String visit(int n, int r, int c) {\nString visitEverything = \"\";\nfor (int i=0; i<r; ++i) visitEverything += 'N';\nfor (int i=0; i<c; ++i) visitEverything += 'W';\nfor (int i=0; i<15; ++i) {\nvisitEverything += \"EEEEEEEEEEEEEEEEEEEEEEEEEEEEES\";\nvisitEverything += \"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWS\";\n}\nString answer = \"\";\nboolean[][] visited = new boolean[30][30];\nfor (int a=0; a<30; ++a) for (int b=0; b<30; ++b) visited[a][b] = false;\nint visitedCount = 1;\nvisited[r][c] = true;\nfor (char step : visitEverything.toCharArray()) {\nif (visitedCount == n) break;\nanswer += step;\nif (step == 'N') --r;\nif (step == 'S') ++r;\nif (step == 'W') --c;\nif (step == 'E') ++c;\nif (!visited[r][c]) { ++visitedCount; visited[r][c] = true; }\n}\nreturn answer;\n}\n```\n\nChallenge: How would you solve the task with the strictest possible limit of only 899 moves?\n\n## IdenticalBags\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15305)\n\nThe key property to observe in this problem is that the answer is monotonous. If we can make K identical bags, we can also make K-1 bags (by filling them in exactly the same way and having more candy left over). Thus, if the answer is X, it forms a threshold: If the number of bags you want to form is less than or equal to X, it can be done, otherwise it cannot.\n\nThis suggests that a good way to look for the right X would be binary search. And indeed, the question “can we make K identical bags?” turns out to be much easier than the question “what is the maximum number of identical bags we can make?”\n\nThe main thing we gained by rephrasing the question is that once we fix K, we can fill the bags using a very simple greedy algorithm. How many candies of type i can I place into each bag? Obviously, at most (candy[i] div K). Sum this up over all i, and you’ll get one of two outcomes. If each of your bags contains fewer than bagSize candies, the value K is obviously too large, otherwise it’s obviously small enough. And that’s all we needed.\n\nWhen doing the implementation, we need two more technical details. The first detail is the upper bound for the binary search. Clearly, if you set K > max(candy), you cannot put any candy into your bags. Hence, a good upper bound was max(candy)+1. Alternately, you could hard-wire the value 10^18 + 1, which is guaranteed to be too large.\n\nThe second detail was to avoid accidental overflows. This is something that should not happen to a properly implemented binary search, as the smallest value of K you will test will be more than half of the correct X, and thus the number of candies in the bag will be at most twice the required number. Still, some loose implementations may get bitten by something like trying K = 1 for the maximum input and getting a bag with 10^20 candies. An alternative for such solutions is to stop counting as soon as your current bag size exceeds the desired amount. This is also shown (although not necessary) in the implementation given below.\n\n```\npublic long makeBags(long[] candy, long bagSize) {\nlong lo = 0, hi = 1_000_000_000_000_000_001L;\nwhile (hi - lo > 1) {\nlong med = (hi + lo) / 2;\nlong filled = 0;\nfor (long c : candy) {\nfilled += c / med;\nif (filled >= bagSize) break;\n}\nif (filled >= bagSize) lo = med; else hi = med;\n}\nreturn lo;\n}\n```\n\n## SimulateBST\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15302)\n\nEveryone who has learned how BSTs work should know what their main issue is: if you don’t do any balancing, the operations on them can be slow because some branches of the tree can be very deep, and the time complexity of all operations is linear in the depth of the tree. Thus, the task name is deceiving you a little bit. If you do a straightforward simulation, it will time out.\n\nI was delighted when I came up with the idea of this problem and realized that there are very simple ways to simulate BST insertion efficiently. Of course, we will be “cheating”: we’ll use more powerful data structures to do so. Below, I describe the approach that has the simplest implementation among the ones I know.\n\nThe key observation is that whenever we have some BST, we can look at the null pointers in the tree - i.e., the places where a node doesn’t have a child. Each of these is a possible place for the next insertion. And, more importantly, each of these corresponds to a range of values. A sample tree is shown in the figure below, with the places for future addition labeled A through E.\n\n40\n/ \\\n20 60\n/ \\ / \\\nA B C 70\n/ \\\nD E\n\nHere, any value in the range (-inf,20) will be inserted at A, anything in the range (20,40) at B, (40,60) goes to C, (60,70) to D, and (70,+inf) to E.\n\nHence, our very simple way to simulate the BST insertions efficiently will use two data structures:\n\nA map “depths” where the keys are numbers already in the BST, and the value associated with the key is the depth of the node with that number. (We need this to discard duplicates and properly report their depth.)\n\nAn ordered map “ranges” where we store the current ranges, and the depth of the root node of each of those. In the figure above, the depth of range A is 2.\n\nWhenever we get a new insertion, we proceed as follows:\nLook for it in “depths” to see whether it’s a duplicate. If it is, report its depth and we are done.\n\nIn logarithmic time, find the range in “ranges” that contains the new value. Set the depth of the new value to the depth of that range, and split the range into two smaller ones, one deeper than the previous one.\n\nIn the implementation I’m using one additional trick: As the beginning of the next range is the same as the end of the previous one, we can store the end of each range implicitly. Thus, the key into “ranges” will be simply the left endpoint of each range. This is how simply the entire insertion is then implemented:\n```\nif (depths.containsKey( S[n] )) {\nD[n] = depths.get( S[n] );\n} else {\nint left = ranges.floorKey( S[n] );\nD[n] = ranges.get( left );\nranges.put( left, D[n]+1 );\nranges.put( S[n], D[n]+1 );\ndepths.put( S[n], D[n] );\n}\n```\n\nThis solution simulates each insertion in O(log n) time, hence its total time complexity is O(n log n).\n\n## PurpleSubsequences\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15306)\n\nAlgorithmically, the most interesting part of this problem is probably the one where we need to make sure we only count each subsequence once, even if it has multiple occurrences. How do we do that? A general technique for problems like this one is to pick one “canonical” occurrence of each sequence and only count that one. In this particular problem, the occurrence we’ll pick is the one that would be picked greedily - i.e., the one with the lexicographically smallest sequence of indices.\n\nIn fact, it will be quite helpful to imagine the greedy algorithm that checks whether some sequence S is a subsequence of the given sequence A. What does this algorithm do? It looks for the first occurrence of S[0] in A, then for the first occurrence of S[1] that comes later, then for the first occurrence of S[2] that comes after that one, and so on.\n\nWe can now mimic this behavior and write a brute-force solution that will generate each distinct subsequence of A exactly once. Call generate(-1, empty sequence) to start it.\n\n```\ngenerate(last, prefix):\nfor i = last+1 to length(A)-1:\nif this is the first occurrence of A[i] we have seen in this cycle:\ngenerate(i, prefix+[ A[i] ] )\nAnother formulation of essentially the same algorithm:\ngenerate(last, prefix):\nfor each possible value v:\nfind the smallest i > last such that A[i] = v\nif that i exists:\ngenerate(i, prefix+[v] )\n```\n\nThe second component of a full solution is a way to tell whether or not our sequence contains an increasing subsequence of length up to 6. The way we’ll use in this solution is based on the online O(n log n) algorithm to find the longest increasing subsequence (LIS). This algorithm processes the elements of the sequence one at a time, and it maintains a state: a vector of values. For each i > 0, the value we store is the smallest possible x[i] such that the sequence we processed so far has an increasing subsequence of length i that ends with the value x[i].\nClearly, the length of the longest increasing subsequence is the largest i for which x[i] is defined. Additionally, the key observation that makes the algorithm efficient is that the values x[i] themselves are always strictly increasing, and whenever we process a new element of the input sequence, at most one of the x[i] changes. Thus, the algorithm can use binary search to find and update the correct x[i] efficiently. (In our solution of this problem, this part will not be necessary.)\n\nLet’s focus on the claim that the values x[i] in any state of the algorithm form an increasing sequence. Why is this the case? The answer is simple: if you can form an increasing subsequence of length 3 that ends in x[3], then by removing its last element you get an increasing subsequence of length 2 that ends in something smaller than x[2].\n\nExercise: Armed with the observation we just made, prove the claim that whenever you append a new value to the sequence, at most one of the values x[i] changes. Hint: if the new value is v, think about what happens to the first x[i] that is greater than v.\n\nIn our problem, the longest increasing subsequence we care about has length L. Thus, as soon as x[L] is defined, we do not care about the exact values x[i], we are already in the state “the current sequence is purple”. And once it is purple, it will remain purple regardless of how many additional elements we append to it. Thus, at any moment during its execution, the LIS algorithm is either in the special purple state, or its state is an increasing sequence of fewer than L integers.\n\nFor L=6 and maximum value 20, we get that the total number of states is (1 purple state) + choose(20,1) + choose(20,2) + … + choose(20,5) = 21,700. That is a nice small number.\nAnd now we can bring those two parts together to get a full solution. We will run the recursive function that generates each subsequence of A exactly once, and at any moment we will ask the question: given the prefix we already chose, how many ways to produce a purple subsequence are there? And here we bring in the second part: we do not care about the exact prefix we chose. All we care about is the index of the last value we picked (this determines where we can and cannot go next), and the state of the LIS algorithm after it processed the values we already picked (because when we know the state, we can continue the computation when we pick the next element).\nIn the above solution, there are at most n * 21,700 distinct calls of the recursive function, and thus we can get it to run within the time limit by applying memoization.\n\nIn the reference solution, instead of going for the recursive approach I used a forward-looking version of dynamic programming. In this solution, for each pair (n, LIS state) I count the number of ways in which it can be reached by the recursive generator. As an initialization, for each value v I look at its first index in A and I increment dp[that index][ the sequence [v] ] by 1. Then, I process all pairs ordered by n, and from each pair I find all possibilities for the next step of the recursive generator, and I add the number of ways to get to my current state to the number of ways to get to the new state.\n\nHere is the main body of this program:\n```\nfor (int n=0; n<N; ++n) {\nfor (int s=0; s<S; ++s) {\n// current state: the last number we picked is at index n,\n// and LIS algorithm is in state number s\n// simple optimization: if we couldn't get here, do nothing\nif (dp[n][s] == 0) continue;\n// a helper array to remember which values we've seen\nboolean[] seen = new boolean[MAXVAL];\nfor (int i=0; i<seen.length; ++i) seen[i] = false;\n// iterate over all possibilities for the next element\nfor (int n2=n+1; n2<N; ++n2) {\n// check whether this is a new value\nif (seen[ A[n2] ]) continue;\nseen[ A[n2] ] = true;\n// retrieve the current state of the LIS algorithm\n// and process the value A[n2] to get the new state\nint[] curr = decode_state(s,L);\nint[] next = LIS_step( curr, A[n2] );\nint s2 = encode_state(next,L);\n// we just discovered some new ways to reach the state (n2,s2):\ndp[n2][s2] += dp[n][s];\n}\n}\n}\n```\n\nThe final answer is then simply the sum of dp[n][purple state] over all n.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-750-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"bVCfodPfyhYkLA954NT7S","type":"Entry","createdAt":"2020-04-20T12:42:15.073Z","updatedAt":"2026-02-16T14:59:48.346Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 751","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-02-21T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 751 Editorials\n\nSRM 751 was held on Feb 21, 2019. Thanks to [majk](https://profiles.topcoder.com/majk) and [misof](https://profiles.topcoder.com/misof) for setting the problems and majk for penning the editorials\n\n## Div2 Easy: Calkin-Wilf\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15309)\n\nThe process can be simulated directly if we store the fractional representation of the current node.\n\n```\nstruct CalkinWilf {\n\n   vector <int findRational(string path) {\n\n       int a = 1, b = 1;\n\n       for (char p: path) {\n\n           if (p == 'L') {\n\n               b += a;\n\n           } else {\n\n               a += b;\n\n           }\n\n       }\n\n       return {a,b};\n\n   }\n\n};\n```\n\nComplexity is O(N).\n\n## Div2 Medium: Calkin-Wilf Reversed\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15310)\n\nConsider a non-root node (a,b) and without loss of generality let a < b. Its parent is the node (a,b-a). We can simulate the process of navigating the tree to the root. However, as the third sample suggests, that would be too slow. Note that we can perform k steps at once if b > k*a - the depth increases by k and (a,b) becomes (a,b-k*a). For performance it is optimal to take k = floor(b/a).\n\nVoila, we have invented Euclidean algorithm!\n\n```\nstruct CalkinWilfReversed {\n\n   ll getDepth(ll a, ll b) {\n\n       if (a b) return getDepth(b, a);\n\n       else if (a == 1) return b-1;\n\n       else return b/a + getDepth(b%a, a);\n\n   }\n\n};\n```\n\nThe complexity is O(log(MAX)).\n\n## Div2 Hard: Half Graph\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15295)\n\nA necessary condition for the existence of a half graph is that the degree of every vertex is even. If that is not the case, we can report that no answer exists.\n\nConsider each connected component of G individually. If the number of edges in it is odd, then there clearly is no answer. Otherwise, find an Eulerian tour (a tour which contains all edges exactly once). This exists because the degrees are even. As the length of the tour is even, we can process all edges along the tour and put odd edges into one half and even indexed into second half. Each of the halves will have the properties sought.\n\n```\nbool A[50][50];\n\nint D[50];\n\nint N;\n\nstructHalfGraph {\n\n   vector<int findEulerTour(int u) {\n\n       if (D[u] == 0) return {};\n\n       vector<int E{u};\n\n       bool done = false;\n\n       while (!done) {\n\n           int u = E.back();\n\n           for (int w = 0; w < N; ++w) {\n\n               if (A[v][w]) {\n\n                   A[v][w] = A[w][v] = false;\n\n                   D[v]--; D[w]--;\n\n                   if (u == w) done = true;\n\n                   else E.push_back(w);\n\n                   break;\n\n               }\n\n           }\n\n       }\n\n       for (int i = 0; i < E.size(); ++i) {\n\n           while (D[E[i]] != 0) {\n\n               auto sub = findEulerTour(E.get(i));\n\n               E.insert(E.begin() + i, sub.begin(), sub.end());\n\n           }\n\n       }\n\n       return E;\n\n   }\n\n   vector<string compute(vector<string x) {\n\n       N = x.size();\n\n       for (int i = 0; i < N; ++i) {\n\n           for (int j = 0; j < N; ++j) {\n\n               A[i][j] = x[i][j] == '1';\n\n               if (A[i][j]) D[i]++;\n\n           }\n\n           if (D[i] % 2 == 1) return {};\n\n       }\n\n       for (int i = 0; i < N; ++i) {\n\n           auto E = findEulerTour(i);\n\n           if (E.size() % 2 == 1) return {};\n\n           for (int j = 0; j < E.size(); j += 2) {\n\n               int u = E[j], v = E[j+1];\n\n               A[u][v] = A[v][u] = true;\n\n           }\n\n       }\n\n       for (int i = 0; i < N; ++i) {\n\n           x[i] = string(N, '0');\n\n           for (int j = 0; j < N; ++j) {\n\n               if (A[i][j]) x[i][j] = '1';\n\n           }\n\n       }\n\n       return x;\n\n   }\n\n};\n```\n\n## Div1 Easy: Hyperbox\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15313)\n\nThe surface volume of a hyperbox is 2*(a*b*c + a*b*d + a*c*d + b*c*d). Let’s backtrack the lengths of the sides starting from the shortest one. On the first three sides, we break as soon as it is clear that such hyper box does not exist. For example, given sides (a,b), if a hyperbox with sides (a,b,b,b) has too large surface volume, we can stop. The fourth side can be calculated and checked in O(1).\n\n```\nstruct Hyperbox {\n\n   int count(int volume) {\n\n       if (volume % 2 == 1) return 0;\n\n       volume /= 2;\n\n       int ans = 0;\n\n       for (ll a = 1; 4*a*a*a <= volume; ++a) {\n\n           for (ll b = a; (3*a+b)*b*b <= volume; ++b) {\n\n               for (ll c = b; (2*a*b + a*c + b*c)*c <= volume; ++c) {\n\n                   ll d = (volume - a*b*c)/(a*b + b*c + a*c);\n\n                   ans += d = c && a*b*c+a*b*d+a*c*d+b*c*d == volume;\n\n               }\n\n           }\n\n       }\n\n       return ans;\n\n   }\n\n};\n```\n\nWe can easily verify that this runs fast enough for v = 2*10^8. Let’s prove the complexity.\n\nScreen-Shot-2019-02-22-at-08.22.05-300x71\nThe time complexity is O(volume).\n\n## Div1 Medium: Wrong Base\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15277)\n\nThe natural way of solving the problem would be to first calculate x_i, then h^(x_i) and finally, the sum. However using Baby Step Giant Step algorithm directly would be too slow.\n\nInstead, we use the fact that g is a generator of the multiplicative group, hence for all h != 0 there exists an integer e, such that g^e = h. This can be found by a single invocation of BSGS. The rest is simple:\n\n```h^(x_i) = (g^e)^x_i = (g^x_i)^e = y_i^e```\n\nFinally when h = 0, the answer is 0.\n\n```\nconstexpr int MOD = 998244353;\n\nstruct WrongBase {\n\n   int pow(int a, int x) {\n\n       ll r = 1, p = a;\n\n       while (x 0) {\n\n           if (x % 2 == 1) r = (r*p) % MOD;\n\n           p = (p*p) % MOD;\n\n           x /= 2;\n\n       }\n\n       return r;\n\n   }\n\n   int bsgs(int g, int h) {\n\n       ll gS = 1, p = h\n\n       int SQRT = 32000, gInv = pow(g, MOD-2);\n\n       unordered_map<int,int M;\n\n       for (int i = 0; i < SQRT; ++i) {\n\n           M[p] = i;\n\n           (p *= gInv) %= MOD;\n\n           (gS *= g) %= MOD;\n\n       }\n\n       p = 1;\n\n       for (int i = 0; i < SQRT; ++i) {\n\n           if (M.find(p) != M.end()) return M[p] + i * SQRT;\n\n           (p *= gS) %= MOD;\n\n       }\n\n       return -1;\n\n   }\n\n   public int getSum(int g, int h, int a, int d, int n) {\n\n       if (h == 0) return 0;\n\n       int logH = bsgs(g, h);\n\n       ll ans = 0;\n\n       for (int i = 0; i < n; ++i) {\n\n           ans += pow(a, logH);\n\n           a += d;\n\n       }\n\n       return ans % MOD;\n\n   }\n\n};\n```\n\nThe complexity is O(sqrt(MOD) + n*log(MOD)).\n\n## Div1 Hard: AllInclusiveStrings\n[Problem Link\n](https://archive.topcoder.com/ProblemStatement/pm/15311)\nThe first observation is that in a string of minimal length, each letter occurs at most twice. This is because for an all-inclusive string containing x > 2 copies of a given letter, we can form a new all-inclusive string by keeping only the first and the last occurence.\n\nWe model the problem as a directed graph, where letters are vertices, and each required string is an arc.\n\nLet’s first describe a backtracking solution for generating minimal all-inclusive strings. Initially, all arcs are unmarked, and the string is all-inclusive as soon as all edges are marked.\n\nAt each position, we try to append every letter x, except if\n\nthe vertex x has degree zero, or\n\nall incoming arcs to x are already marked, or\n\nthe letter already occurs in the prefix, but some of the vertices from which there is an arc to x\n\nAfterwards, mark all arcs to x for which the source vertex is present in the prefix.\n\nIn other words, when the letter is appended for the second time, all bigrams that end with such letter must be present after this append. If they are present after appending the letter for the first time, the letter is never appended for the second time.\n\nNow we need to speed up this backtracking solution by reusing calculations, either using memoization or an explicit DP. The state is (length) * (the set of letters in prefix) * (the set of letters for which all incoming arcs are marked). There are O(N * 3^N) states, O(N) transitions from each state, and with a bit of precomputation each transition can be done in O(1). The total runtime is thus O(3^N * N^2). This seems like a lot, but since there are many unreachable states, this runs fast in practice. Furthermore, if we compute the DP row by row, the transitions can be performed in-place, and the memory complexity is 3^N words, fitting into the ML.\n\n```\nconstexpr int MOD = 998244353;\n\nconstexpr int M = 16;\n\nint C[M], P3[M+1], D[43046721];\n\nbool P[M], B[43046721], U[M][M];\n\nstruct AllInclusiveString {\n\n   vector<int shortest(vector<string A) {\n\n       int N = A.size();\n\n       if (N == 0) return {0,1};\n\n       for (int i = 0; i < N; i++) {\n\n           int a = A[i][0]-'a';\n\n           int b = A[i][1]-'a';\n\n           U[a][b] = P[a] = P[b] = true;\n\n           C[b] |= 1<<a;\n\n       }\n\n       vector<int T;\n\n       for (int i = 0; i < M; i++) if (P[i]) T.add(i);\n\n       int K = T.size();\n\n       P3[0] = 1;\n\n       for (int i = 0; i < K; i++) P3[i+1] = P3[i] * 3;\n\n       D[0] = 1;\n\n       B[0] = true;\n\n       for (int i = 1; ; i++) {\n\n           for (int j = P3[K]-1; j = 0; j--) {\n\n               if (!B[j]) continue;\n\n               int e = 0;\n\n               for (int k = 0; k < K; k++) {\n\n                   if (j / P3[k] % 3 != 0) e |= 1<<T[k];\n\n               }\n\n               for (int k = 0; k < K; k++) {\n\n                   int cur = j / P3[k] % 3;\n\n                   if (cur == 2) continue;\n\n                   bool ok = (e&C[T[k]])==C[T[k]];\n\n                   if (cur == 0 || ok) {\n\n                       int l = j + (1 + ok - cur) * P3[k];\n\n                       (D[l] += D[j]) %= MOD;\n\n                       B[l] = true;\n\n                   }\n\n               }\n\n               D[j] = 0;\n\n               B[j] = false;\n\n           }\n\n           if (B[P3[K]-1]) return { i, D[P3[K]-1] };\n\n       }\n\n   }\n\n};\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6gHA1WnDWUuz1ZtHAncxg3","type":"Entry","createdAt":"2020-04-20T12:42:14.533Z","updatedAt":"2020-04-20T12:42:14.533Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"majk","tcHandle":"majk"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/single-round-match-751-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3CinbrngRMG4A5LIQxaZxM","type":"Entry","createdAt":"2020-04-20T12:42:13.173Z","updatedAt":"2026-02-16T13:57:41.520Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":65,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 746","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-01-15T00:00:00.000Z","readTime":"30 min","content":"SRM 746 was held on Jan 15, 2019. Thanks to majk for the preparing the round and the editorials.\n\n## Div2 Easy: KidsInAYard\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15274)\n\nPhrased mathematically, we are given a system of three modular equations to solve for x:\nx mod 2 = r2\nx mod 3 = r3\nx mod 5 = r5\n\nLet the smallest positive solution be __y__. Observe that for __z = y-30__, the set of equations also holds as 30 is divisible by 2,3 and 5. Since we picked y to be the smallest positive solution, it holds __z```<=```0__, hence __y ```<=``` 30__\n\nWe can try all possible values up to 30 and see that every input has an answer in this range.\n\n```\nclass KidsInAYard {\nint howMany(int r2, int r3, int r5) {\nint x = 1;\nwhile (x%2 != r2 || x%3 != r3 || x%5 != r5) ++x;\nreturn x;\n}\n};\n```\n\nFor more details on what we just did, and how to find the answer for larger moduli, consult the entry on [Chinese remainder theorem](https://en.wikipedia.org/wiki/Chinese_remainder_theorem).\n\n## Div2 Medium: PairProduct\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15275)\n\nWe are given an array A. The task is to find two of its member whose product is exactly p.\n\nThere are two cases. Either __p=0__, and then we can find an answer if and only if the input array contains a zero as well. Alternatively, for each __a__ in A we can find __p/a__, the number with which a produces __p__. To find the index of p/a, we use simple map.\n\n```\nclass PairProduct {\nstd::vector findPair(int n, int a0, int step, long long p) {\nstd::map<int, int> I;\nfor (int i = 0; i < n; ++i) { I[a0] = i; if (a0 == 0) { if (p == 0) return {i,i}; } else if (p % a0 == 0) { auto it = I.find(p/a0); if (it != I.end()) return {i,it->second};\n}\na0 += step;\n}\nreturn {};\n}\n};\n```\n\nThe complexity is O(n log n).\n\n## Div2 Hard: FindStringEasy\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15270)\n\nIn this task we are asked to find a string having exactly n palindromic substrings.\n\nWe try to guess that there will be solutions of some form, for instance aaa..abbb.baaa.a , where the lengths of the runs of the same character are __x,y,z__, respectively. The number of palindromes of this arrangement is, provided __y```>```0__, equal to __x(x+1)/2+y(y+1)/2+z(z+1)/2+min(x,z)__. We enumerate all triples x,y,z having sum at most 100 and check whether they are solution for given __n__.\n\nWhen we run this code for all possible n, we find no solution for __n=5__ and __n=19__. Observe that a string of length __k __has at least __k__ palindromic substrings of length 1. We can use this fact and enumeration of all binary strings of length up to 5 to prove that the case __n=5__ indeed has no solution.\n\nFor __n=19__, we can find a solution either by hand, or trying four runs of the same character instead of three, to find the solution \"aaabbbaab\"\n\nCode (by [misof](https://www.topcoder.com/members/misof)):\n```\nclass FindStringEasy:\nstring withPalindromicSubstrings(int n) {\nif (n == 5) return \"\";\nif (n == 19) return \"aaabbbaab\";\nfor (int x=1;x<101;++x) {\nfor (int y=0;y<101-x;++y) {\nint current = x*(x+1)/2 + y*(y+1)/2;\nif (current == n) return string(x,'a') + string(y,'b');\nif (current < n && b > 0)\nfor (int z=1; z<101-x-y; ++z)\nif (current + z*(z+1)/2 + min(x,z) == n)\nreturn string(x,'a') + string(y,'b')\n+ string(z,'a');\n}\n}\n}\n}\n```\n\n## Div1 Easy: ChangeDistances\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15272)\n\nIn this task we are given graph G and are asked to construct graph H such that d_G(u,v) != d_H(u,v) for all u!=v.\n\nWe can simply pick the complement of G as H. Clearly, each pair of vertices u!=v is connected by an edge in exactly one of the graphs, having distance d(u,v) = 1. The distance in the second graph is strictly larger than 1.\n\n```\nclass ChangeDistances {\nvector findGraph(vector g) {\nint n = g.size();\nfor (int i = 0; i < n; ++i) {\nfor (int j = 0; j < n; ++j) {\ng[i][j] ^= i!=j;\n}\n}\nreturn g;\n}\n}\n```\n\nThe runtime is __O(n2)__.\n\n## Div1 Medium: FindStringHard\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15273)\n\nIn this task we are asked to find a string having exactly n antipalindromic substrings, where antipalindrome is a string that differs from its reverse in all positions.\n\nThere are many heuristic solutions that work. We cover two of them.\n\nGenerate string (ab){x}c{y}, where c is a random character, x is integer between 1 and 35 and y is integer between 1 and 30. This approach can generate answers for all inputs in less than a second.\n\nUse backtracking to find a solution, returning early when we are over the needed number of antipalindromes. When picking whether to use a or b, try the one that maximises the number of antipalindromes in this prefix.\n\nIf your solution is somewhat slower, you can always find all the answers offline and hardcode the solutions.\n\nBelow is code for the first approach, minus the code that counts the antipalindromes of a string by brute force.\n\n```\nclass FindStringHard {\nstring withAntipalindromicSubstrings(int N) {\nString S = \"a\";\nwhile (antipalindromes(S) != N) {\nint X = rand()%35;\nint Y = rand()%30;\nS.resize(2*X + Y);\nfor (int i = 0; i < X; ++i) { B[2*i] = 'a'; B[2*i+1] = 'b'; }\nfor (int i = 0; i < Y; ++i) B[2*X+i] = \"ab\"[rand()%2];\n}\nreturn S;\n}\n}\n```\n\n## Div1 Hard: SpaceProbes\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15268)\n\nIn SpaceProbes, we are given two lines __a__, __b__ and a point __P__. We are asked to pick __A__ on __a__, __B__ on __b__ to minimise distance between __P__ and the midpoint of segment __A__ and __B__.\n\nFirst case is when the lines __a,b__ are parallel (or identical). In such case the set of all possible centers is clearly a line p parallel and coplanar with __a__ and __b__ equidistant from both of them. The solution is to find point-line distance in 3D. This can be done, for instance, by finding a plane orthogonal to __p__, going through __P__, and find its intersection with __p__.\n\nOtherwise, let the lines a and b be skew. To show what is the set of all midpoints, we first solve the problem in two dimensions.\n\nLet __a__, __b__ be two lines in a plane intersecting at point __T__. Pick an arbitrary point __P__ outside of both lines (the case where P lies on one of the lines is trivial). We will construct the triangle ABT, where __A__ lies on __a__, __B__ lies on __b__ and __P__ is midpoint of segment __AB__. Observe that TP is a median of the triangle, and the centroid S lies in two thirds of this line segment. Project line a using homothety with coefficient -2 across __S__ to obtain a’. As a’ is parallel with a (property of homothety), it intersects b in a single point called __A__. It is now easy to construct the needed triangle. Hence, the set of all midpoints coincides with the plane.\n\nBack to the three dimensions, rotate the space so that both __a__ and __b__ are parallel to plane __z__. This transformation preserves all angles and distances, hence we can solve this instance and then perform the inverse rotation to find solution of the original problem. The z coordinate of all midpoints is now constant and independent of __x,y,__ reducing the problem to two dimensions. Hence, the set of all midpoints coincides with a plane parallel to __a__ and __b__ and equidistant from both. To find the answer, we construct this plane and then return point-plane distance.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6gHA1WnDWUuz1ZtHAncxg3","type":"Entry","createdAt":"2020-04-20T12:42:14.533Z","updatedAt":"2020-04-20T12:42:14.533Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"majk","tcHandle":"majk"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-746-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5J7l3M5WNbG15dcEX9PfvG","type":"Entry","createdAt":"2020-04-20T12:42:15.125Z","updatedAt":"2026-02-16T13:43:03.982Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":37,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 752","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-03-09T00:00:00.000Z","readTime":"25 min","content":"# SRM 752 Editorial\n\n## Poker Round\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15325)\n\n__Solution:__\n\nLet us see what happens after one round if they had 10000-x  and x initially.\n\nAfter 1 round, it becomes 2*(10000-x) and 2*x-10000.\n\nLets assume second player had z after first round.\n\nThen z=2*x-10000, i.e x= (z+10000)/2\n\nSo now we can try to go 1 step back at a time for 3 times to reach initial amounts. If the final amount is not an integer then answer is -1.\n\nCode:\n\n```\npublic int getamt(int t,int left){\nif(left==0){\nreturn t;\n}\nif(t%2==1){\nreturn -1;\n}\nreturn getamt(t+(10000-t)/2,left-1);\n}\npublic int amount(int T){\nreturn getamt(T,3);\n}\n```\n\nTime complexity:\nTo move back each round, it takes O(1) time because we are simply evaluating a formula. To move back 3 rounds, it takes O(1) operations.\n\n## Literature Optimal\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15334)\n\n__Solution:__\n\nTeja understands everyones cards if and only if at least one of Vinay or Sohail calls out the cards of the other person.\n\n__Proof:__\n\nBackward direction is trivial because when a person(say Vinay) calls out all the cards of other person(say Sohail). He knows all the cards of Sohail. He also knows his cards. So he can deduce the set of Vinay.  Hence, Teja knows exact distribution of all the cards.\n\nForward direction:\n\nAssume each have atleast one card which was not called by other person. Lets say such card with Sohail is x and Vinay is y. Now,Teja cannot say who has x and who has y. Hence, atleast one of Vinay or Sohail should call out cards of other person.\n\nNow lets say during history, Vinay called x cards of Sohail and Sohail called y cards of Vinay. Let us see how to compute this from the history. Any card Vinay calls must belong to Teja or Sohail, so if a card called by Vinay is not Teja’s then it must belong to Sohail. Using this, we can count number of distinct cards not belonging to Teja that Vinay called as x. Similarly y also.\n\nFor the game to end in minimal moves.The best thing that can happen is  Vinay and Sohail to call out the cards of the other player which were not called yet.\n\nSo we can just simulate their steps assuming each one calls the cards not yet called of the other person.\n\nCode:\n\n```\npublic int minTurns(int n,int[] Teja,int[] history){\nint y=history.length;\nint[] a0 = new int[12345];\nTreeSet<Integer set1 = new TreeSet<Integer();\nTreeSet<Integer set2 = new TreeSet<Integer();\nint i;\nfor(i=0;i<n;i++){\na0[Teja[i]]=1;\n}\nfor(i=0;i<y;i++){\nif(i%3==1 && a0[history[i]]==0){\nset1.add(history[i]);\n}\nelse if(i%3==2 && a0[history[i]]==0){\nset2.add(history[i]);\n}\n}\nint lef1 = set1.size();\nint lef2 = set2.size();\nlef1=n-lef1;\nlef2=n-lef2;\nif(lef1==0 || lef2==0)\nreturn 0;\ni=y;\nint cnt=0;\nwhile(true){\ncnt++;\nif(i%3==1)\nlef1--;\nif(i%3==2)\nlef2--;\nif(lef1==0 || lef2==0)\nreturn cnt;\ni++;\n}\n}\n```\n\nTime Complexity: O(n+size(history)). size(history) because we have to iterate the whole history array.  The simulation part takes O(n) because in every three steps, we discover 2 unknown cards. Since total number of unknown cards is atmost 2*n, we need O(n) turns in simulation and simulating each turn takes O(1) time.\n\nProblems to try: Div1 Medium is a problem with similar background sharing some part of the solution.\n\n## Literature\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15326)\n\n__Solution:__\n\nTeja understands everyones cards if and only if atleast one of Vinay or Sohail calls out the cards of the other person.\n\n__Proof:__\n\nBackward direction is trivial because when a person(say Vinay) calls out all the cards of other person(say Sohail). He knows all the cards of Sohail. He also knows his cards. So he can deduce the set of Vinay.  Hence, Teja knows exact distribution of all the cards.\n\nForward direction:\n\nAssume each have atleast one card which was not called by other person. Lets say such card with Sohail is x and Vinay is y. Now,Teja cannot say who has x and who has y. Hence, atleast one of Vinay or Sohail should call out cards of other person.\n\nNow let's say during history, Vinay called x cards of Sohail and Sohail called y cards of Vinay. Let us see how to compute this from the history. Any card Vinay calls must belong to Teja or Sohail, so if a card called by Vinay is not Teja’s then it must belong to Sohail. Using this, we can count number of distinct cards not belonging to Teja that Vinay called as x. Similarly y also.\n\nLet us dp state dp[person][call1][call2] as expected number of turns needed for Teja to understand everyone’s cards if current turn belongs to person and Vinay has called out call1   cards of Sohail and Sohail has called out call2 cards of Vinay. Let us person takes values 0,1,2 representing Teja, Vinay, Sohail respectively,\n\nWe can define the following recurrence relations.\n\ndp[2][call1][call2] = ((n-call2)/(2*n)) * dp[0][call1][call2+1]  + ((n+call2)/(2*n)) * dp[0][call1][call2] +1.\n\nThe first term corresponds to player 2 calling a card that gives new information. Second term corresponds to player 2 calling a card that gives no new information.\n\ndp[1][call1][call2] = ((n-call1)/(2*n)) * dp[2][call1+1][call2] + ((n+call1)/(2*n)) * dp[2][call1][call2] +1.\n\nSimilar explanation as first equation.\n\ndp[0][call1][call2] = dp[1][call1][call2] + 1\n\nWhatever card Teja calls, it's never informative because he knows his own cards.\n\nNow if the dependency graph of these equations was a DAG, then we could have directly solved this as a standard dp.\n\nBut the dependency graph contains cycles (for example if player 1 and player 2 calls cards which do not give new information then we come back to the same state where we started),\n\nTo avoid this, one idea is we can solve using Gaussian Elimination.\n\nThere is a more easier approach, we can rewrite the equations in such a way that there will be no cycles.\n\ndp[0][call1][call2] = dp[1][call1][call2] + 1\n\ndp[1][call1][call2] = ((n-call1)/(2*n)) * dp[2][call1+1][call2] + ((n+call1)/(2*n)) * dp[2][call1][call2] +1.\n\nThe second and third from previously defined equations remains the same. Let us expand the first equation a little more.\n\ndp[2][call1][call2] = ((n-call2)/(2*n)) *( dp[0][call1][call2+1] +1)  + ((n+call2)/(2*n)) *  ((n-call1)/(2*n)) *(dp[2][call1+1][call2] +3) + ((n+call2)/(2*n)) *  ((n+call1)/(2*n)) *(dp[2][call1+1][call2] +3).\n\nThe terms are as follows,\n\n1st : player 2 calls a new card of player 1.\n\n2nd: player 2 calls a card of no new information and player 0 move is irrelevant and player 1 calls a card of some new information\n\n3rd: player 2 calls a card of no new information and player 0 move is irrelevant and player 1 calls a card of no new information\n\nWe can rewrite last equation as\n\n(1 -  ((n+call2)/(2*n)) *  ((n+call1)/(2*n))) *dp[2][call1][call2] = ((n-call2)/(2*n)) *( dp[0][call1][call2+1] +1)  + ((n+call2)/(2*n)) *  ((n-call1)/(2*n)) *(dp[1][call1+1][call2] +3) + ((n+call2)/(2*n)) *  ((n+call1)/(2*n)) *3 .\n\nNow the dependency graph is a DAG, Hence we can solve the problem like it is a standard dp problem.\n\nProof that dependency graph is DAG :  We can see that from every state either one of the card  counts (call1 or call2 ) rises or index of the person called rises. Hence ,there cannot be cycles.\n\nCode:\n\n```\nint n;\ndouble[][][] dp = new double[3][1003][1003];\nint[][][] visit = new int[3][1003][1003];\npublic double getprob(int val1,int val2){\ndouble x=1.0;\nx*=val1;\nx/=val2;\nreturn x;\n}\npublic double solve(int person,int given1,int given2){\nif(given1==n || given2==n){\nreturn 0;\n}\nif(visit[person][given1][given2]==1)\nreturn dp[person][given1][given2];\nvisit[person][given1][given2]=1;\nif(person==2){\ndp[person][given1][given2] = getprob(n-given2,2*n) *\n(solve((person+1)%3 , given1,given2+1)+1);\ndp[person][given1][given2] + = getprob(n+given2,2*n) *\ngetprob(n-given1,2*n) * (solve(person,given1+1,given2)+3);\ndp[person][given1][given2] + = getprob(n+given2,2*n) *\ngetprob(n+given1,2*n)*3;\ndp[person][given1][given2] / = 1-getprob(n+given2,2*n)*\ngetprob(n+given1,2*n);\n}\nelse if(person==1){\ndp[person][given1][given2] = getprob(n-given1,2*n) *\n(solve((person+1)%3,given1+1,given2)+1);\ndp[person][given1][given2] + = getprob(n+given1,2*n) *\n(solve((person+1)%3,given1,given2)+1);\n}\nelse{\ndp[person][given1][given2]=solve(person+1,given1,given2)+1;\n}\nreturn dp[person][given1][given2];\n}\npublic double expectation(int _n,int[] Teja,int[] history){\nn=_n;\nint y=history.length;\nint[] a0 = new int[12345];\nTreeSet<Integer set1 = new TreeSet<Integer();\nTreeSet<Integer set2 = new TreeSet<Integer();\nint i;\nfor(i=0;i<n;i++){\na0[Teja[i]]=1;\n}\nfor(i=0;i<y;i++){\nif(i%3==1 && a0[history[i]]==0){\nset1.add(history[i]);\n}\nelse if(i%3==2 && a0[history[i]]==0){\nset2.add(history[i]);\n}\nif(set1.size()==n || set2.size()==n){\nreturn i+1;\n}\n}\nint given1=set1.size();\nint given2=set2.size();\ndouble ans=solve(y%3,given1,given2);\nans=ans+y;\nreturn ans;\n}\n```\n\nTime Complexity :O (n*n + size(history)) , Initial preprocessing takes O(size(history)) time. Dp table has 3*n*n states with each taking  O(1) time to be computed. Hence, time complexity for the dp part is O(n*n).\n\n## Reconstruct Number\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15312)\nLet us define the dp state dp[pos][dig]  as if it is possible to fill the digits from the pos position (assuming zero based indexing) and previous digit was dig. We will handle the first digit (position 0)(separately as it has different restrictions.\n\nLet us define nex[pos][dig] as the best digit to give to current position so that we reach minimum number from pos position till end obeying all the restrictions.  \n\nSince the total number of digits in the final number is always same at any state, The key observation to minimise the number is  pick the first digit as small as possible. So now we can use dynamic programming to solve this.\n\nIterate from 0 to 9 for the current digit, check if comparison given holds between previous digit and current current digit and also dp[pos+1][current digit] this is true. Then current digit can be chosen at present position. Choose the minimum one among all those satisfying the criteria.\n\nFor the first digit, we iterate from 1 to 9 , and all are valid digits with respect to comparison because there is comparison it needs to hold because it does not have previous digit.\n\nThe computation of dp states will be clear from the code.\n\nAnd finally we can reconstruct the answer using the nex array built during the dp.\n\nCode:\n\n```\nint n;\nstring s;\nint dp[12345][12],nex[12345][12],visit[12345][12];\nint solve(int pos,int dig){\nif(pos==n)\nreturn 1;\nif(visit[pos][dig])\nreturn dp[pos][dig];\nint i;\nvisit[pos][dig]=1;\nfor(i=0;i<10;i++){\nif(s[pos]=='=' && dig==i){\nif(solve(pos+1,i)){\ndp[pos][dig]=1;\nnex[pos][dig]=i;\nreturn 1;\n}\n}\nif(s[pos]=='<' && dig<i){\nif(solve(pos+1,i)){\ndp[pos][dig]=1;\nnex[pos][dig]=i;\nreturn 1;\n}\n}\nif(s[pos]=='' && digi){\nif(solve(pos+1,i)){\ndp[pos][dig]=1;\nnex[pos][dig]=i;\nreturn 1;\n}\n}\nif(s[pos]=='!' && dig!=i){\nif(solve(pos+1,i)){\ndp[pos][dig]=1;\nnex[pos][dig]=i;\nreturn 1;\n}\n}\n}\nreturn 0;\n}\nstring printans(int dig){\nstring ans=\"\";\nint i=0;\nwhile(i<=n){\nans+=(char)(dig+'0');\ndig=nex[i][dig];\ni++;\n}\nreturn ans;\n}\nclass ReconstructNumber{\npublic:\nstring smallest(string comparisons){\ns=comparisons;\nn=s.length();\nint i;\nfor(i=1;i<10;i++){\nif(solve(0,i)){\nreturn printans(i);\n}\n}\nreturn \"\";\n}\n};\n```\n\n## Token Doubling Game\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15327)\n\nFirst let us see what exactly is happening in the game.\n\nLet us denote number of token on the  table as x and in hand as y.\n\nIf heads, y=1 then x=x+y\n\nIf tails, x=x-y then y=2*y,\n\nIf x goes outside (1,2*n-1)  then game ends.\n\nNow let us define dp[i] as expected number of coin flips for the game to end with currently having x=i and y=1.\n\nThe key observation is we want to consider possible moves from a state such that always the state we reach has y=1. So the kind of moves we can consider from a state is something like  tail,tail,... head (till first head occurs or x goes out of the range). Since as tails keep occuring , y increases exponentially and x decreases at a exponential rate as tails increase. So we can observe there can atmost O(logn) tails continuously such that x still stays in range.  So number of possible moves from a state will be O(logn) because each move is the type (Tail)*Head or only tails until you go below x=1. Now we can try to write these dynamic programming equations , We will try to give a taste of how the equation looks for a particular i.\n\ndp[i] = ½(dp[i+1]+1) + ¼(dp[i]+2) +⅛(dp[i-2]+3) + …\n\nSimilarly we can write other equations. Also dp[2*n]=0.\n\nNow we can observe that we cannot solve this dp straight forward because there are cycles. One way to solve is to use gaussian elimination. The complexity of gaussian elimination is n*n*n which is not enough.\n\nNow we can rewrite the equation written for i=1,2,....,2*n-2 such that\n\n½(dp[i+1]+1) = -¾(dp[i]) + ½  + ⅛(dp[i-2]+3) + …\n\nSo now we have expressing i = 2,3,...., 2*n-1 using only lower indexed states.\n\nAnd we still haven't used dp equation written for 2*n-1.\n\nSo we can take equation written for dp[2*n-1] and keep removing highest indexed term by substituting its formula using only lower indexed terms (as found above). Finally we will be left with some equation of the form  a*dp[1]-b =0. And dp[1] = b/a = b *(a^(-1)).\n\nNow once we find dp[1], we can use\n\n½(dp[i+1]+1) = -¾(dp[i]) + ½  + ⅛(dp[i-2]+3) + …\n\nTo find all the dp values. We need to return dp[n]  because initially x=n and y=1.\n\nNow, question guarantees few things such as inverse exists. Do you see a way to prove inverse exists ? We could not see a way, so we simulated all the possible values for n from 1 to 100000 and checked that always inverse existed at the step where dp[1] is calculated.\n\nCode:\n\n```\npublic class TokenDoublingGame{\npublic long getpow(long a,long b){\nlong mod=(1000*1000*1000+7);\nlong res=1;\nwhile(b!=0){\nif(b%2==1){\nres*=a;\nres%=mod;\n}\nb/=2;\na*=a;\na%=mod;\n}\nreturn res;\n}\npublic long inverse(long val){\nlong mod=(1000*1000*1000+7);\nreturn getpow(val,mod-2);\n}\npublic int expectation(int n){\nif(n==1){\nreturn 1;\n}\nlong inv2=inverse(2);\nlong mod=(1000*1000*1000+7);\nlong[] dp = new long[2*n+10];\nlong[] ans = new long[2*n+10];\nlong[] remem = new long[2*n+10];\nlong[] pr = new long[200];\nlong[] st = new long[200];\nArrayList<Integer states_reachable[] = new ArrayList[2*n+10];\nArrayList<Long coeffs[] = new ArrayList[2*n+10];\nlong prob;\nlong twos,val;\nlong value=0;\nlong steps;\nint i,j;\npr[0]=1;\nfor(i=1;i<200;i++){\npr[i]=pr[i-1]*inv2;\npr[i]%=mod;\n}\nfor(i=0;i<200;i++){\nst[i]=i*pr[i];\nst[i]%=mod;\n}\nfor(i=0;i<2*n+5;i++){\nstates_reachable[i]=new ArrayList<();\ncoeffs[i]=new ArrayList<();\n}\nfor(i=2;i<2*n-1;i++){\nprob=1;\ntwos=1;\nval=i;\nvalue=0;\nsteps=0;\nj=0;\nwhile(true){\nif(val<=0){\nvalue+=st[(int)steps];\nvalue%=mod;\nbreak;\n}\nprob = pr[(int)steps+1];\nvalue+=st[(int)steps+1];\nif(val+1!=i+1){\nstates_reachable[i+1].add((int)val+1);\nif(val+1==i){\ncoeffs[i+1].add((2*prob-2)%mod);\n}\nelse{\ncoeffs[i+1].add((2*prob)%mod);\n}\n}\nval-=twos;\ntwos*=2;\nsteps=steps+1;\n}\nremem[i+1]=2*value;\nremem[i+1]%=mod;\n}\nstates_reachable[2].add(1);\ncoeffs[2].add(-2L);\nremem[2]=2;\nfor(i=2*n-1;i<=2*n-1;i++){\nprob=1;\ntwos=1;\nval=i;\nvalue=0;\nsteps=0;\nj=0;\ndp[2*n-1]=1;\nwhile(true){\nif(val<=0){\nvalue+=st[(int)steps];\nvalue%=mod;\nbreak;\n}\nprob = pr[(int)steps+1];\nvalue+=st[(int)steps+1];\nif(val+1!=i+1){\ndp[(int)val+1]-=prob;\ndp[(int)val+1]%=mod;\n}\nval-=twos;\ntwos*=2;\nsteps=steps+1;\n}\nvalue*=-1;\nvalue%=mod;\n}\nfor(i=2*n-1;i=2;i--){\nfor(j=0;j<states_reachable[i].size();j++){\ndp[states_reachable[i].get(j)]-=dp[i]*coeffs[i].get(j);\ndp[states_reachable[i].get(j)]%=mod;\n}\nvalue-=dp[i]*remem[i];\nvalue%=mod;\ndp[i]=0;\n}\nassert(dp[1]!=0);\nans[1]=-1*value*inverse(dp[1]);\nans[1]%=mod;\nfor(i=2;i<=n;i++){\nans[i]=0;\nfor(j=0;j<states_reachable[i].size();j++){\nans[i]+=ans[states_reachable[i].get(j)]*coeffs[i].get(j);\nans[i]%=mod;\n}\nans[i]+=remem[i];\nans[i]=-1L*ans[i];\nans[i]%=mod;\n}\nans[n]%=mod;\nans[n]+=mod;\nans[n]%=mod;\nreturn (int)ans[n];\n}\n}\n```\n\n__Time Complexity__: Since each equation of size O(log(n)). We need O(nlogn) time to find all the equations. Each equation will be substituted atmost once. So we need O(nlogn) time. And to evaluate all the equations from bottom to top , we need O(nlogn) time.\n\nHence, total time complexity is nlogn.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"ngf3PiJzyUzZn7ouBvbJv","type":"Entry","createdAt":"2020-04-20T12:42:16.217Z","updatedAt":"2020-04-20T12:42:16.217Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"teja349","tcHandle":"teja349"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-752-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7m6Vab2QLQnFvhfaW45FYv","type":"Entry","createdAt":"2026-02-13T10:36:41.800Z","updatedAt":"2026-02-16T11:08:25.250Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":134,"revision":12,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Member Onboarding CheckList","slug":"topcoder-member-onboarding-checklist","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2xnuR6XfyQ27hYwm05msdB","type":"Entry","createdAt":"2020-01-09T19:03:44.828Z","updatedAt":"2020-01-09T19:03:44.828Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Account","trackParent":"Topcoder"}}],"tags":["General Info","Onboarding"],"creationDate":"2026-02-13","readTime":"3 min","content":"Here is the Topcoder Member onboarding checklist:\n\n### 1.Topcoder Member Registration\n\na. Visit [topcoder.com](https://www.topcoder.com/) and click on Sign Up button to proceed for account registration.\n\n![01 Sign Up](//images.ctfassets.net/piwi0eufbb2g/1E26FGRpLj5kfiHSZES7UG/27065ad274cd2b366a8d035e7f315ec2/01.webp)\n\nb. Fill in all required fields, check the agreement box, and click __Sign Up__.\n\n![Sign Up](//images.ctfassets.net/piwi0eufbb2g/5QM0c0rBuWF9ZqzIfRMnkc/a928ca84f90ac0a3cd3f5514dc156362/Sign_Up.png)\n\nc. You will see the activation code on your entered email inbox, enter it on below screen and click on continue.\n\n![03](//images.ctfassets.net/piwi0eufbb2g/4EB7G5gNdBH8qqk6gRfSbo/c1c20653103b8e89d5c61f73ddd9bdae/03.webp)\n\nd. On next screen, you will redirected to set up MFA , Click on Google Authenticator or similar. Scan the QR code and enter the 6 digit code from the Authenticator App. \n\n![04](//images.ctfassets.net/piwi0eufbb2g/2qenG37lVSSeqlPudo55la/7c2b9aca0cf480a6dfa929f55d1ca445/04.webp)\n\ne. After setting up MFA, you will be redirected to [Topcoder Top Technology Talent On-Demand](https://onboarding.topcoder.com/skills) to finalize your profile. Once you complete the profile, your account registration will be finished. \n\n![05](//images.ctfassets.net/piwi0eufbb2g/6Cw6ycbxJHWxD2Syz2ynLb/64543b3a8097da2238c4d348a2d8e799/05.webp)\n\n### 2.Complete the Non-Disclosure Agreement (NDA) \na. Visit the link: [Topcoder Competition NDA](https://www.topcoder.com/challenges/terms/detail/c41e90e5-4d0e-4811-bd09-38ff72674490), tick the checkbox and click on continue.\n\n![06](//images.ctfassets.net/piwi0eufbb2g/5vOIEhDhVgDQJPEs4j7njS/5a27ad7e1b0286193fa69b129af3187d/06.webp)\n\nb.Scroll down to bottom, fill the address details and scroll down, click on Finish.\n\n![NDA Fill](//images.ctfassets.net/piwi0eufbb2g/Sr1vhBDGgnRZR4Hyev4VR/2a356f871aefadf132d88583407c5e5c/NDA_Fill.png)\n\n### 3.Agree to the Topcoder Standard Terms \n\na. Visit [Topcoder Standard Terms](https://www.topcoder.com/challenges/terms/detail/564a981e-6840-4a5c-894e-d5ad22e9cd6f).\n\nb. Review the terms, tick the checkbox, and click __Continue__ to confirm your acceptance.\n\n![08](//images.ctfassets.net/piwi0eufbb2g/2Ce1NY8QgUNwXKyb6MzFVw/68ad42b6f594f444ad608bef3fe9b7d0/08.webp)\n\n### 4.Set Up Wallet Payout Information\n\na. Navigate to the [Wallet Payout](https://wallet.topcoder.com/#payout) section in your Topcoder account.\n\nb. Update all fields under General Information. \n   i.Ensure that the details you provide are accurate and match exactly with the address information you will enter in your tax form.\n   ii.Based on your country of residence, the payout bank country will be automatically selected.\n\n![Payment Setup](//images.ctfassets.net/piwi0eufbb2g/6sv4R7wDDOqMEd9MEuN13V/f270c99819c6001773653ab75e0af567/Payment_Setup.png)\n\nc. Once the general information is updated, proceed to __Add Payout Method__ and fill in all required details.\n\n![10](//images.ctfassets.net/piwi0eufbb2g/1SlhcHfvUstg8TtS2llo7r/50ff5486a28f9c1094e535c11f92440d/10.webp)\n\n- __Note__: The fields displayed may vary depending on your country.\n   ![11](//images.ctfassets.net/piwi0eufbb2g/5CrMJ4wYsiK09chae9Oeff/0dd4ada15369f2a9ff992a8aa4515dc1/11.webp)\n\n### 5. Submit Tax Form\n\na. After successfully submitting your payout method, proceed to the __Tax Form__ section.\n\n![12](//images.ctfassets.net/piwi0eufbb2g/2Sq6XUuHm111497IQuJIo0/facbc8b0e82fb194ceb8239ef3b172c3/12.webp)\n\nb. Select the appropriate options based on the information entered in __General Information__ —these details must match.\n\nc. The correct tax form type will be displayed automatically based on your selections.\n\n![13](//images.ctfassets.net/piwi0eufbb2g/2ZP3b53BIqUF0KsqLBBx5n/664c3ee446a38bcbf9c27f9cbf602d07/13.webp)\n\n- __Note__: Topcoder cannot provide tax advice for legal reasons. If you have questions about your tax form, please consult a qualified tax adviser\n\nd. Click __Continue__, select the agreement checkbox, and click __Certify__ to submit your tax form for approval.\n\n![W8BEN](//images.ctfassets.net/piwi0eufbb2g/qxAT1unKWtpDIsNbCHdjB/64983e093a0960f16b5dfff3c94ef52b/W8BEN.png)\n\ne. Once verified, the status will change to __Reviewed__.\n\n- If the status remains __Submitted__ for an extended period, please contact Topcoder Support for assistance. (support@topcoder.com)\n\n### 6.Complete Identity Verification\n\na. After your tax form is submitted, you can proceed to the __Identity Verification__ step.\n\n![bank details](//images.ctfassets.net/piwi0eufbb2g/5xG3zSE9H0ovG1ldCaFLzw/d8b5082bed1b1dd1564aec947a80271f/bank_details.png)\n\nb. Upload a valid government‑issued ID.\n\n   i. Ensure that the name and address on your ID match the details provided in your earlier onboarding steps.\n\nc. Complete the verification process as instructed on the screen. \n\n![16](//images.ctfassets.net/piwi0eufbb2g/7aInvwFajIB6qIFSftsqcs/ff09f8a0879731e690f1a0174e8b340f/16.webp)\n\nThat's it! Your onboarding is now complete.✅","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1TlqUx1nGJjrenmM3uJzmi","type":"Asset","createdAt":"2022-10-21T14:49:03.618Z","updatedAt":"2023-09-15T21:00:19.700Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"How to be an Effective Freelancer, Freelancing with Topcoder and More","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1TlqUx1nGJjrenmM3uJzmi/dab38d05faeb5c03db7f377a309ce6ba/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6bPz6YSWA43zpnYnjRQWnf","type":"Entry","createdAt":"2025-11-29T21:57:08.425Z","updatedAt":"2026-02-09T17:00:54.108Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":14,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Lovely Professional University Students Setup Guide","slug":"lovely-professional-university-students-setup-guide","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}}],"tags":["Account setup","Discord"],"creationDate":"2025-11-28","readTime":"2 min","content":"These are the guidelines for LPU (Lovely Professional University) students on how to set up their Topcoder accounts, complete onboarding, and join Discord.\n\n### Topcoder Registration\nThese are the steps to register on Topcoder:\n\nCheck the video below for how to register on Topcoder or follow the listed steps:\n[https://www.youtube.com/watch?v=ZNd_2b1Zvp0](https://www.youtube.com/watch?v=ZNd_2b1Zvp0)\n\n1. Click on the Get Started button from the LPU Homepage. \n__Note: Please use this button exclusively to register to remain part of the LPU University group on Topcoder and access associated opportunities.__\n![Image Header LPU.png](//images.ctfassets.net/piwi0eufbb2g/6gBteKQnIwN9pMPwq7qIw6/eb33d60b438c38235f9d58a1a12e32ea/Image_Header_LPU.png)\n\n2. You will be taken to the Topcoder Login up page. Click on Sign up tab and provide the required details and Sign up\n![img01](//images.ctfassets.net/piwi0eufbb2g/p3dsQ1wj5aVhIruXm0vES/635400405a573e93e526af9a9faacc3c/img01.png)\n\n3. Check your email for account activation code and enter it\n![img02](//images.ctfassets.net/piwi0eufbb2g/6xkp58EUmT4nZQZd6qeWOB/83b55679326166d196ce5afda7a10d32/img02.png)\n\n4. Set up your MFA (Multi-Factor Authentication)\n![img03](//images.ctfassets.net/piwi0eufbb2g/33ZZXw2JCHnT9QhPJ7B6gB/e14adba89e57e84dd3dfbdd936723b8f/img03.png)\n\nOnce you have set up your MFA you are successfully registered to Topcoder and will be taken to the onboarding flow.\n\n### Topcoder Onboarding\nKeeping your skills and profile information up to date increases your chances of getting more work.\n\n1. Update your skills\n![img04](//images.ctfassets.net/piwi0eufbb2g/5cIg8YRcx3rsVBTdtkg6a2/70609f03c4376c64b666975a6a249a9d/img04.png)\n\n2. Update your availability status\n![img05](//images.ctfassets.net/piwi0eufbb2g/6MWhLHFbkDUuFl56M56RyZ/363df36be22dcc48b393e331c44bdf35/img05.png)\n\n3. Update your work experience if you have any\n![img06](//images.ctfassets.net/piwi0eufbb2g/5blJkVl3tvLa9joGI7nW5J/7f4e325865f157a0565370940adc28be/img06.png)\n\n4. Update your education details\n![img08](//images.ctfassets.net/piwi0eufbb2g/4E64MHLha98fJA8wjH5Bcb/3903dd7b565b2f73891dd23f8c7523f1/img08.png)\n![img07](//images.ctfassets.net/piwi0eufbb2g/3Q6Esr2OmZLmqaXww3qdEV/fa3a0218768329ec3c6e6e33c5c63a46/img07.png)\n\n5. Upload your profile photo and enter your Bio details\n![img09](//images.ctfassets.net/piwi0eufbb2g/1snKHmXqd6LgdYkIsIOQNC/29478627a10fd5b76d26f3f0cf80bf22/img09.png)\n\nYou have successfully completed your Topcoder onboarding and will be taken to your profile page.\n\n### Submit to a Topcoder challenge\nCheck out this video to see how to submit to a Topcoder challenge\n[https://www.youtube.com/watch?v=ic6klMM9_r0](https://www.youtube.com/watch?v=ic6klMM9_r0)\n\n### Joining Discord \nAfter creating your Topcoder account and finishing the onboarding process, you’ll be able to join the Topcoder Discord to engage with other members.\n\nWatch the video below or check the screenshots.\n[https://www.youtube.com/watch?v=dXBkCW6dhP0](https://www.youtube.com/watch?v=dXBkCW6dhP0)\n\n1. From the LPU home page click on “Connect Now” from the Join Discord section.\n![img10](//images.ctfassets.net/piwi0eufbb2g/2QsvFyZwU7hAQ9k2ejkLs7/e372d10136eb790eacabc61e0ab6eae9/img10.png)\n\n2. Create an account on Discord if you don't have one. If you have an account, please log in.\n![img11](//images.ctfassets.net/piwi0eufbb2g/Nr4K7EioykNOCNN2IJjeo/3d4f645e02f194419c3121a16db23a03/img11.png)\n\n3. Click on Accept Invite\n![img12](//images.ctfassets.net/piwi0eufbb2g/31NuIOoRVHzAQFtL4gvmN2/f3e69b3f5664f0da9b3d3ea9ffc28532/img12.png)\n\n4. Verify your Topcoder account \n![img13](//images.ctfassets.net/piwi0eufbb2g/4VsHElV8JtemBPvMuag9rK/01b7135e9e1ebfa85f1799fce26adbdb/img13.png)\n\nClick on the link below\n\n![img14](//images.ctfassets.net/piwi0eufbb2g/1sqkkUGLZu94nxsHIwm2Zh/1178b24429211f31435d710a57cd986d/img14.png)\nYou will be redirected to Topcoder and asked to login. \n\nOnce you login you will be sent back to Discord and you will be verified. \nYou will now be able to connect with Topcoder members and have access to Topcoder channels.\n\n![img15](//images.ctfassets.net/piwi0eufbb2g/4z8qPxtJrXgFhc834AU5Zv/76f6033b337eb46ad587f99a7015cd7b/img15.png)\n\n__Note__: If you are not able to complete verification for any reason, please try again.  If you still have issues with the verification in Discord, please message the Topcoder community manager, DaraK, in Discord to help.\n\nFor any general issues or questions, you can reach us at support@topcoder.com","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yO45g1yJfxerGOktJVufM","type":"Asset","createdAt":"2022-10-18T14:37:19.496Z","updatedAt":"2023-09-15T21:03:26.749Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"Being a Successful Topcoder Freelancer","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7yO45g1yJfxerGOktJVufM/a283509c9e75aeb72730662fb1bc989a/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YlyriCI08lCzbTbBI9tBP","type":"Entry","createdAt":"2020-04-20T12:42:17.860Z","updatedAt":"2026-02-06T22:36:45.610Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":26,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 753","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-03-20T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 753 Editorials\n\n## Div II Easy: KerimJavati\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15355)\nFor each l like L, it takes 2 * distance(‘a’, L) + 1 seconds for Kerim to type it.\n\nTime complexity is O(text.size())\n\n```\npublic static int howLong(String text) {\n\n  int ans = 0;\n\n  for (char c : text.toCharArray())\n\n      ans += 1 + 2 * (c - 'a');\n\n  return ans;\n\n}\n```\n\n## Div II Medium: CCChecker2\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15240)\nSimulate the process, several things to check:\n\nAll elements in arrays int[] moveStartRow, int[] moveStartCol, int[] moveDestRow, int[] moveDestCol, must be between 1 and n.\n\nNever two cubes could take the same position.\n\nCubes must arrive at their destination at the end.\n\nMoves must be valid.\n\nTime complexity is O(moves * m), could be improved to O(moves + m + n ^ 2).\n\n```\npublic static String check(int n, int[] startRow, int[] startCol, int[] destRow, int[] destCol, int[] moveStartRow, int[] moveStartCol, int[] moveDestRow, int[] moveDestCol){\n\n  int m = startCol.length, moves = moveStartCol.length;\n\n  if (checkArray(n, moveDestRow) || checkArray(n, moveStartRow) || checkArray(n, moveDestCol) || checkArray(n, moveStartCol))\n\n      return \"invalid\";\n\n  for(int i = 0; i < moves; i++) {\n\n      int id = -1;\n\n      for(int j = 0; j < m; j++)\n\n          if(startRow[j] == moveStartRow[i] && startCol[j] == moveStartCol[i])\n\n              id = j;\n\n      for(int j = 0; j < m; j++)\n\n          if(startRow[j] == moveDestRow[i] && startCol[j] == moveDestCol[i])\n\n              return \"invalid\";\n\n      if(abs(moveStartCol[i] - moveDestCol[i]) + abs(moveStartRow[i] - moveDestRow[i]) != 1)\n\n          return \"invalid\";\n\n      if(id == -1)\n\n          return \"invalid\";\n\n      startCol[id] = moveDestCol[i];\n\n      startRow[id] = moveDestRow[i];\n\n  }\n\n  for(int j = 0; j < m; j++)\n\n      if(startRow[j] != destRow[j] || startCol[j] != destCol[j])\n\n          return \"invalid\";\n\n  return \"valid\";\n\n}\n\nprivate static boolean checkArray(int n, int[] destRow) {\n\n  for(int x : destRow)\n\n      if(x < 1 || x n)\n\n          return true;\n\n  return false;\n}\n```\n\n## Div II Hard: MaxCutFree\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15257)\nConsider bridges, they form a forest graph, solve the problem for each tree of this forest independently. Now the problem is converted to find the maximum independent set in a tree (a set that no two vertices out of that are adjacent). Use Dynamic Programming. For each vertex, keep two values:\n\nClose: Answer for the subtree of this vertex.\n\nOpen: Answer for the subtree of this vertex if you don’t choose this vertex.\n\nNow, dp[root].close is the answer.\n\n```\npublic static class Edge{\n\n  int v, u;\n\n  public Edge(int v, int u) {\n\n      this.v = v;\n\n      this.u = u;\n\n  }\n\n}\n\npublic static class Dp{\n\n  int open, close;\n\n  public Dp(int open, int close) {\n\n      this.open = open;\n\n      this.close = close;\n\n  }\n\n}\n\npublic static final int maxn = (int) 3e5 + 17;\n\nstatic int edge[], comp[], h[], gp, d[], cnt[];\n\nstatic boolean bl[];\n\nstatic boolean seen[];\n\nstatic ArrayList<ArrayList<Integer g = new ArrayList<();\n\nstatic Edge e[] = new Edge[maxn];\n\nstatic int hi(int v, int p){\n\n  int ret = h[v];\n\n  seen[v] = true;\n\n  int parEdge = 0;\n\n  for(int i : g.get(v)){\n\n      int u = edge[i] ^ v;\n\n      if(!seen[u]){\n\n          h[u] = h[v] + 1;\n\n          int t = hi(u, v);\n\n          if(t == h[u])\n\n              bl[i] = true;\n\n          ret = min(ret, t);\n\n      }\n\n      else if(u != p && u != v)\n\n          ret = min(ret, h[u]);\n\n      else if (u == p)\n\n          parEdge++;\n\n  }\n\n  if(parEdge 1)\n\n      ret = min(ret, h[v] - 1);\n\n  return ret;\n\n}\n\nstatic void hello(int v){\n\n  cnt[ comp[v] = gp ]++;\n\n  for(int i : g.get(v)){\n\n      int u = edge[i] ^ v;\n\n      if(!bl[i] && comp[u] == -1)\n\n          hello(u);\n\n  }\n\n}\n\nstatic void build_tree(int m){\n\n  for(int i = 0; i < m; i++)\n\n      if(bl[i]) {\n\n          g.get(e[i].v).add(e[i].u);\n\n          g.get(e[i].u).add(e[i].v);\n\n      }\n\n}\n\nstatic Dp dfs(int v, int p){\n\n  seen[v] = true;\n\n  Dp ans = new Dp(0, 1);\n\n  for(int u : g.get(v))\n\n      if(u != p) {\n\n          Dp child = dfs(u, v);\n\n          ans.open += child.close;\n\n          ans.close += child.open;\n\n      }\n\n  ans.close = max(ans.close, ans.open);\n\n  return ans;\n\n}\n\nstatic public int solve(int n, int a[], int b[]){\n\n  int m = a.length;\n\n  edge = new int[maxn];\n\n  comp = new int[maxn];\n\n  h = new int[maxn];\n\n  d = new int[maxn];\n\n  cnt = new int[maxn];\n\n  bl = new boolean[maxn];\n\n  seen = new boolean[maxn];\n\n  comp = new int[n];\n\n  g = new ArrayList<();\n\n  for(int i = 0; i < n; i++)\n\n      g.add(new ArrayList<());\n\n  Arrays.fill(comp, -1);\n\n  for(int i = 0; i < m; i++) {\n\n      int v = a[i];\n\n      int u = b[i];\n\n      //System.err.println(v + \" \" + u);\n\n      e[i] = new Edge(v, u);\n\n      edge[i] = v ^ u;\n\n      g.get(v).add(i);\n\n      g.get(u).add(i);\n\n  }\n\n  for(int i = 0; i < n; i++)\n\n      if(!seen[i])\n\n          hi(i, -1);\n\n  for(int i = 0; i < n; i++)\n\n      if(comp[i] == -1){\n\n          hello(i);\n\n          cnt[gp] = cnt[gp] - 1;\n\n          gp++;\n\n      }\n\n  g = new ArrayList<(n);\n\n  for(int i = 0; i < n; i++)\n\n      g.add(new ArrayList<());\n\n  build_tree(m);\n\n  Arrays.fill(seen, false);\n\n  int ans = 0;\n\n  for(int i = 0; i < n; i++)\n\n      if(!seen[i])\n\n          ans += dfs(i, -1).close;\n\n  return ans;\n```\n\n## MojisBag:\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15254)\nKeep trie of numbers at each moment and two elements that maximize the answer, e1, and, e2.\n\nIf number x added to the bag, at first try to update the answer and if updated, update e1 and e2. Then add x to trie. Time complexity: O(log MAXV).\n\nIf number x become removed from the bag, remove it from trie. If it’s e1 or e2, clear trie, insert elements one by one again and update the answer. Time complexity: O(q * log MAXV) if x is e1 or e2, O(log MAXV) otherwise.\n\nWhat do you think about time complexity? The point is because queries are generated randomly, the probability of that x equals to e1 or e2 is 2 / n. So the mathematical expectation of time complexity is: q * (2 / q * q * log MAXV + (q - 2) / q * log MAXV) = q log (q).\n\n```\nstatic class Node {\n\n  int cnt, index;\n\n  Node left;\n\n  Node right;\n\n  public Node() {\n\n      cnt = 0;\n\n      left = null;\n\n      right = null;\n\n      index = -1;\n\n  }\n\n}\n\nstatic class Pair {\n\n  int key, value;\n\n  public Pair(int key, int value) {\n\n      this.key = key;\n\n      this.value = value;\n\n  }\n\n}\n\nstatic Node root = new Node();\n\nstatic void insert(int value, int index) {\n\n  Node cur = root;\n\n  cur.cnt++;\n\n  for (int i = 31; i = 0; i--) {\n\n      if (((1 << i) & value) == 0) {\n\n          if (cur.left == null) {\n\n              cur.left = new Node();\n\n          }\n\n          cur = cur.left;\n\n      }\n\n      else {\n\n          if (cur.right == null) {\n\n              cur.right = new Node();\n\n          }\n\n          cur = cur.right;\n\n      }\n\n      cur.cnt++;\n\n  }\n\n  cur.index = index;\n\n}\n\nstatic void remove(int value) {\n\n  Node cur = root;\n\n  root.cnt--;\n\n  for (int i = 31; i = 0; i--) {\n\n      if (((1 << i) & value) == 0) {\n\n          cur = cur.left;\n\n      }\n\n      else {\n\n          cur = cur.right;\n\n      }\n\n      cur.cnt--;\n\n  }\n\n}\n\nstatic Pair getMax(int value) {\n\n  Node cur = root;\n\n  if(root.cnt == 0)\n\n      return new Pair(-1, 0);\n\n  int res = 0;\n\n  for (int i = 31; i = 0; i--) {\n\n      int add = 0;\n\n      if (((1 << i) & value) == 0) {\n\n          if (cur.right != null && cur.right.cnt != 0) {\n\n              cur = cur.right;\n\n              add++;\n\n          }\n\n          else {\n\n              cur = cur.left;\n\n          }\n\n      }\n\n      else {\n\n          if (cur.left != null && cur.left.cnt != 0) {\n\n              cur = cur.left;\n\n              add++;\n\n          }\n\n          else {\n\n              cur = cur.right;\n\n          }\n\n      }\n\n      res = 2 * res + add;\n\n  }\n\n  return new Pair(cur.index, res);\n\n}\n\npublic static int maximumXor(int q, int base, int add, int rate) {\n\n  final int Mod = (int) 1e9 + 7;\n\n  int ans = 0;\n\n  int a[] = new int[q];\n\n  int y[] = new int[q];\n\n  int z[] = new int[q];\n\n  boolean deleted[] = new boolean[q];\n\n  int cur = 0, sz = 0, cera = -1, cerb = -1;\n\n  for(int i = 0; i < q; i++){\n\n      cur = (int) (((long) cur * base + add) % Mod);\n\n      if(cur % rate != 0){\n\n          //System.out.println(\"+ \" + cur);\n\n          Pair tmp = getMax(cur);\n\n          if(ans < tmp.value){\n\n              ans = tmp.value;\n\n              cera = sz;\n\n              cerb = tmp.key;\n\n          }\n\n          insert(cur, sz);\n\n          a[sz++] = cur;\n\n      }\n\n      else if(sz 0){\n\n          int remIndex = cur % sz;\n\n          //System.out.println(\"- \" + remIndex + \" (\" + a[remIndex] + \")\");\n\n          if(!deleted[remIndex]) {\n\n              deleted[remIndex] = true;\n\n              remove(a[remIndex]);\n\n              if (remIndex == cera || remIndex == cerb) {\n\n                  root = new Node();\n\n                  ans = 0;\n\n                  cera = cerb = -1;\n\n                  for (int j = 0; j < sz; j++)\n\n                      if(!deleted[j]){\n\n                          Pair tmp = getMax(a[j]);\n\n                          if (ans < tmp.value) {\n\n                              ans = tmp.value;\n\n                              cera = j;\n\n                              cerb = tmp.key;\n\n                          }\n\n                          insert(a[j], j);\n\n                      }\n\n              }\n\n          }\n\n      }\n\n      y[i] = ans;\n\n      //System.out.println(\"= \" + ans);\n\n  }\n\n  z[0] = y[0];\n\n  for(int i = 1; i < q; i++)\n\n      z[i] = (int) (((long) z[i - 1] * base + y[i]) % Mod);\n\n  return z[q - 1];\n\n}\n```\n\n## MojiDeletes\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15241)\nConsider xor of range [L, R] be X, we are searching for some i (L <= i <= R), such that maximizes the value X ^ a[i];\n\nWe know how to find value maximizing xor in a trie (like problem 706D from codeforces). Let’s keep a trie for each prefix of the array, name the trie constructed from numbers in the range [0, i], t[i]. For each node, keep count of the number of nodes in its subtree. Now, for answering query [L, R], we can subtract values written on nodes in t[L] from t[R + 1], from this trie we can find the answer.\n\nOne problem remains. Time complexity is now O(n ^ 2 * log MAXV). The key idea is to use persistent trie instead of constructing n tries, it reduces the time complexity to O(n * log MAXV).\n\n```\nprivate final static int Mod = (int) 1e9 + 7;\n\nstatic class PersistentTrie\n\n{\n\n  int node;\n\n  int left[],right[],data[];\n\n  int maxN=20000001;\n\n  PersistentTrie()\n\n  {\n\n      node=0;//0 is dummy node\n\n      left=new int[maxN];\n\n      right=new int[maxN];\n\n      data=new int[maxN];\n\n  }\n\n  /**Finds the number in this trie which maximizes xor with val.\n\n   * @param n is the root number of the version which is being queried.\n\n   * @param val is a 32 bit positive integer.\n\n   * @return A value from trie which maximizes the xor with val.\n\n   */\n\n  int queryMax(int n, int m, int val)\n\n  {\n\n      int ans=0;\n\n      int y=1<<30;\n\n      while(y0)\n\n      {\n\n          if((val&y)0)//current bit is 1\n\n          {\n\n              if(data[left[m]] - data[left[n]]!=0)\n\n              {\n\n                  ans+=y;\n\n                  n = left[n];\n\n                  m = left[m];\n\n              }\n\n              else if(data[right[m]] - data[right[n]]!=0) {\n\n                  n = right[n];\n\n                  m = right[m];\n\n              }\n\n              else\n\n                  return ans;\n\n          }\n\n          else//current bit is 0\n\n          {\n\n              if(data[right[m]] - data[right[n]]!=0)\n\n              {\n\n                  n=right[n];\n\n                  m = right[m];\n\n                  ans+=y;\n\n              }\n\n              else if(data[left[m]] - data[left[n]]!=0)\n\n              {\n\n                  m = left[m];\n\n                  n=left[n];\n\n              }\n\n              else\n\n                  return ans;\n\n          }\n\n          y=1;\n\n      }\n\n      return ans;\n\n  }\n\n  /**\n\n   * Insert the value val in the trie version with root n.\n\n   * @param n Root number of trie version in which insertion is to be done.\n\n   * @param val Value to be inserted.\n\n   * @param y pow(2,30) in this case.\n\n   * @return\n\n   */\n\n  int insert(int n,int val,int y)//returns the root of new trie\n\n  {\n\n      //create a new node\n\n      int cur=++node;\n\n      if(y==0)\n\n      {\n\n          data[cur]=1+data[n];\n\n          return cur;\n\n      }\n\n      if((val&y)0)//current bit is 1\n\n      {\n\n          left[cur]=left[n];\n\n          data[cur]=data[left[n]];\n\n          int r=insert(right[n],val,y1);\n\n          right[cur]=r;\n\n          data[cur]+=data[r];\n\n      }\n\n      else\n\n      {\n\n          right[cur]=right[n];\n\n          data[cur]=data[right[n]];\n\n          int l=insert(left[n],val,y1);\n\n          left[cur]=l;\n\n          data[cur]+=data[l];\n\n      }\n\n      return cur;\n\n  }\n\n}\n\npublic static long maximumXor(int n, int q, int base, int add, int qBase, int qAdd){\n\n  PersistentTrie pt = new PersistentTrie();\n\n  int a[] = new int[n + 1];\n\n  int ps[] = new int[n + 1];\n\n  int root[] = new int[n + 1];\n\n  root[0] = ps[0] = a[0] = 0;\n\n  for(int i = 1; i <= n; i++) {\n\n      a[i] = (int) (((long) a[i - 1] * base + add) % Mod);\n\n      root[i] = pt.insert(root[i - 1], a[i], 1 << 30);\n\n      ps[i] = ps[i - 1] ^ a[i];\n\n      //System.out.print(String.valueOf(a[i]) + ' ');\n\n  }\n\n  //System.out.println();\n\n  int cur = 0;\n\n  long ans = 0;\n\n  while(q-- 0){\n\n      cur = (int) (((long) cur * qBase + qAdd) % n);\n\n      int l = cur;\n\n      cur = (int) (((long) cur * qBase + qAdd) % n);\n\n      int r = cur;\n\n      if(r < l) {\n\n          int t = l;\n\n          l = r;\n\n          r = t;\n\n      }\n\n      ans += pt.queryMax(root[l], root[r + 1], ps[r + 1] ^ ps[l]);\n\n      //System.out.println(String.valueOf(l + 1) + \", \" + String.valueOf(r + 1) + \" = \" + pt.queryMax(root[l], root[r + 1], ps[r + 1] ^ ps[l]));\n\n  }\n\n  return ans;\n\n}\n\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-753-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4s4OGj7A0jjDXaJTfg3Lng","type":"Entry","createdAt":"2020-04-20T12:42:14.658Z","updatedAt":"2026-02-06T22:26:09.896Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":75,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 754","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-03-31T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 754 Editorials\n\n## MissingDwarf\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15354)\n__Used as: Division Two - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 250       |\n| __Submission Rate__       | 141 / 155 (90.97%)     |\n| __Success Rate__          | 126 / 141 (89.36%)  |\n| __High Score__            | winterflame for 248.62 points (2 mins 7 secs)       |\n| __Average Score__         | 214.04 (for 126 correct submissions)    |\n\n__Statement__\n\nYou're given [latex]6[/latex] numbers [latex]h_1,\\dots,h_6[/latex]. You need to find smallest number [latex]h_7[/latex] such that [latex]h_7 > h_k[/latex] for [latex]k=1..6[/latex] and mean value of all numbers [latex]\\frac{h_1 + \\dots + h_7}{7}[/latex] is integer.\n\n__Solution__\n\nFind maximum [latex]h_k[/latex], start with [latex]h_7[/latex] being equal this number plus one, increase it until mean value becomes integer. You will do at most [latex]6[/latex] increases, thus running time is [latex]O(1)[/latex].\n\nint getHeight(vector\n\n## SeventhPowers\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15358)\n__Used as: Division Two - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 500       |\n| __Submission Rate__       | 114 / 155 (73.55%)    |\n| __Success Rate__          | 100 / 114 (87.72%)  |\n| __High Score__            | ongchuviettel for 486.67 points (4 mins 43 secs)      |\n| __Average Score__         | 339.35 (for 100 correct submissions)   |\n\n__Statement__\n\nConsider integer [latex]A=a_{n-1}\\dots a_1a_0[/latex], You're given [latex]B=a_{0}^{7}+a_{1}^{7}+\\dots+a_{n-1}^{7}[/latex]. Construct any [latex]A[/latex] which gives such [latex]B[/latex] having no leading zeroes and length at most [latex]500[/latex]. [latex]B[/latex] itself is at most [latex]10^7[/latex].\n\n__Solution__\n\nOne of possible ways to solve the problem is to greedily pick the largest digit [latex]x[/latex] such that [latex]x^7[/latex] is less than [latex]B[/latex], then subtract [latex]x^7[/latex] from [latex]B[/latex] and append it to the answer. It may be directly checked that this will provide short enough output for all possible inputs\n\n```\nstring reconstructA(int B) {\nstring ans;\nint t = 9;\nwhile(B > 0) {\nwhile(pow(t, 7) > B) {\nt--;\n}\nans += '0' + t;\nB -= pow(t, 7);\n}\nreturn ans;\n}\n```\n\n## MoreSquares\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15362)\n__Used as: Division Two - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 1000       |\n| __Submission Rate__       | 20 / 155 (12.90%)    |\n| __Success Rate__          | 4 / 20 (20.00%)  |\n| __High Score__            | kektak for 586.75 points (28 mins 28 secs)      |\n| __Average Score__         | 500.18 (for 4 correct submissions)     |\n\n__Used as: Division One - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 250       |\n| __Submission Rate__       | 104 / 120 (86.67%)     |\n| __Success Rate__          | 56 / 104 (53.85%) |\n| __High Score__            | Egor for 237.29 points (6 mins 38 secs)   |\n| __Average Score__         | 171.60 (for 56 correct submissions)    |\n\n__Statement__\n\nYou're given set of [latex]N \\leq 3000[/latex] points [latex](x_1, y_1), \\dots, (x_N, y_N)[/latex]. You have to calculate the number of point [latex](x,y)[/latex] such that if you add them to the set, the number of quadruples of points which form square will increase.\n\n__Solution__\n\nIf point [latex](x,y)[/latex] increases the amount of squares among points, there should be two points [latex](x_i,y_i)[/latex] and [latex](x_j,y_j)[/latex] among the set forming the diagonal of that square, we can iterate over all such pairs in [latex]O(N^2)[/latex].\n\nFor given pair we can determine that center of the square is at the point [latex]\\frac{(x_i+x_j,y_i+y_j)}{2}[/latex] and two other corners are in positions [latex]\\frac{(x_i+x_j,y_i+y_j) \\pm (y_i-y_j,x_j-x_i)}{2}[/latex], thus if one of such points is present in the set and the other is not, you should add the one which is not present to the set of points constituting the answer. Note that you can't simply increment answer because single point may add several squares and it will be counted multiple times in such a case.\n\n```\ntypedef int ftype;\ntypedef complex\n```\n\n## OrthogonalProjections\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15376)\n__Used as: Division One - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 600       |\n| __Submission Rate__       | 15 / 120 (12.50%)   |\n| __Success Rate__          | 6 / 15 (40.00%)  |\n| __High Score__            | Stonefeang for 277.42 points (43 mins 9 secs)       |\n| __Average Score__         | 260.52 (for 6 correct submissions)  |\n\n__Statement__\n\nConsider set of [latex]N[/latex] distinct points [latex](x_1,y_1), \\dots, (x_N,y_N)[/latex] and a line [latex]L[/latex]. If point [latex]X[/latex] lies on the line [latex]L[/latex], the orthogonal projection of [latex]X[/latex] onto [latex]L[/latex] is [latex]X[/latex] itself. Otherwise, the orthogonal projection of [latex]X[/latex] onto [latex]L[/latex] is the unique point [latex]Y[/latex] on [latex]L[/latex] such that [latex]XY[/latex] is orthogonal to [latex]L[/latex].\n\nSuppose you are given a finite sequence [latex]S[/latex] of points in the plane. Two lines [latex]L_1[/latex] and [latex]L_2[/latex] are equivalent if the orthogonal projections of points of [latex]S[/latex] onto [latex]L_1[/latex] are in the same order as the projections of points of [latex]S[latex] onto [latex]L_2[/latex]. You have to construct the set of [latex]N \\leq 500[/latex] points having exactly given number [latex]n \\leq 10^5[/latex] of equivalence classes.\n\n__Solution__\n\nFirst of all we have to determine how to calculate the number of equivalence classes for given set. Let's look on two particular points [latex]X_i[/latex] and [latex]X_j[/latex]. What relative configuration can they have? If the line is orthogonal to [latex]X_i - X_j[/latex] then they have same projection on it, let's call this line [latex]L_0[/latex]. Otherwise they lie in one order if line goes counter-clockwise from [latex]L_0[/latex] and in the other order if it goes clockwise from [latex]L_0[/latex].\n\nIf we consider lines [latex]L_0[/latex] for all possible pairs of [latex](X_i, X_j)[/latex], they will split the unit circle in [latex]2k[/latex] segments in such a way that lines going through same segment have same configuration with respect to given set of [latex]N[/latex] points. Also each endpoint will have its own configuration different from configurations in segments. It would provide you with [latex]4k[/latex] configurations, but it also counts inverted configurations which should not be counted, thus the number of configurations will be exactly [latex]2k[/latex] where [latex]k[/latex] is the number of distinct [latex]X_i-X_j[/latex] directions up to [latex]-1[/latex] multiplier.\n\nSome manual check also tells us that it's impossible to obtain [latex]4[/latex] configurations and it's possible to obtain exactly [latex]1[/latex] configuration if you use only one point. Otherwise making [latex]n[/latex] configurations is possible if and only if [latex]n[/latex] is even. Let's consider one of possible explicit constructions to obtain [latex]n[/latex] configurations. Let [latex]t = \\lfloor \\sqrt{n} \\rfloor[/latex], begin with [latex]t[/latex] points [latex](0,0), (0,1), \\dots, (0,t-1)[/latex]. It will initialize our number of directions with [latex]1[/latex]. Now if we add arbitrary point [latex](x,y)[/latex] it will give us another [latex]t[/latex] directions. To fairly control number of new directions we will add points [latex](1,0), (1,t),(1,2t),\\dots,(1,kt)[/latex], so with each new point we will have exactly [latex]t[/latex] new directions. But for final point you will have to add some number [latex]x[/latex] which is less or equal to [latex]t[/latex]. It can be done by placing point [latex](1,(k-1)t+x)[/latex] instead of [latex]kt[/latex].\n\nFor example, look on the following diagram:\n\n1. [latex]A-B-C[/latex] and [latex]D-E-F[/latex] lie on same lines having pairwise direction [latex](0,1)[/latex].\n2. [latex]DC,DB,DA[/latex] have directions [latex](-5,2),(-5,1),(-5,0)[/latex] respectively.\n3. [latex]EA,EB,EC[/latex] have directions [latex](-5,-1),(-5,-2),(-5,-3)[/latex] respectively.\n4. [latex]FC,FB,FA[/latex] have directions [latex](-5,-3),(-5,-4),(-5,-5)[/latex] respectively.\n\nNote that because we took [latex]F[/latex] to be [latex]2[/latex] points above [latex]E[/latex] instead of [latex]3[/latex], exactly one direction to set of points [latex]\\{A,B,C\\}[/latex] was repeated. This solution works in [latex]O(\\sqrt n)[/latex].\n\n## RestoreDrawing\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15359)\n__Used as: Division One - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 900       |\n| __Submission Rate__       | 5 / 120 (4.17%)  |\n| __Success Rate__          | 1 / 5 (20.00%))   |\n| __High Score__            | tourist for 521.02 points (29 mins 9 secs)      |\n| __Average Score__         | 521.02 (for 1 correct submission)     |\n\n__Statement__\n\nYou have to construct [latex]N \\times M[/latex] grid [latex]N, M \\leq 100[/latex] such that sizes of its 4-connected components are [latex]a_1,\\dots,a_n[/latex] and sizes of its 8-connected components are [latex]b_1,\\dots,b_m[/latex]. Where for arrays holds [latex]n,m \\leq 20[/latex] and [latex]a_1 + \\dots + a_n \\leq 1500[/latex].\n\n__Solution__\n\nNote that you may take arbitrary set of [latex]4[/latex]-connected components, join it via diagonals and obtain single [latex]8[/latex]-connected component. Thus the whole solution splits in two parts: splitting sizes of [latex]8[/latex]-connected components into sizes of [latex]4[/latex]-connected components and constructing the answer.\n\nFirst part is an instance of bin packing problem. Author's approach to solve it is to fix some order on set [latex]b[/latex] and calculate [latex]dp[mask][/latex] which is equal to [latex]1[/latex] if it's possible to construct prefix of [latex]b[/latex] (maybe with some remainder) such that it splits on two distinct subsets on [latex]b_1,b_1+b_2,b_1+b_2+b_3[/latex] and so on, it may be calculated in [latex]2^n \\times n[/latex].\n\nTester approach is to use recursive function split(L, R, mask) which tries to split segment [latex]b_L, b_{L+1},\\dots, b_{R-1}[/latex] using only items presented in [latex]mask[/latex]. To do this you split [latex][L,R)[/latex] into [latex][L,M)[/latex] and [latex][M,R)[/latex], iterate over all submasks of [latex]mask[/latex] and try to split subsegment [latex][L,M)[/latex] with such submask. If it was possible, you also try to split [latex][M,R)[/latex] with its complement. It's hard to estimate working time of such solution but rough upper bound is something like [latex]3^n[/latex] which, obviously, always way less on practice.\n\nAfter you calculated possible splitting, you should compose [latex]4[/latex]-connected components with such sizes and make them into [latex]8[/latex]-connected components. One of possible ways to do it is to split the whole table by vertical line in half and fill 4-connected components alternatively, aligning them to the center. Another possible way is by using following pattern alternatively:\n\n![SRM 754 1](//images.ctfassets.net/piwi0eufbb2g/ZCaf6Kp2dIomdMjArVwOx/155427312548b324c20c45d689dd337f/SRM_754_1.webp)\n\nThus each 4-connected component is either single `#` or it is preceded and succeeded by single `#`, so that those single `#`'s maintain connection between 4-components into 8-component. Please feel free to inspect the code for better understanding.\n\n```\nconst int maxn = 1\n```\n\nBy [adamant](https://www.topcoder.com/members/adamant),\nTopcoder Member\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-754-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3zyVrun0VPPk3qUbtx7pNy","type":"Entry","createdAt":"2020-04-20T12:42:15.084Z","updatedAt":"2026-02-06T21:46:33.807Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":25,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 755","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java"],"creationDate":"2019-04-15T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 755 Editorials\n\nSRM 755 was held on April 15, 2019. Thanks to misof for setting the problems and writing the editorials.\n\n## OneHandScheduling\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15415)\nWe need to determine whether the time intervals given in the input are disjoint. If they are, Misof can do everything, if they aren’t, he cannot.\n\nOne possible solution is to look at each pair of intervals and check whether they overlap. Depending on the implementation, this may be tricky, as there are multiple different ways in which two intervals may overlap. Probably the easiest way is the following: suppose we have two closed intervals [a,b] and [c,d]. The earliest time at which both of them started is max(a,c), the latest time at which neither has ended is min(b,d). Clearly, there is an overlap if and only if max(a,c) <= min(b,d).\n\nAnother, less error-prone solution is to simply look at all integer times between 0 and 10^6, inclusive. If each of them belongs to at most one of the given intervals, they obviously have to be disjoint, and if you find a time that belongs to two or more intervals, you know that the intervals are not disjoint.\n\n```\npublic String checkSchedule(int[] tStart, int[] tEnd) {\nfor (int t = 0; t <= 1 _000_000; ++t) {\nint inside = 0;\nfor (int i = 0; i < tStart.length; ++i)\nif (tStart[i] <= t && t <= tEnd[i]) ++inside;\n}\nif (inside 1) return \"impossible\";\n}\nreturn \"possible\";\n}\n```\n\n## OneHandSort\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15416)\nThere are many different ways to sort the given sequence. The simplest one is probably the one where you consider each slot on the shelf from the left to the right. If the slot contains the correct element, you do nothing. Otherwise, you put the current element from that slot to slot N, then you move the correct element to the current (now empty) slot, and then you return the arbitrary element from slot N to the empty slot you just created.\n\n```\ndef sortShelf(target):\nN = len(target)\ntarget.append(-1) # add the empty slot\nanswer = []\nfor n in range(N):\nif n == target[n]: continue\ncorrect = target.index(n)\nanswer.append( n )\nanswer.append( correct )\nanswer.append( N )\ntarget[correct] = target[n]\ntarget[n] = n\nreturn answer\n```\n\n## OneHandSort2\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15417)\nIn this problem we have the same setting as in OneHandSort, but there are two notable differences. First, we need to actually generate a huge input, and second, we need to solve it in an optimal number of moves.\n\nIn order to generate the input, we need an efficient way to answer the query “what is the smallest unused number that is greater than or equal to x?”. In order to do this, we can use an ordered set data structure, such as “set” in C++ or “TreeSet” in Java. We will store all unused numbers in this data structure, and remove them as we assign them to the input array. Whenever we get a query, we simply use the corresponding method of the data structure -- e.g., “lower_bound” in C++ or “ceiling” in Java.\n\nIn order to solve the input optimally, note that what we have is a permutation of numbers 0 through N-1. For each permutation there is a unique way to split that permutation into cycles. (E.g., if element in slot 3 wants to go to slot 7, element in slot 7 wants to go to slot 42, and element in slot 42 wants to go to slot 3, this is one cycle.)\n\nIf we have a cycle of length 1, we don’t have to do anything: this is an element that is in its correct slot.\n\nFor any other cycle, note that when we move one of its elements for the first time, we cannot put it into the correct slot, as it is currently occupied. Hence, for a cycle of length x we need at least x+1 moves.\n\nOn the other hand, it’s easy to solve a cycle of length x in exactly x+1 moves: just move any one of its elements into the empty slot N, then do exactly x-1 moves in which you move the element that belongs to the currently empty slot into that slot (thereby freeing a slot for another element) and finally return the element from slot N into its correct slot that is now empty.\n\nIn the above example of a cycle, we would move “element 7” (meaning “the element that belongs into the slot 7”) from slot 3 to slot N, then element 3 from slot 42 to slot 3, then element 42 from slot 7 to slot 42, and finally element 7 from slot N to slot 7.\n\nHence, once we have the permutation, we split it into cycles and then compute the answer by looking at their lengths.\n\nIf we use the algorithm described above, the permutation can be generated in O(n log n) time. We can easily decompose a permutation into cycles in O(n) time, so the total time complexity remains O(n log n).\n\n```\npublic int minMoves(int N, int[] targetPrefix, int a, int b) {\nTreeSet<Integer unused = new TreeSet<Integer();\nfor (int n=0; n<N; ++n) unused.add(n);\nint[] target = new int[N];\nfor (int n=0; n<targetPrefix.length; ++n) {\ntarget[n] = targetPrefix[n];\nunused.remove( target[n] );\n}\nfor (int n=targetPrefix.length; n<N; ++n) {\nlong nextll = target[n-1];\nnextll = (nextll * a + b) % N;\nint next = (int)nextll;\nInteger tmp = unused.ceiling(next);\nif (tmp == null) tmp = unused.ceiling(0);\ntarget[n] = tmp;\nunused.remove( target[n] );\n}\nboolean[] seen = new boolean[N];\nfor (int n=0; n<N; ++n) seen[n] = false;\nint answer = 0;\nfor (int n=0; n<N; ++n) if (!seen[n]) {\nint cycleLength = 1;\nseen[n] = true;\nint where = n;\nwhile (true) {\nwhere = target[where];\nif (seen[where]) break;\nseen[where] = true;\n++cycleLength;\n}\nif (cycleLength 1) answer += cycleLength + 1;\n}\nreturn answer;\n}\n```\n\n## OneHandRoadPainting\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15418)\nThis problem is solvable greedily -- but note that not all greedy solutions work.\n\nA correct solution can be made using the following observations:\n\n- There is always an optimal solution that consists of multiple trips such that in each trip Misof begins in his home, takes the paint, walks somewhere, turns around, and on his way home he paints some segments. (It doesn’t make sense to walk across the same section twice in the same direction. Whatever you do during the second pass you could do during the first pass. It doesn’t matter whether you paint on your way there or on your way back.)\n- Consider the point farthest away from the home that needs to be painted. This point has to be painted in some trip, which means that it has to be visited in some trip. Now comes the greedy observation: in that trip, we can paint the paintPerBrush meters of the road that need painting and are farthest away from the home.\n\nIn order to prove the greedy observation, we can do a switching argument. Suppose you have an optimal solution S. If it has a trip that matches our greedy observation, we are done. Otherwise, consider the trip that visits the farthest point in S. While this trip uses fewer paint than paintPerBrush, take some painting away from some other trip and assign it to this trip. Clearly this doesn’t change the value of the solution, so we still have an optimal solution, but now the trip that visits the farthest point uses all available paint. Now, if it still doesn’t match our greedy observation, there has to be a segment (or a collection of them) closer to home that we do paint during this trip, and a segment (or a collection of them) farther from home that we don’t. Find any trip that paints anything in the second part and swap it for something in the first part. This can never worsen our solution, because our special trip remains of the same length, and on the other trip we swapped a segment for some other segment closer to home. Thus, we can change any optimal solution into one where our greedy observation works.\n\nAll that remains is to implement the greedy strategy in an efficient way. The only catch is that we cannot simulate one trip at a time: in the worst case, there can be up to 2*10^9 trips.\n\nThus, we do the following. Look at the last segment that needs to be painted. If it requires more than one trip using the greedy strategy, do all the trips at once, except for the last one. More precisely, we will do (segmentLength div paintPerBrush) trips. The total distances traveled during these trips form an arithmetic series and we can sum them up easily using a formula. This leaves us with the case where the length of the last segment is strictly smaller than paintPerBrush. We handle it by simulating one trip. In this trip we consider the segments from the back to the front. As long as we have enough paint to paint the current segment, we paint it and forget about it. Eventually, we will either run out of segments (in which case we are done) or we will run out of paint (in which case we’ll use the last remaining paint on our brush to paint the tail of the currently active segment).\n\nThis gives us a solution that runs in O(number of segments).\n\n```\npublic long fastest(int[] dStart, int[] dEnd, int paintPerBrush) {\nlong answer = 0;\nint active = dStart.length - 1;\nwhile (active = 0) {\nlong fullRuns = (dEnd[active] - dStart[active]) / paintPerBrush;\nif (fullRuns 0) {\nanswer += (2L*dEnd[active] - (fullRuns-1)*paintPerBrush) * fullRuns;\ndEnd[active] -= fullRuns * paintPerBrush;\n}\nif (dStart[active] == dEnd[active]) { --active; continue; }\nanswer += 2L*dEnd[active];\nlong paintRemaining = paintPerBrush;\nwhile (true) {\nlong paintNeeded = dEnd[active] - dStart[active];\nif (paintNeeded <= paintRemaining) {\npaintRemaining -= paintNeeded;\n--active;\nif (active == -1) break;\n} else {\ndEnd[active] -= paintRemaining;\nbreak;\n}\n}\nif (active == -1) break;\n}\nreturn answer;\n}\n```\n\n## DejaVu\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15420)\nThe first thing we do is that we go through the movie and build a data structure that maps each scene to the indices in the movie at which it occurs.\n\nConsider an array A as long as the movie. Set all its elements to 0. Then, for each scene, set the element that corresponds to its second occurrence (if it exists) to +1, and its third occurrence (if it exists) to -1. The key observation is that the number of deja vus in the first X scenes of the movie is the sum of the first X elements of this sequence.\n\nIf we want to start watching at the beginning and we are looking for the optimal moment when to stop watching, we want to find the largest among all the prefix sums of the array A. We could answer this easily in linear time, but instead of doing that we will use a data structure. The reason why we do so will become apparent in a moment.\n\nIn particular, the data structure we’ll use will be a simple interval tree (a.k.a. range tree or tournament tree) built on top of the array A. Each inner node of this tree represents some contiguous segment of A. In each inner node we will store two values: the sum of that segment, and the largest of all prefix sums for that segment only.\n\nThese values are easy to propagate along the tree. For any inner node, its sum is the sum of the sums of its children, and its largest prefix sum is either the largest prefix sum of the left child, or the sum of the left child plus the largest prefix sum of the right child.\n\nIn order to find the best end for the movie, we simply look into the root of the tree and report the maximum prefix sum found there.\n\nWhy did we choose this data structure? Well, duh, because it’s easy to update. Now that we know the optimal end, consider what happens if we shift the beginning of the movie one scene to the right. That is, the scene M[0] stopped being in the movie. What do we have to change in the array A? It turns out that we only need to update three cells: the ones corresponding to the second, third, and fourth occurrence of that same scene in the movie. Now they become the first, second, and third occurrence, and as such their contribution to the number of deja vus changes from +1, -1, 0 to 0, +1, -1. Thus, we can make these three updates (or fewer, if the scene doesn’t have that many occurrences) and after each of them we propagate the changes up the interval tree.\n\nIn this way, we can implement the operation “discard the first scene and recompute the best end” in O(log n) time, making the full solution run in O(n log n).\n\n```\nint[][] sum;\nint[][] max_psum;\nvoid update(int level, int index) {\nsum[level][index] = sum[level+1][2*index] + sum[level+1][2*index+1];\nmax_psum[level][index] = Math.max(\nmax_psum[level+1][2*index],\nsum[level+1][2*index] + max_psum[level+1][2*index+1]\n);\n}\nvoid iset(int level, int index, int value) {\nsum[level][index] = value;\nmax_psum[level][index] = value;\nwhile (level 0) { --level; index /= 2; update(level,index); }\n}\npublic int mostDejaVus(int N, int seed, int R) {\n// omitted: generate the array M as described in the statement\nint depth = 18;\nsum = new int[depth+1][];\nfor (int l=0; l<=depth; ++l) sum[l] = new int[1<<l];\nmax_psum = new int[depth+1][];\nfor (int l=0; l<=depth; ++l) max_psum[l] = new int[1<<l];\nHashMap<Integer, ArrayList<Integer occurrences\n= new HashMap<Integer, ArrayList<Integer ();\nfor (int n=0; n<N; ++n) {\nif (!occurrences.containsKey( M[n] )) {\noccurrences.put( M[n], new ArrayList<Integer() );\n}\noccurrences.get( M[n] ).add(n);\n}\nHashMap<Integer, Integer offsets = new HashMap<Integer, Integer();\nfor (int scene : occurrences.keySet()) offsets.put( scene, 0 );\nfor (int n=0; n<(1<<depth); ++n) iset(depth,n,0);\nfor (int scene : occurrences.keySet()) {\nif (occurrences.get(scene).size() = 2) {\niset(depth,occurrences.get(scene).get(1),+1);\n}\nif (occurrences.get(scene).size() = 3) {\niset(depth,occurrences.get(scene).get(2),-1);\n}\n}\nint answer = 0;\nfor (int start=0; start<N; ++start) {\nif (max_psum[0][0] answer) answer = max_psum[0][0];\nint scene = M[start];\nint off = offsets.get(scene);\nif (occurrences.get(scene).size() = 2+off) {\niset(depth,occurrences.get(scene).get(1+off),0);\n}\nif (occurrences.get(scene).size() = 3+off) {\niset(depth,occurrences.get(scene).get(2+off),+1);\n}\nif (occurrences.get(scene).size() = 4+off) {\niset(depth,occurrences.get(scene).get(3+off),-1);\n}\noffsets.put(scene,off+1);\n}\nreturn answer;\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-755-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1yUYrBjJ8ymwqfDffZWRbc","type":"Entry","createdAt":"2020-04-20T12:42:15.067Z","updatedAt":"2026-02-06T21:38:18.556Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":32,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 758","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java","Python"],"creationDate":"2019-05-15T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 758 Editorials\n\n## LongJump2\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15457)\nThe implementation is fairly straightforward. The main thing we need to realize is that it is not sufficient to keep track of the longest jump so far, we also need to know who made that jump. This is because if the same contestant later improves the maximum, the leader will not change.\n\n```\npublic int countNewLeaders(int N, int[] jumpLengths) {\nint currentLeader = -1;\nint currentBest = -1;\nint answer = 0;\nint nextJump = 0;\nfor (int round=1; round<=3; ++round) {\nfor (int jumper=1; jumper<=N; ++jumper) {\nint currentJump = jumpLengths[nextJump++];\nif (currentJump currentBest) {\ncurrentBest = currentJump;\nif (currentLeader != jumper) {\ncurrentLeader = jumper;\n++answer;\n}\n}\n}\n}\nreturn answer;\n}\n```\n\n## WildSequence\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15459)\nThere are multiple patterns that work and are easy to implement, but a little bit of care was needed: e.g., many implementations will fail the cases when head is either the smallest or the largest of all elements.\n\nHere’s one possible technique. First, imagine that head is smaller than anything in rest. One really easy solution is to alternately take the largest and the smallest element of rest to guarantee that the sequence goes up and down alternately. If head isn’t the smallest of all values, we can start by taking the smallest element of rest first (as that one is definitely smaller than head) and then fall back to the above strategy.\n\n```\npublic int[] construct(int head, int[] rest) {\nArrays.sort(rest);\nboolean nextSmallest = true;\nif (rest.length 0 && head < rest[0]) nextSmallest = false;\nint lo = 0, hi = rest.length;\nint[] answer = new int[1+rest.length];\nanswer[0] = head;\nfor (int i=0; i<rest.length; ++i) {\nif (nextSmallest) answer[i+1] = rest[lo++];\nelse answer[i+1] = rest[--hi];\nnextSmallest = !nextSmallest;\n}\nreturn answer;\n}\n```\n\nA slightly different valid strategy is to simply split the array [head]+rest in the middle into “small” and “large” elements, and then alternately take any small element and any large element. (The two technical details are that you need to take head first, and if the total number of elements is odd, you need to break the tie so that the half that contains the head is the one with more elements than the other one.)\n\n## SelfDescFind\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15458)\nThis problem required you to make three simple observations.\n\nThe first one is the following one: if you are given D digits, the number you are constructing will have exactly 2D digits. The digits you are given are the b[i] of the number, and you have to find the corresponding a[i]. As the corresponding a[i] must describe the whole number, we now know that the sum of all a[i] must be exactly 2D.\n\nThe second observation: Each valid sequence of a[i] is some integer partition of 2D into exactly D ordered positive parts. For D=20, there are only (19 choose 9) = 92,378 such partitions (and some of them are invalid because they have some a[i] exceed 9). This means that we can simply try all of them. If we fix one sequence a[i], we know the exact multiset of digits we will have in our number, and we need to verify whether it works by counting the number of actual occurrences of each digit and comparing these counts to a[i].\n\nThe third observation is the easiest. Once we have some pairs (a[i],b[i]) that work, we can produce the smallest number that contains them simply by sorting the pairs lexicographically.\n\n```\nArrayList< ArrayList<Integer partitions(int sum, int length) {\nArrayList< ArrayList<Integer answer\n= new ArrayList< ArrayList<Integer ();\nif (length == 1) {\nif (1 <= sum && sum <= 9) {\nArrayList<Integer onlyOption = new ArrayList<Integer();\nonlyOption.add(sum);\nanswer.add(onlyOption);\n}\nreturn answer;\n}\nfor (int last=1; last<=9 && sum-last = length-1; ++last) {\nArrayList< ArrayList<Integer tmp = partitions(sum-last,length-1);\nfor (ArrayList<Integer one : tmp) {\none.add(last);\nanswer.add(one);\n}\n}\nreturn answer;\n}\npublic String construct(int[] digits) {\nString answer = \"\";\nint D = digits.length;\nArrayList< ArrayList<Integer options = partitions(2*D,D);\nfor (ArrayList<Integer one : options) {\nint[] actualCounts = new int[10];\nfor (int d=0; d<D; ++d) ++actualCounts[ one.get(d) ];\nfor (int d=0; d<D; ++d) ++actualCounts[ digits[d] ];\nint[] declaredCounts = new int[10];\nfor (int d=0; d<D; ++d) declaredCounts[ digits[d] ] = one.get(d);\nif (!Arrays.equals(actualCounts, declaredCounts)) continue;\nint[] pieces = new int[D];\nfor (int d=0; d<D; ++d) pieces[d] = 10*one.get(d) + digits[d];\nArrays.sort(pieces);\nString curr = \"\";\nfor (int x : pieces) curr += x;\nif (answer.equals(\"\")) answer = curr;\nif (curr.compareTo(answer) < 0) answer = curr;\n}\nreturn answer;\n}\n```\n\n## LollipopHoney\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15409)\nThe condition from the problem statement can be restated as follows: pick 2K tastiest lollipops, given that you cannot pick more than K lollipops from any one flavor.\n\nThe optimal total deliciousness can be solved greedily. We simply sort all lollipops into batches according to their deliciousness, and then we process the batches in decreasing order of deliciousness and we always take all lollipops we can. Clearly, this way we only discard a lollipop if we are full (of more delicious ones) or if we already have K of its type.\n\nThe above algorithm can also be extended to count the number of ways in which the optimal selection of lollipops can be made. First, note that when processing the batches as described above, there are three states. First, there are some batches where we take everything (except for stopping at K for each flavor). Then, there may be one batch where we take something and end up with 2K lollipops. Finally, there are some batches we discard completely.\n\nHandling batches of the first type is easy: all choices are unique, except for the one where we have choose(A,B) options which B of A available lollipops to keep if the limit “K per flavor” is stopping us.\n\nFor the special batch we will use dynamic programming. For each flavor we know the number of lollipops available, and we know the maximum number we are still allowed to take. We process the flavors one at a time, and for each flavor we try all possible numbers of lollipops. The values computed are the values ways[i] = in how many ways could I pick exactly i lollipops of the already processed flavors?\n\n```\ndef count(self, K, flavor, deliciousness):\ndistinct_f = set(flavor)\ndistinct_d = set(deliciousness)\nsorted_lollipops = { d:[] for d in distinct_d }\nfor f, d in zip(flavor, deliciousness): sorted_lollipops[d].append(f)\ntaken_from_flavor = { f:0 for f in distinct_f }\ntaken_total = 0\ndeliciousness_total = 0\nways_total = 1\nfor d in reversed(sorted(distinct_d)):\nwill_take = []\nfor f in distinct_f:\nhas_f = sorted_lollipops[d].count(f)\nwill_take += [f] * min(has_f, K - taken_from_flavor[f])\nif taken_total + len(will_take) <= 2*K:\n# take all you have, sample those that have too many\ntaken_total += len(will_take)\ndeliciousness_total += d * len(will_take)\nfor f in distinct_f:\nhas_f = sorted_lollipops[d].count(f)\ntook_f = will_take.count(f)\nways_total *= binomial(has_f,took_f)\nways_total %= MOD\ntaken_from_flavor[f] += took_f\nelse:\n# take a subset that is large enough for your needs\nitems_remains = 2*K - taken_total\ntaken_total = 2*K\ndeliciousness_total += d * items_remains\nways_dp = [ 0 for _ in range(items_remains+1) ]\nways_dp[0] = 1\nfor f in distinct_f:\nhas_f = sorted_lollipops[d].count(f)\nmax_f = min(has_f, K - taken_from_flavor[f])\nnew_ways_dp = [ 0 for _ in range(items_remains+1) ]\nfor i in range(items_remains+1):\nfor j in range(max_f+1):\nif i+j <= items_remains:\nnew_ways_dp[i+j] += ways_dp[i]*binomial(has_f,j)\nways_dp = [ x%MOD for x in new_ways_dp ]\nways_total = (ways_total * ways_dp[-1]) % MOD\nbreak\nif taken_total < 2*K:\nreturn []\nreturn (deliciousness_total, ways_total)\n```\n\n## PrettyLiar\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15405)\nIn this task the main trick we need to make the solution run in time is the ability to “undo” one part of the computation of a dynamic programming table instead of recomputing said table from scratch.\n\nThe general outline of how we will count all pairs of permutations for which Kaede wins will look as follows:\n\n- Try all possibilities for the last number L played by Kanade when she loses the game.\n- Try all possibilities for the number F of full rounds played before the round in which Kanade lost.\n- Try all possibilities for the number of stones K removed by Kanade in the first F rounds.\n- In each of the situations described above, compute the answer as follows:\n- Take the number of ways in which Kanade can remove exactly K stones in exactly F rounds, without using the one move we chose for round F\n- Take the total number of ways in which Kaede can achieve a valid score such that Kaede’s score + K < S but Kaede’s score + K + L >= S. (This is always some contiguous range of scores.)\n- Multiply those two counts.\n\nWe will treat each of the girls roughly the same, but with some differences.\n\nFor Kaede:\n\n- We will use dynamic programming to compute the number of subsets of her sequence with each possible sum and each possible size.\n- Once we have those, we will compute the prefix sums of those values in the direction of increasing scores.\n- Once we have the prefix sums, we can answer the queries we need for the above solution in constant time. (Note that as we counted subsets, we then need to multiply that count by an appropriate pair of factorials to get the numbers of all permutations in which there is first the subset we want in any order, and then the remaining elements also in any order.)\n\nFor Kanade:\n\n- We will use the same dynamic programming as for Kaede.\n- Each time we choose a specific index in her sequence to get the value L she will play in the round in which she loses, we can now compute the new values for the dynamic programming. Doing this quickly is the crucial step of this solution.\n\nSuppose we have the values kanade_subsets[size][sum] that tell us the number of subsets of Kanade’s sequence with a given size and sum. We now want to compute the values kanade_subsets_fixed that count the same if we cannot use element L. Doing this from scratch requires N^2 * maximum sum time, but we need to do it in N*maximum sum time instead.\n\nThe observation we need is that we can indeed “undo” any one step of the computation of the dynamic programming. The values computed in kanade_subsets do not depend on the order in which we processed the elements, so we can imagine that L was the last value processed. How do we undo its processing and recompute the values that were in kanade_subsets previously?\n\nThe values in kanade_subsets[0] are obviously correct. When computing the values in kanade_subsets[1] we always took some value from kanade_subsets[0] and we added L to contribute to a value in kanade_subsets[1]. We can now undo these steps and thus get the correct values in kanade_subsets_fixed[1]. Using those we can now fix kanade_subsets[2] to kanade_subsets_fixed[2], and so on.\n\nThe whole solution therefore runs in O(N^2 * maximum sum).\n\n```\nint count(int S, vector<int kaede, vector<int kanade) {\nint N = kanade.size();\n// precompute factorials and their products we'll use\nvector<long long factorial(101,1);\nfor (int n=1; n<=100; ++n) factorial[n] = (factorial[n-1] * n) % MOD;\nvector<long long coefficients(N);\nfor (int n=0; n<N; ++n) {\nlong long curr1 = (factorial[n+1] * factorial[n]) % MOD;\nlong long curr2 = (factorial[N-n-1] * factorial[N-n-1]) % MOD;\ncoefficients[n] = (curr1 * curr2) % MOD;\n}\n// for each number of items and each sum,\n// precompute the number of matching subsets of kaede/kanade\nvector< vector<int kaede_subsets(N+1, vector<int(100*N+1,0));\nvector< vector<int kanade_subsets(N+1, vector<int(100*N+1,0));\nkaede_subsets[0][0] = 1;\nkanade_subsets[0][0] = 1;\nfor (int n=0; n<N; ++n) {\n// add thing number n for kaede/kanade\nfor (int sz=N-1; sz=0; --sz) {\nfor (int i=0; i<=100*n; ++i) {\nkaede_subsets[sz+1][i+kaede[n]] += kaede_subsets[sz][i];\nif (kaede_subsets[sz+1][i+kaede[n]] = MOD)\nkaede_subsets[sz+1][i+kaede[n]] -= MOD;\nkanade_subsets[sz+1][i+kanade[n]] += kanade_subsets[sz][i];\nif (kanade_subsets[sz+1][i+kanade[n]] = MOD)\nkanade_subsets[sz+1][i+kanade[n]] -= MOD;\n}\n}\n}\n// do prefix sums for kaede\nvector< vector<int kaede_psums(N+1, vector<int(100*N+2,0));\nfor (int n=0; n<=N; ++n) for (int i=0; i<=100*N; ++i)\nkaede_psums[n][i+1] = (kaede_psums[n][i] + kaede_subsets[n][i]) % MOD;\nlong long answer = 0;\n// try all possibilities for kanade's last number\nfor (int last=0; last<N; ++last) {\n// recompute the subsets for kanade\n// if she cannot use the chosen number\nint chosen = kanade[last];\nvector< vector<int kanade_subsets_fixed = kanade_subsets;\nfor (int sz=1; sz<=N; ++sz) for (int i=0; i<=100*N; ++i)\nif (kanade_subsets_fixed[sz-1][i]) {\nkanade_subsets_fixed[sz][i+chosen] -= kanade_subsets_fixed[sz-1][i];\nif (kanade_subsets_fixed[sz][i+chosen] < 0)\nkanade_subsets_fixed[sz][i+chosen] += MOD;\n}\n// try all possibilities for the number of full rounds without a loss,\n// and all possibilities for kanade's score in them\nfor (int full=0; full<N; ++full)\nfor (int kanade_score=0; kanade_score<S; ++kanade_score) {\n// kaede's score from full+1 rounds must be such\n// that kaede_score + kanade_score < S\n// but kaede_score + kanade_score + chosen = S\nint kaede_score_lo = max(0, S - kanade_score - chosen );\nint kaede_score_hi = min(100*N + 1, S - kanade_score);\nif (kaede_score_lo kaede_score_hi) continue;\nif (kanade_score 100*N) continue;\nlong long kanade_ways = kanade_subsets_fixed[full][kanade_score];\nlong long kaede_ways = kaede_psums[full+1][kaede_score_hi]\n- kaede_psums[full+1][kaede_score_lo];\nif (kaede_ways < 0) kaede_ways += MOD;\nlong long add = ((kaede_ways * kanade_ways) % MOD) * coefficients[full];\nanswer = (answer + add) % MOD;\n}\n}\nreturn answer;\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/single-round-match-758-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5K2O2QmVYxYa9N8cYBn1dW","type":"Entry","createdAt":"2020-04-20T12:42:15.466Z","updatedAt":"2026-02-06T21:38:11.999Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 756","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java","Python"],"creationDate":"2019-05-11T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 756 Editorials\n\n*__Note:__ The editorial and the problem NewBanknote were written by misof, all other problems were written and prepared by IH19980412.*\n\n## CinderellaGirls\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15407)\nThe easiest solution is to implement the check described in the problem statement as two nested loops: for each girl A look at each other girl B and check whether B disqualifies A.\n\nSample implementation in Python:\n\n```\ndef count(self, talent, skill):\nanswer = 0\nN = len(talent)\nfor a in range(N):\nadvances = True\nfor b in range(N):\nif talent[b] talent[a] and skill[b] skill[a]:\nadvances = False\nif advances:\nanswer += 1\nreturn answer\n```\n\n## PAndPuns\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15406)\nChecking for puns by simply implementing their definition may be too small. Luckily, we can make an easy observation that will make our code both faster and simpler. Suppose you have two non-overlapping occurrences of some string S such that |S| > 2. If you take just the first two characters of each of them, you now have two non-overlapping occurrences of some string T such that |T| = 2.\n\nIn other words, an equivalent definition of a pun is that a text is a pun iff it contains two non-overlapping identical substrings of length exactly 2. And this is easy to check in O(n^2) using brute force: we just iterate over all possible locations of their beginnings.\n\n```\ndef check(self,text):\nfor a in range(len(text)-3):\nfor b in range(a+2,len(text)-1):\nif text[a:a+2] == text[b:b+2]:\nreturn 'pun'\nreturn 'not a pun'\n```\n\n## NewBanknote\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15439)\n__Solution__: For each i between 0 and 50,000, try using the new banknote exactly i times. If we already paid too much, break. Otherwise, pay the remaining amount greedily. Pick the best solution over all i.\n\nBelow, we prove the correctness of this solution.\n\n__Observation:__ For any amount within the given constraints, the new banknote will never be used more than 50,000 times.\n\n__Proof:__ If the new banknote is the largest of all denominations, 50,000 pieces of the banknote have the value at least 50,000^2, and that is already bigger than the largest amount we can be asked to pay.\n\nIf the new banknote with value B is smaller than the largest original banknote (which has the value 50,000), we will never use 50,000 copies of B because it’s strictly better to use B copies of the 50,000-cent banknote.\n\n```\nint greedy(int suma) {\nint[] denominations = {1, 2, 5, 10, 20, 50, 100, 200, 500,\n1000, 2000, 5000, 10000, 20000, 50000};\nint used = 0;\nfor (int d=14; d=0; --d) {\nused += suma / denominations[d];\nsuma %= denominations[d];\n}\nreturn used;\n}\npublic int[] fewestPieces(int newBanknote, int[] amountsToPay) {\nint Q = amountsToPay.length;\nint[] answer = new int[Q];\nfor (int q=0; q<Q; ++q) {\nanswer[q] = amountsToPay[q];\nfor (int i=0; i<=50000; ++i) {\nlong mam = newBanknote;\nmam *= i;\nif (mam amountsToPay[q]) break;\nint remains = (int)(amountsToPay[q] - mam);\nanswer[q] = Math.min( answer[q], i + greedy(remains) );\n}\n}\nreturn answer;\n}\n```\n\nThere are also other ways to get a similar upper bound. For example, you can start by trying to pay the given amount using just the original Euro denominations. This gives you some valid solution that uses X pieces, with X being at most in tens of thousands. Then, it’s obviously not optimal to use the new banknote more than X times, because you are already using too many pieces.\n\nFor completeness, we also include a sketch of the proof that for the Euro denominations the optimal number of coins and banknotes to pay any amount can always be determined using the straightforward greedy algorithm: always take the largest one that does not exceed the amount left to pay.\n\nThere are general techniques how to show that a greedy algorithm works for a given set of denominations - essentially, it’s enough to check that it matches the optimum (which is easily computed using dynamic programming) on all amounts from 1 to some reasonably low threshold. However, for Euro we can also make a simpler, self-contained proof.\n\nNote that the Euro denominations come in groups of three, always having the values (1,2,5) times some power of 10. If we start with the smallest ones, we can easily verify that any amount between 1 and 9 cents will be paid optimally. Now we can notice the following property: in an optimal solution you will only use these coins to pay at most 9 cents. This is because if you use them to pay 10 or more, you can always swap some of them for a single 10-cent coin, or you can swap some of them for a 10-cent and a 1-cent coin, always getting the same amount paid using fewest pieces. Hence, when paying any amount, we use the 1,2,5-cent coins to pay whatever is the last digit of the amount, and then we can forget about them.\n\nRepeating this argument gives you the proof that the optimal solution is indeed always the one found by the greedy algorithm.\n\n## CrazyCrazy\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15408)\nWe can solve this problem using the meet-in-the-middle technique. Imagine that we split the string into two halves. First, let’s take the first half of the string and try all 2^(n/2) possibilities for which girl gets which letters. Without loss of generality, we can only consider those in which Shiki gets at least as many letters as Frederica. In some of them, the string Frederica gets will not be a prefix of Shiki’s string. Those options are clearly wrong. Thus, we only look at the options where Frederica’s string is a prefix of Shiki’s string, and for each of them the thing we store is the rest of Shiki’s string -- i.e., the part of the song Shiki already heard and Frederica didn’t.\n\nNext, we do the same with the second part of the string, but now we only check options in which Frederica gets at least as many letters as Shiki, and Shiki’s string is a suffix of Frederica’s string. We can reuse the same code we used for part 1 by reversing the second half of the string before we call it, and reversing all the outputs it returns.\n\nNow, all that remains is to check whether we have a match. For the first part we have all possible parts of song that can be heard by only Shiki in a valid solution, for the second part we have all possible parts that can be heard only by Frederica, hence the song is good if and only if the same string appears in both sets. This is easy to check using any efficient data structure (or even using binary search).\n\n```\nset<string get_diffs(const string &song) {\nint N = song.size();\nset<string answer;\nfor (int sub=0; sub<(1<<N); ++sub) if (__builtin_popcount(sub)*2 = N) {\nstring first, second;\nfor (int n=0; n<N; ++n)\nif (sub & 1<<n) first += song[n]; else second += song[n];\nif (first.substr(0,second.size()) == second)\nanswer.insert( first.substr(second.size()) );\n}\nreturn answer;\n}\nstruct CrazyCrazy {\nstring possible(string song) {\nint N = song.size() / 2;\nstring first_half = song.substr(0,N), second_half = song.substr(N);\nauto diffs1 = get_diffs(first_half);\nreverse( second_half.begin(), second_half.end() );\nauto diffs2 = get_diffs(second_half);\nfor (string diff2 : diffs2) {\nreverse( diff2.begin(), diff2.end() );\nif (diffs1.count(diff2)) return \"possible\";\n}\nreturn \"impossible\";\n}\n};\n```\n\n## Newgenerations\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15404)\nClearly, if all four neighbors of a special cell are active, there is no way to color the pipes: we will have two pipes of the same color leaving this special cell due to the pigeonhole principle. Thus, we have a necessary condition: each special cell must have at least one neighbor that is not active.\n\nLuckily for us, this condition is not just necessary but also sufficient for a valid coloring to exist.\n\nConsider a graph in which vertices are the special cells and their active neighbors, and edges are pipes. This is a bipartite graph with degrees at most three. Forget about the topology of the graph and view it just as an abstract bipartite graph. Imagine that we add new vertices and new edges to make both partitions have the same size and to make each vertex have degree exactly 3. By Hall’s theorem we know that this graph has a perfect matching. Color those edges using the same color, discard them, repeat twice more. Thus, the original graph has a valid 3-edge-coloring. In other words, whenever each special cell has a non-active neighbor, we can always 3-color the surroundings of the special cells.\n\nThus, all that remains is to count the number of ways in which the undecided cells are turned into active and nonactive cells in such a way that the property we just discovered holds. This can be done using the principle of inclusion and exclusion: count all ways, for each special cell subtract the ones where it has all neighbors active, for each pair of special cells add back the ways in which all their neighbors are active, and so on.\n\n```\npublic int count(String[] field){\nint N = field.length;\nint M = field[0].length();\nlong mod = 1000000007;\nint [] posx = new int [25];\nint [] posy = new int [25];\nboolean [][] select = new boolean [55][55];\nlong [] bin = new long [2505];\nbin[0] = 1L;\nfor(int i=1;i<2505;i++) bin[i] = bin[i-1]*2L%mod;\nint cnt = 0, num_free = 0;\nfor(int i=0;i<N;i++){\nfor(int j=0;j<M;j++){\nif(field[i].charAt(j) == 'x'){\nposx[cnt] = i;\nposy[cnt] = j;\ncnt++;\n}\nelse if(field[i].charAt(j) == '*'){\nnum_free++;\n}\n}\n}\nlong ans = 0L;\nint [] dx = {0,0,1,-1};\nint [] dy = {1,-1,0,0};\nfor(int mask=0;mask<(1<<cnt);mask++){\nlong flag = 1L;\nboolean bad = false;\nint free = num_free;\nArrayList<Integer changexy = new ArrayList<();\nfor(int i=0;i<cnt;i++){\nif((mask & (1<<i)) 0){\nflag *= -1L;\nfor(int j=0;j<4;j++){\nint nx = posx[i]+dx[j];\nint ny = posy[i]+dy[j];\nif(0<=nx && nx<N && 0<=ny && ny<M\n&& field[nx].charAt(ny) != '.'){\nif(field[nx].charAt(ny) == '*'){\nif(select[nx][ny] == false){\nfree--;\nselect[nx][ny] = true;\nchangexy.add(nx*64+ny);\n}\n}\n}\nelse{\nbad = true;\nbreak;\n}\n}\n}\n}\nif(!bad){\nans += bin[free] * flag;\nif(ans < 0) ans += mod;\nif(ans = mod) ans -= mod;\n}\nfor(int i=0;i<changexy.size();i++){\nint V = changexy.get(i);\nselect[V/64][V%64] = false;\n}\n}\nfor(int i=0;i<N;i++){\nfor(int j=0;j<M;j++){\nassert select[i][j] == false;\n}\n}\nans = (ans%mod+mod)%mod;\nreturn (int)(ans);\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-756-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1rIYbgdCpQLa6sLvqw9Qf6","type":"Entry","createdAt":"2020-04-20T12:42:14.600Z","updatedAt":"2026-02-06T21:20:10.748Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":22,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 759","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-06-06T00:00:00.000Z","readTime":"20 min","content":"# SRM 759 Editorial\n\nAnother round by me ([espr1t](https://profiles.topcoder.com/espr1t)) - this time not a TCO round but a standard SRM. I hope you're not getting bored by Elly :)\n\nTypical for the midday-in-Europe matches there weren't too many contestants - around 200 in Div1 and another 350 in Div2. Still better than the 4 A.M. matches, though!\n\nThe match ran very smoothly with no questions being asked during the *entire* match. Also no technical issues that we know of. Yey!\n\nThis was one of the rare rounds in the recent years where two of the problems were shared between Div1 and Div2 - the Div1 250 was the same as the Div2 600 and the Div1 500 was the same as the Div2 900.\n\nThere were some blazingly fast solutions for the Div2 250, which was expected, as it was fairly trivial problem. This wasn't the case in Div1, where the 250 required both an observation and some amount of coding. Solutions slowly started to pour, with the first one being submitted for 238.39 points (by uwi). Around 15 minutes late to the party, tourist opened the first problem and got it for 245.20 - this guy is a machine... In Div2 solutions to the 600 also started to pop here and there, although for much slower times than the Div1 ones (well, duh!). Newcomer diamond_duke was the first to submit the 250, the 500, and the 1000, which lead to his win in the second division. I'm curious if this is a second account, or just someone who is really good but hasn't participated in TopCoder until now?\n\nAs the match revolved, many people in Div1 started submitting solutions to the 500 as well (which was much more standard and some people can even find it easier than the 250). With at least ten people being ready with the first two problems in the first 30 minutes, I started fearing the 1000 may not be hard enough to prevent many people from being done with the whole contest in less than an hour. Indeed, the first person with all three was ecnerwal (around 45 minutes into the match). This, unfortunately, still wasn't enough to win the match, but at least he/she became target for the first time, woohoo! Congratulations! :)\n\nIt turned out that ecnerwal was more of an exception, as the second submitted solution was after the one hour mark, and in the end there were only 7 people who managed to submit it (four of them passing).\n\nDiv2 was much more balanced, with many people solving the easy, a few (in the order of tens) solving the medium, and just two dealing with the hard.\n\n## EllysViewPoints (Div2 250)\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15411)\nThe easy problem for division 2 was indeed easy. It was designed for TCO Round 1B, but never used, thus it is slightly easier than a typical Div2 250.\n\nThe problem, in short, is given a matrix with N rows and M columns of zeroes and ones, find the number of cells with a zero, such that all other cells in the same row and same column are also zeroes.\n\nThere are multiple ways to solve it. The easiest one is to just implement the check with four loops: two to iterate through all cells (all possible viewpoints), and two more to check if there are no \"blocked\" cells (1s in the abstraction above) in its row and column. This worked for O(N*M*max(N, M)), but  even if implemented in O(N^2 * M^2) would have passed since the constraints were relatively low.\n\nAnother option was to realize that the answer is just the number of empty rows multiplied by the number of empty columns. To count this one would need O(N * M), which is also the optimal time this problem can be solved with:\n\n```\nlong long rows = 0, cols = 0;\nfor (int row = 0; row < n; row++) {\nfor (int col = 0; col < m; col++) {\nif (a[row][col] == '#') {\nrows |= (1LL << row);\ncols |= (1LL << col);\n}\n}\n}\nreturn (n - __builtin_popcount(rows)) *\n(m - __builtin_popcount(cols)));\n```\n\n## EllysThreePrimes (Div1 250 / Div2 600)\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15436)\nThe easy problem in Div1 (also used as medium in Div2) was maybe slightly harder than I'd like for a 250, but the \"hard\" part was to make an observation - otherwise the implementation was  fairly easy afterwards.\n\nThe problem was the following: given five integers sum1, sum10, sum100, sum1000, sum10000 which are supposed to be the sums of the 1s, 10s, 100s, 1000s, and 10000s of three five-digit  prime numbers, can you find any three such numbers which would give those sums?\n\nThe main thing to solve the problem was to realize that there aren't that many prime numbers in the interval [10000, 99999]. As a rule of thumb we know that a number N is prime with chance in the order of 1/ln(N). Thus, numbers around 10000 have chance of being prime around 1/ 9.2, and numbers around 99999 have chance of being prime around 1/11.5. Thus, we'd expect around 10% of the numbers in [10000, 99999] to be prime, which makes less than 10000 numbers. In fact, it turns out there are exactly 8363 prime numbers in that interval. One could quickly find the primes using Sieve of Eratosthenes - see this tutorial for details if this is new for you.\n\nHaving that, we can do a simple \"divide and conquer\" solution - if we fix two of the numbers, we can get in O(1) the third one. Well, we still have to check whether it is prime, whether it has exactly five digits, and whether it is equal to some of the two fixed ones, but other than that we're done.\n\nSince we can fix the first two primes in increasing order, we have 8368 * 4184 = 35,011,712 possible pairs. For each of them we need 5 more operations to find the last one and a simple indexing in an array to see whether it is also prime. Please note that many of the pairs can be skipped as we have easy ways to prune the search. Even without the pruning, ~200 million operations aren't that many on a modern processor, so this would fit in the 2 second time limit.\n\nThere are several things to get wrong here. Probably the most common bug was to find an answer, in which some of the numbers are the same. This was mentioned twice in the problem statement (once with italic to stress on it) and it actually makes sense - if you are to tell your favourite three numbers to somebody, would you tell them a number twice? Many people still managed to overlook it somehow, which lead to many happy challengers (some with four or even more successful ones). Gennady was no exception, but his 4 successful challenges actually brought him the victory with a comfortable margin.\n\nThe second possible way to fail the problem was to think that if there is a solution, then there are many solutions and just try random pairs of primes until finding a solution (or some time expires, in which case return that there is no solution). Unfortunately, there are tests with very few possible solutions (I couldn't find any test with exactly one, though). The least I got to was 21 solutions.\n\nAll in all, this problem proved to be much more evil than I anticipated. In retrospect, I should have added a sample which checks the uniqueness of the returned numbers!\n\nYou can check out an example solution here:\n\n```\nprivate int MAX = 100001;\npublic int[] getPrimes(int[] sums) {\nboolean[] isPrime = new boolean[MAX];\nArrays.fill(isPrime, true);\nisPrime[0] = isPrime[1] = false;\nfor (int i = 2; i * i < MAX; i++) if (isPrime[i]) {\nfor (int c = i * i; c < MAX; c += i) {\nisPrime[c] = false;\n}\n}\nList<Integer primes = new ArrayList<();\nfor (int i = 10000; i < 100000; i++)\nif (isPrime[i]) primes.add(i);\nfor (int i = 0; i < primes.size(); i++) {\nfor (int c = i + 1; c < primes.size(); c++) {\nint rem0 = sums[4] - primes.get(i) % 100000 / 10000 - primes.get(c) % 100000 / 10000;\nif (rem0 <= 0 || rem0 = 10) continue;\nint rem1 = sums[3] - primes.get(i) % 10000 / 1000 - primes.get(c) % 10000 / 1000;\nif (rem1 < 0 || rem1 = 10) continue;\nint rem2 = sums[2] - primes.get(i) % 1000 / 100 - primes.get(c) % 1000 / 100;\nif (rem2 < 0 || rem2 = 10) continue;\nint rem3 = sums[1] - primes.get(i) % 100 / 10 - primes.get(c) % 100 / 10;\nif (rem3 < 0 || rem3 = 10) continue;\nint rem4 = sums[0] - primes.get(i) % 10 / 1 - primes.get(c) % 10 / 1;\nif (rem4 < 0 || rem4 = 10) continue;\nint num = rem0 * 10000 + rem1 * 1000 + rem2 * 100 + rem3 * 10 + rem4;\nif (isPrime[num] && num != primes.get(i) && num != primes.get(c)) {\nreturn new int[]{primes.get(i), primes.get(c), num};\n}\n}\n}\nreturn new int[]{};\n}\n```\n\n## EllysHash (Div1 500 / Div2 900)\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15435)\nAs I feared, this problem turned out to be almost as solved as the 250. It *was* harder, but it was also much more standard, and people with enough experience to see meet-in-the-middle when they encounter it knew what they have to do from the very beginning.\n\nThe problem, in short, was given three strings A, B, and C with length N, to create a new string S with length N, in which S[i] = A[i] or S[i] = B[i] or S[i] = C[i] and the hash of S is as low as possible. The contestants had to find that lowest hash (given a concrete hashing function).\n\nSince N was relatively low (N <= 28), that had to ring a bell for many of the contestants that the solution should be built around this.\n\nFor each position in S we had three choices - get the letter from A, from B, or from C. 3^28 choices are too many unfortunately, but not *way* too many - there are 22,876,792,454,961 possible strings that can be built, which, in the grand scheme of things, isn't that enormous. In similar problems we often have to apply \"Meet-in-the-Middle\" approach - divide the problem in two relatively equal parts, solve each of them independently, and combine the results. In this case, the length of the halves of the string would be up to 14, thus there would be 3^14 = 4,782,969 possible strings, which can be checked in much less than a second. If we split the given problem into two instances with N <= 14, we could solve these quite quickly.\n\nUnfortunately, the hash of the string depends on both parts and the lowest hash cannot be found by simply finding the lowest hash in both parts. One has to combine the results of the sub-problems in a smarter way in order to obtain the real answer.\n\nFortunately for us, the given hashing function is pretty simple and we can exploit that. Imagine we've split the input string (with length N) into two strings with length L and R, respectively (R can be either L or L-1, depending on whether N was even or odd). If we have a string in the left part with hash HL and a string in the right part with hash HR, the concatenation of those two strings would have hash HL * 127^R + HR.\n\nSo what we *can* do is find the hashes of all possible strings in the left part and sort them; then find the hashes of all possible strings in the right part and sort them, and finally find which combination of a hash from the left part multiplied by 127^R plus a hash from the right side gives the lowest number. Once we have the hashes sorted, finding the hash in the right part for a fixed hash in the left part can be done easily with binary search. What's even more, since we've sorted also the hashes in the left part, we can do \"two pointers\" solution (moving a pointer in the left or right arrays of hashes to keep the resulting hash as low as possible, while iterating all hashes on the left).\n\nThe described solution has complexity O(3^(N/2) * (N/2) + 3^(N/2) * log(3^(N/2))), which is dominated by the second part, thus O(3^(N/2) * log(3^(N/2)). This is around 4782969 * 25 = 119,574,225 operations - low enough to fit nicely into two seconds on a modern processor.\n\nAn example solution (which uses binary search and sorts only one of the halves):\n\n```\nint n;\nchar a[3][MAX];\nlong long pwr[MAX];\nvector <long long valuesL;\nvector <long long valuesR;\nvoid recurse(long long hash, int idx, int limit, vector <long long& values) {\nif (idx = limit) {\nvalues.push_back(hash);\n} else {\nrecurse((hash + a[0][idx] * pwr[idx]) % MOD, idx + 1, limit, values);\nrecurse((hash + a[1][idx] * pwr[idx]) % MOD, idx + 1, limit, values);\nrecurse((hash + a[2][idx] * pwr[idx]) % MOD, idx + 1, limit, values);\n}\n}\nlong long solve() {\nint sizeL = n / 2 + n % 2;\npwr[n - 1] = 1;\nfor (int i = n - 2; i = 0; i--)\npwr[i] = (pwr[i + 1] * BASE) % MOD;\nrecurse(0, 0, sizeL, valuesL);\nrecurse(0, sizeL, n, valuesR);\nlong long ans = MOD;\nsort(valuesL.begin(), valuesL.end());\nfor (int i = 0; i < (int)valuesR.size(); i++) {\nlong long target = MOD - valuesR[i];\nint left = 0, right = (int)valuesL.size() - 1;\nwhile (left <= right) {\nint mid = (left + right) / 2;\nvaluesL[mid] < target ? left = mid + 1 : right = mid - 1;\n}\nans = min(ans, (valuesR[i] + valuesL[left % (int)valuesL.size()]) % MOD);\n}\nreturn ans;\n}\n```\n\n## EllysTournament (Div1 1000)\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15434)\nThis was an easy-to-state problem, and the solution wasn't too long or too hard either - the problem with it was that it was hard to wrap your head around it (there are so many things happening with each choice)!\n\nFortunately for the contestants who managed to get to a working solution, the sample inputs were strong (as they pretty much covered correctness). However, what the samples didn't cover was TL (the largest one was with N = 100 with the limit set to 500). Still, as tests were pretty easy to generate, I expected people to check this themselves and be fairly sure in their solutions (thus no or very few challenges/systest fails on this problem). Surprisingly, 3 out of the 7 submissions failed, thus bringing the accuracy on the problem to slightly over 50%.\n\nThe task was the following. Given a list of N integers, you start choosing pairs of neighboring integers and remove one of them at each step. If the integers were X and Y, then X is removed with chance Y/(X+Y) and Y is removed with chance X/(X+Y). If the integer at position i is removed, then the integers at positions i-1 and i+1 (if there are such) are now considered neighboring. The contestants had to find the chance that the number in the K-th position in the original list remains as the last number.\n\nThere are multiple solutions here, but most of them are too slow for the given constraints. Fortunately for me, I was able to test each next faster solution using the previous one :)\n\nIt should have been fairly obvious to all participants who got to the third problem in Div1 that this was a dynamic programming problem. If you don't know the concept of dynamic programming or want a refresher, you can run through this tutorial.\n\nThe real problem here was how to make the state small enough (since O(N^3) memory was too much) and the DP fast enough (since O(N^4) time was too much).\n\nIf N was up to 20, there is a bitmask DP solution which keeps track which numbers are already thrown out and which are not. This works in O(2^N * N), but for N <= 500 this was waaaay too slow.\n\nOne main observation needed for the next several ideas is that, given an interval [L, R] and a person X (L <= X <= R) whom we want to \"win\" this interval, splits the task into two subtasks: one for [L, X] (with the person whom we want to win on the right end) and one for [X, R] (with the person whom we want to win on the left end). Thus, we can decrease the state from [L][R][X] to [L][R][2], which solves the problem with the memory. What's more, since being on the left end or the right end is not really different (well, just a tiny change in the code), for this analysis we'll only consider the person whom we want to win to be on the left end (position L) - extending the code to handle the other case should be trivial - see the provided code at the end for details.\n\nIn the beginning we know that Elly is on the K-th position - since we want her to win, we call the DP function twice - once with [1, K, 1] (she's in the right end of this interval) and once with [K, N, 0] (she's on the left end in this interval). We can multiply the probabilities for the two sub-tasks to get the answer for the whole task.\n\nNow let's see how we can get a working solution for N up to around 100.\n\nFor any interval [L, R] we know that we want L to win, but don't know how this will happen (there are many options for doing so). We do know, however, that L will participate in the last match against some of the other R-L people in the interval. Let's fix this other person X (L < X <= R)! We do a for loop which checks each of the possible \"last\" opponents. In order for the last match in the interval [L, R] to be between L and X two things must happen:\n\nX wins in the [X, R] interval - which is a sub-task of the original problem, thus can be calculated by the same DP function;\n\nThe matches in [L, X] end up in such a way, that L and X are the last people left in the interval.\n\nThe first point is trivial - just call recursively the DP. The second point is not that obvious, so let's examine it further.\n\nWe can select \"where\" L and X will \"meet\" - the position where the last match in [L, X] will happen (let's say point M (L <= M < X)). We fix that with another for loop. Knowing M, we know that L must win in [L, M] and X must win in [M+1, X]. Those are just smaller instances of the same problem, thus can also be solved by the DP!\n\nSo now we have O(N^2) state with O(N) to fix the opponent and another O(N) to fix the meeting point. This leads to a O(N^4) solution, which works okay for N up to 100.\n\nWe need to optimize it a bit more, though. Instead of doing two nested loops (one for the opponent and one for the meeting point), we can take out the inner loop into a second DP. It will tell us \"Given an interval [L, R], what is the chance that L and R will play as last?\" It also has a state with size O(N^2) and this time a single for loop (to fix the meeting point) for a total of O(N^3) runtime. But now the outer DP also becomes O(N^3), for a total of O(N^3) for the whole problem! This solution works fast enough for N <= 500.\n\nThe code for this problem is actually relatively simple:\n\n```\nint n, k;\nint a[MAX];\ndouble dp[MAX][MAX];\ndouble dyn[MAX][MAX][2];\ndouble recurse(int, int, int);\ndouble go(int left, int right) {\nif (left + 1 == right)\nreturn 1.0;\nif (dp[left][right] == dp[left][right])\nreturn dp[left][right];\ndouble ans = 0.0;\nfor (int meet = left; meet < right; meet++)\nans += recurse(left, meet, 0) * recurse(meet + 1, right, 1);\nreturn dp[left][right] = ans;\n}\ndouble recurse(int left, int right, int side) {\nif (left == right) return 1.0;\nif (dyn[left][right][side] == dyn[left][right][side])\nreturn dyn[left][right][side];\ndouble ans = 0.0;\nint pos = !side ? left : right;\nfor (int opp = left; opp <= right; opp++) if (pos != opp) {\ndouble chancePlay = 1.0 / (right - left);\ndouble chanceWin = (double)a[pos] / (a[pos] + a[opp]);\ndouble chanceOpp = !side ? recurse(opp, right, 0) : recurse(left, opp, 1);\ndouble chanceMeet = !side ? go(left, opp) : go(opp, right);\nans += chancePlay * chanceWin * chanceOpp * chanceMeet;\n}\nreturn dyn[left][right][side] = ans;\n}\ndouble ans = recurse(0, K - 1, 1) * recurse(K - 1, N - 1, 0);\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6vT0Zl3IZ6hSMvMgCLqQa5","type":"Entry","createdAt":"2020-04-20T12:42:15.893Z","updatedAt":"2020-04-20T12:42:15.893Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"espr1t","tcHandle":"espr1t"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-759-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1f6zQWKbMBgSyJE4TCXZkr","type":"Entry","createdAt":"2020-04-20T12:42:14.103Z","updatedAt":"2026-02-06T21:13:49.178Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 762","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java","Python"],"creationDate":"2019-07-11T00:00:00.000Z","readTime":"30 min","content":"# SRM 762 Editorial\n\n## Div 2 Easy - PartitionArray\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15594)\nIn this problem you have to find out if it’s possible to divide the given array of integers A into contiguous subarrays each having positive sum of its elements. And if so construct any such partition.\n\nObviously, if the sum of elements in A is non-positive then no solution exists. Otherwise the array A itself is a valid partition. The time complexity linearly depends on the size of A.\n\n## Div 2 Medium - Restrictions\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15598)\nIn this problem you have to find the lexicographically smallest n-length array of positive integers satisfying the given set of m constraints. According to the i-th constraint all elements in the contiguous subarray (l[i], r[i]) must be greater \\ less than or equal to the given value val[i].\n\nThe problem can be solved for each array element independently. Consider an element at index k. What are the minimal and the maximal possible values that can be assigned to it? Let’s iterate over all constraints effective for index k and find the maximum value among all “greater than or equal to” items and denote it with MIN. Similarly we find the minimal value among all “less than or equal to” entries and denote it with MAX. If MIN value exceeds MAX value then no solution exists for the entire problem. Otherwise we assign MIN value to the k-th element of the resulting array. Note that initially MIN is equal to 1 since we are looking for an array of positive integers and MAX is equal to infinity.\n\nThe time complexity is O(n*m).\n\n## Div 2 Hard - Strawberry\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15600)\nIn this problem an array X of length n+1 is being constructed using the following rules:\n\nX[0] = 0;\n\nX[2*j + 1] = X[j] + T, where T is an integer chosen at random between 0 and 2*k, inclusive, using the given probabilities A for each value;\n\nX[2*j + 2] = X[2*j + 1] - R, where R is an integer chosen at random between 0 and 2*k, inclusive, using the given probabilities B for each value.\n\nYou have to find the probability that each element of X does not exceed k by its absolute value.\n\nThe problem can be solved by a dynamic programming approach, where the state is an index in array X and the corresponding value. The overall number of states is (n+1)*(2*k + 1). The transitions between the states are made by iterating over all possible values of T and R.\n\nThe time complexity is O(n*k^2).\n\n## Div 1 Easy - LexicographicPartition\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15597)\nIn this problem you have to divide the given array of integers A into contiguous subarrays each having positive sum of its elements. A solution is represented as a sequence of partition lengths. Among all valid ways to divide the array you have to find the lexicographically smallest one.\n\nFirst, note that a solution exists if and only if the sum of the elements in A is positive. In such case the array A itself is a valid partition. The lexicographically smallest partition can be found by using a greedy approach. Let’s try to split A into two parts - the prefix and the suffix such that both have a positive sum of the elements and the prifix contains as few elements as possible. If this is possible recursively solve the same problem for the suffix, otherwise the array A is the only valid partition.\n\nSince the prefix and the suffix sums can be updated in O(1) the overall complexity is O(n) where n is the length of A.\n\n## Div 1 Medium - StrawberryHard\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15599)\nIn this problem an array X of length n+1 is being constructed using the following rules:\n\n- X[0] = 0;\n- X[2*j + 1] = X[j] + T, where T is an integer chosen at random between 0 and 2*k, inclusive, using the given probabilities A for each value;\n- X[2*j + 2] = X[2*j + 1] - R, where R is an integer chosen at random between 0 and 2*k, inclusive, using the given probabilities B for each value.\n\nYou have to find the probability that each element of X does not exceed k by its absolute value.\n\nThe problem can be solved by a dynamic programming approach, where the state is an index in array X and the corresponding value. The overall number of states is (n+1)*(2*k + 1).\n\nLet dp[j][v] be a probability of a valid construction of the first j elements of X where the last one is equal to v. \n\nThe transitions between the states could be made by simply iterating over all possible values of T and R which would result in O(n*k^2) solution like in div2 version of the problem. However this is too slow and would result in TL.\n\nSince dp[2*j + 1][v] = dp[2*j][v]*T[0] + dp[2*j][v - 1]*T[1] + … \n\nand dp[2*j + 2][v] = dp[2*j + 1][v]*R[0] + dp[2*j + 1][v + 1]*R[1] + …\n\ntransitions between dp[j] and dp[j + 1] can be made faster by applying FFT.\n\nThis leads us to O(n*k*log(k)) solution.\n\n## Div 1 Hard - DistancePermutation\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/14725)\nIn this problem you are given a tree with hidden root which is chosen at random. You check the vertices one by one in random order. For each vertex being checked you get a distance from the vertex to the root. Whenever the tree root can be uniquely identified you stop. What is the expected number of vertex checks?\n\nFirst, let’s fix the tree root and denote it with R. Consider tree vertex V. Let’s denote the following:\n\n- st(V) - the subtree which corresponds to V;\n- d(V) - the distance from V to R;\n- h(V) - the height of st(V);\n- ch(V) - the children of V;\n- chst(V) - subtrees which correspond to ch(V).\n\nConsider ch(R) and chst(R). We will stop as soon as we check R or there are two checks in different chst(R). In other words if the first check is located inside one of chst(R) then any check outside of it will identify the root. Which means that all checks in the sequence except for maybe the last one belong to one of chst(R).\n\nLet’s call a vertex V good if except of R all vertices at distance d(V) from V are located in st(V). Note that all ch(R) are good. For each good vertex V we will count the number of non-empty check sequence prefixes from st(V) that does not identify the root or identity the root with its last check.\n\nLet’s call a child C of vertex V deep if h(C) >= d(V)-1 or shallow otherwise. Let deep(V) be the number of deep children of V. Note that if C is a shallow child of V then any check inside st(C) is equivalent to the check of V. \n\nThere are few cases:\n\n1. deep(V) = 0. Any check within st(V) will be the last one.\n\n2. deep(V) = 1. Let W is the deep child of V. If the first check is not inside st(W) then the following check will definitely be the last one. Otherwise at any point a check outside of st(W) will be the last one. So we recursively move from V to W. Note that W is the only good child of V.\n\n3. deep(V) >= 2. No child of V is good. By using a dynamic programming approach we count the check sequence prefixes. The state consists of:\n\na number of deep children of V considered;\n\nthe length of the check prefix;\n\nIs there any deep child C of vertex V with no checks in st(C)?","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"Kti40712QT55MZwopkkXi","type":"Entry","createdAt":"2020-04-20T12:42:14.134Z","updatedAt":"2020-04-20T12:42:14.134Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"vasylalphacom","tcHandle":"vasylalphacom"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/srm-762-editorial"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4cwNyi4nCYsHqBug5BhFDY","type":"Entry","createdAt":"2020-04-20T12:43:23.127Z","updatedAt":"2026-02-06T21:00:09.206Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":42,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 764","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-08-10T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 764 Editorials\n\nSRM 764 was held on 10th Aug 2019. It was a combined division round with 5 problems to solve.\n\n## Coastlines\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15686)\n__Statement__\nYou are given a map depicting the layout of several islands. A '.' indicates water, while 'X' indicates land. Two cells that are adjacent horizontally or vertically are considered part of the same island. Assume that all area outside the bounds of the given map is all water. Any place where a land cell is adjacent, horizontally or vertically, to water, is called a coastline. A single land cell may have as many as four units of coastline. The following examples have 4, 6, 8 and 8 units of coastline, respectively:\n\n![SRM 764](//images.ctfassets.net/piwi0eufbb2g/1bicJAXWIBRdzZglTEMu0Y/27c052072c4e6b967b842890ee58c80b/SRM_764.png)\n\nFind the total length of coastline of each island, and return the largest of these lengths.\n\n__Solution__\nYou basically have to do what's written in the statement in any reasonable way. One of possible ways is by using disjoint set union (DSU) to identify all islands and then for each pair of cells (A,B) where A is '.' and B is 'X' add one to the island to which B belongs.\n\n__Code:__\n```\nclass Coastlines {\nstatic const int maxn = 55 * 55;\nint par[maxn];\nint get(int v) {\nreturn v == par[v] ? v : get(par[v]);\n}\nvoid uni(int a, int b) {\na = get(a);\nb = get(b);\npar[a] = b;\n}\npublic:\nint longest(vector <string map) {\niota(par, par + maxn, 0);\nint n = map.size();\nint m = map[0].size();\nfor(auto &it: map) {\nit = \".\" + it + \".\";\n}\nmap.insert(begin(map), string(m + 2, '.'));\nmap.insert(end(map), string(m + 2, '.'));\nint dx[] = {0, 1, 0, -1};\nint dy[] = {1, 0, -1, 0};\nfor(int i = 1; i <= n; i++) {\nfor(int j = 1; j <= m; j++) {\nfor(int z = 0; z < 4; z++) {\nint ni = i + dx[z];\nint nj = j + dy[z];\nif(map[i][j] == 'X' && map[ni][nj] == 'X') {\nuni(i * m + j, ni * m + nj);\n}\n}\n}\n}\nvector<int res(maxn);\nfor(int i = 1; i <= n; i++) {\nfor(int j = 1; j <= m; j++) {\nfor(int z = 0; z < 4; z++) {\nint ni = i + dx[z];\nint nj = j + dy[z];\nif(map[i][j] == 'X' && map[ni][nj] == '.') {\nres[get(m * i + j)] += 1;\n}\n}\n}\n}\nreturn *max_element(begin(res), end(res));\n}\n};\n```\n\n## RectangleHunt\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15685)\n\n__Statement__\nYou are given a set of points, given as (x, y) coordinates in arrays x and y.\n\nReturn the area of the largest rectangle that can be formed from four of the points. If no four points can form a rectangle, return -1.\n\n__Solution__\nOnce again brute force will do. Just check every possible quadruple of points and output maximum area.\n\n__Code:__\n```\ntypedef int ftype;\ntypedef complex<int point;\n# define x real\n# define y imag\nftype dot(point a, point b) {\nreturn (conj(a) * b).x();\n}\nftype cross(point a, point b) {\nreturn (conj(a) * b).y();\n}\nclass RectangleHunt {\npublic:\ndouble largest(vector <int x, vector <int y) {\nint n = x.size();\nint ans = 0;\nfor(int i = 0; i < n; i++) {\nfor(int j = 0; j < n; j++) {\nfor(int k = 0; k < n; k++) {\nfor(int l = 0; l < n; l++) {\nif(i != j && i != k && i != l && j != k && j != l && k != l) {\npoint A = {x[i], y[i]};\npoint B = {x[j], y[j]};\npoint C = {x[k], y[k]};\npoint D = {x[l], y[l]};\nif(dot(B - A, C - B) == 0 && dot(C - B, D - C) == 0\n&& dot(D - C, A - D) == 0 && dot(A - D, B - A) == 0) {\nans = max(ans, abs(cross(B - A, D - A)));\n}\n}\n}\n}\n}\n}\nreturn ans == 0 ? -1 : ans;\n}\n};\n```\n\n## WebSpider\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/3977)\n__Statement__\nYou are given a String[], firstPass, containing a list of the links visited from the home page. They will all be in the form \"page\", \"subfolder/page\", \"subfolder/subfolder/page\", etc. There may be any level of depth to the subfolders.\n\nYou are given a String[], secondPass, containing a list of all the links found in the second pass (by visiting the links found on the home page). Each element is of the form \"pageNumber address\", where pageNumber is the index (from 0) of the page from firstPass on which the link was found. address is formatted similarly to the elements of firstPass, with the added possibility of a subfolder named \"..\", which means \"go to the parent folder\".\n\nYou are finally given a String[], thirdPass, indicating all of the links found in the third pass. It is formatted exactly as in secondPass, but the page numbers here refer to the index of the page from secondPass. In all cases, the links reference will be relative paths. In particular, they will never begin with a '/' character.\n\nYou are to return an int indicating the number of distinct pages (not including the initial homepage) visited during this crawl of the web site.\n\n__Solution__\nIn this problem too, you have to carefully deal with what's given in the problem. You should maintain the rooted tree keeping the whole structure, it's going to resemble a compressed trie. Now you may store in each vertex followings: map<string, int> to -- descendant of current vertex with the given string on the edge, int parent -- parent of current vertex, set<string> files -- for set of pages which may be found on the current vertex. After some manual processing all you have to do is to sum up files.size() over all vertices.\n\n__Code:__\n\n```\nclass WebSpider {\npublic:\nstruct trie {\nvector<set<string files = undefined;\nvector<map<string, int to = undefined;\nvector<int parent = {0};\nint size() {\nreturn files.size();\n}\nint add(vector<string s, int v = 0) {\nfor(int i = 0; i < s.size(); i++) {\nauto c = s[i];\nif(c == \"..\") {\nv = parent[v];\n} else if(i + 1 == s.size()) {\nfiles[v].insert(c);\n} else {\nif(!to[v][c]) {\nto[v][c] = size();\nfiles.push_back({});\nto.push_back({});\nparent.push_back(v);\n}\nv = to[v][c];\n}\n}\nreturn v;\n}\nint calc(int v = 0) {\nint res = files[v].size();\nfor(auto it: to[v]) {\nres += calc(it.second);\n}\nreturn res;\n}\n} me;\nvector<string parse(string s) {\nreplace(begin(s), end(s), '/', ' ');\nstringstream ss(s);\nvector<string ans;\nwhile(ss s) {\nans.push_back(s);\n}\nreturn ans;\n}\nint countPages(vector<string f, vector<string s, vector<string t) {\nint n = f.size();\nint ver1[n];\nfor(int i = 0; i < n; i++) {\nver1[i] = me.add(parse(f[i]));\n}\nint m = s.size();\nint ver2[m];\nfor(int i = 0; i < m; i++) {\nauto parsed = parse(s[i]);\nver2[i] = me.add(vector<string(begin(parsed) + 1, end(parsed)), ver1[stol(parsed[0])]);\n}\nfor(auto c: t) {\nauto parsed = parse(c);\nme.add(vector<string(begin(parsed) + 1, end(parsed)), ver2[stol(parsed[0])]);\n}\nreturn me.calc();\n}\n};\n```\n\n## FourSquareSum\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15684)\n__Statement__\nYou are given four non-negative integers ?,?,?,?, and are given that 2?=?^2+?^2+?^2+?^2.\n\nYou have to find four non-negative integers ?,?,?,? such that ?=?^2+?^2+?^2+?^2.\n\nReturn a int[] containing the values ?,?,?,?.\n\n__Solution__\nIf ?^2+?^2+?^2+?^2 is even then {?,?,?,?} may be split into pairs of numbers with same parity.\n\nNow you have to note that (?+?)^2+(?−?)^2=2(?^2+?^2), thus (?+?)/2)^2+(?−?/2)^2=(?^2+?^2/)2.\n\n__Code:__\n```\npublic int[] DivideByTwo(int a, int b, int c, int d) {\nif (a % 2 != b % 2) {\nif (c % 2 == a % 2) {\nint t = b;\nb = c;\nc = t;\n} else {\nint t = b;\nb = d;\nd = t;\n}\n}\nint[] ans = new int[] { (a + b) / 2, Math.abs(a - b) / 2, (c + d) / 2, Math.abs(c - d) / 2 };\nreturn ans;\n}\n```\n\n## Conquest\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/3973)\n__Statement__\nYou have armies amount of armies and you want to conquer three territories guarded by opponent[0], opponent[1] and opponent[2] armies respectively. On each turn you may choose the territory and attack it. You're given probabilities of all possible outcomes for such attacks which are given by the table:\n\nattacking | defending | |\narmies | armies | outcome | probability\n-----------+-----------+---------+------------\nover 3 | over 1 | 2 - 0 | 2275 / 7776\nover 3 | over 1 | 1 - 1 | 2611 / 7776\nover 3 | over 1 | 0 - 2 | 2890 / 7776\nover 3 | 1 | 1 - 0 | 441 / 1296\nover 3 | 1 | 0 - 1 | 855 / 1296\n3 | over 1 | 2 - 0 | 581 / 1296\n3 | over 1 | 1 - 1 | 420 / 1296\n3 | over 1 | 0 - 2 | 295 / 1296\n3 | 1 | 1 - 0 | 91 / 216\n3 | 1 | 0 - 1 | 125 / 216\n2 | over 1 | 1 - 0 | 161 / 216\n2 | over 1 | 0 - 1 | 55 / 216\n2 | 1 | 1 - 0 | 21 / 36\n2 | 1 | 0 - 1 | 15 / 36\n\nIf you conquer a territory you have to bring one your army there. You have to calculate the probability of winning all territories.\n\n__Solution__\nConsider dynamic programming of kind dp[armies][opponent[0]][opponent[1]][opponent[2]]. There are at most 50⋅203=4⋅105 possible states of this dp. For each state you should try to attack every territory and see the probability of winning the whole game after this. If you have possible outcomes produce probabilities ?1,?2,?3 and those outcomes happen with probabilities ?1,?2,?3 then the probability for success is ?1?1+?2?2+?3?3. Just choose the maximum of these values over all territories.\n\n__Code:__\n```\nclass Conquest {\npublic:\ndouble ans[51][21][21][21];\nint used[51][21][21][21];\nvector<tuple<int, int, double outcomes(int a, int b) {\nif(a 3) {\nif(b 1) {\nreturn {tuple<int, int, double{2, 0, 2275. / 7776},\ntuple<int, int, double{1, 1, 2611. / 7776},\ntuple<int, int, double{0, 2, 2890. / 7776}};\n} else {\nreturn {tuple<int, int, double{1, 0, 441. / 1296},\ntuple<int, int, double{0, 1, 855. / 1296}};\n}\n} else if(a == 3) {\nif(b 1) {\nreturn {tuple<int, int, double{2, 0, 581. / 1296},\ntuple<int, int, double{1, 1, 420. / 1296},\ntuple<int, int, double{0, 2, 295. / 1296}};\n} else {\nreturn {tuple<int, int, double{1, 0, 91. / 216},\ntuple<int, int, double{0, 1, 125. / 216}};\n}\n} else {\nif(b 1) {\nreturn {tuple<int, int, double{1, 0, 161. / 216},\ntuple<int, int, double{0, 1, 55. / 216}};\n} else {\nreturn {tuple<int, int, double{1, 0, 21. / 36},\ntuple<int, int, double{0, 1, 15. / 36}};\n}\n}\n}\ndouble bestChance(int x, vector<int a) {\nsort(begin(a), end(a));\nif(a == vector<int{0, 0, 0}) {\nreturn 1;\n} else if(x < 2) {\nreturn 0;\n} else if(used[x][a[0]][a[1]][a[2]]) {\nreturn ans[x][a[0]][a[1]][a[2]];\n} else {\nfor(int z = 0; z < 3; z++) {\nif(a[z] == 0) {\ncontinue;\n}\ndouble res = 0;\nfor(auto it: outcomes(x, a[z])) {\nx -= get<0(it);\na[z] -= get<1(it);\nif(x != 0) {\nx -= a[z] == 0;\nres += get<2(it) * bestChance(x, a);\nx += a[z] == 0;\n}\nx += get<0(it);\na[z] += get<1(it);\n}\nans[x][a[0]][a[1]][a[2]] = max(ans[x][a[0]][a[1]][a[2]], res);\n}\nused[x][a[0]][a[1]][a[2]] = 1;\nreturn ans[x][a[0]][a[1]][a[2]];\n}\n}\n};\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"46T1HDcJB0xmVTKm7Vjv8U","type":"Entry","createdAt":"2020-04-20T12:43:23.184Z","updatedAt":"2020-04-20T12:43:23.184Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"adamant","tcHandle":"adamant"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-764-editorials","openExternalLinksInNewTab":false}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7pqNqQK4thkEADsv0CPIrw","type":"Entry","createdAt":"2020-04-20T12:43:23.204Z","updatedAt":"2026-02-06T20:48:06.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":20,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 766","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python"],"creationDate":"2019-09-18T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 766 Editorials\n\n## Alibi\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15697)\nFor each person, keep track of the room where they are. (A hashmap is usually the most convenient way to do this: use the name of the person as the key into the hashmap and the name of the room as the value associated with the key.)\n\nProcess the events in the given order, until you reach their end or the first event that happened after the murder. For each event before the murder, update the room of the person who moved.\n\nFinally, check whether exactly one person is in the room with the victim.\n\n## QueenMeetup\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15698)\nThere are many different strategies to get the queens to meet. The limit of 50 is quite loose, we just need to be careful and make sure that we don’t accidentally move a queen somewhere where it does not fit.\n\nOne strategy that is easy to implement uses at most 2N moves for N queens. We’ll first move each queen as far left as we can. This requires at most N moves and creates a block of queens at the left end of some rows. In the second half of the solution we then move these blocks of queens as far up as we can. (E.g., if we had some queens in rows 4, 7, and 100, we will move all queens from row 4 to row 0, all queens from row 7 to row 1, and all queens from row 100 to row 2.) It is clear that after the second phase all queens have to form a 4-connected component.\n\nAnother similar strategy is to move the queens individually in the second phase as well. That is, we first move each queen as far left as we can and then we move each queen as far up as we can. The resulting configuration is almost the same as in the previous solution, and the argument why it works is also similar.\n\nWhen moving the queens we need to make sure that other queens are not in the way. E.g., we cannot move a queen from (100,100) to (100,0) if there is another queen at (100,20). In order to ensure that all moves are valid, we can simply process the queens ordered from left to right (and in the second step, ordered from top to bottom). In our example, we first move the queen from (100,20) to (100,0) and only later the queen from (100,100) to (100,1).\n\n## HockeyPlayoff\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15701)\nThis is a fairly standard problem that screams “dynamic programming / memoization”. Any moment during the series can be described by four numbers: (the number of matches won by team A, the number of matches won by team B, the team currently having a streak, the length of the streak).\n\nAs each match in a streak increases the team’s win probability by 5 percent, the longest streak we have to consider is 19 matches. This brings the number of states down to 600^2 * 2 * 20 < 15,000,000.\n\nFor each state of the series, we ask the same question: what is the probability of A winning the series from this point? In order to answer the question, we compute the probability of A winning the next game and then we recursively solve each of the two new scenarios: one in which A won that game and one in which they lost.\n\n## BannedBook\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15699)\nObviously, the friendships define an undirected graph. If we are moving the book between two connected components of that graph, the move is always high-risk. Thus, if there are C connected components, there will always be at least C-1 high-risk moves. Below we will show that a connected graph can always be solved without high-risk moves, which will give us an optimal solution: solve each component separately and concatenate those solutions.\n\nIf we want to find a solution for an arbitrary connected component, that solution has to work for trees. And on the other hand, once we know how to solve the problem for trees, we can solve it for any other connected graphs by simply picking one spanning tree and ignoring the other edges. Thus, it’s enough to solve the problem on trees.\n\nA valid solution for any tree can be constructed by doing a simple DFS traversal of the tree, with the rules “step on vertices in even depth on the way down and on vertices in odd depth on the way back up”.\n\nMore formally, we’ll have two recursive functions:\n\n```\ndef DFS_last(v):\nfor each child w of v:\nDFS_first(w)\nstep on v\ndef DFS_first(v):\nstep on v\nfor each child w of v:\nDFS_last(w)\n```\n\nThis modified DFS produces a valid sequence of vertices. To show this, first notice that DFS_last produces a sequence of vertices that starts with a child of v (or v itself, if it’s a leaf) and ends with v, and DFS_first produces the same thing but in reverse. Once we know this, we can easily verify that we never make a jump too far. E.g., if we call DFS_first(w1) and then DFS_first(w2), the first call will end with a child of w1 (or w1 itself), and the distance from there to w2 is (at most) 3.\n\nThe above DFS implementation can directly be used on the graph given as the input.\n\nShortestMissingSubsequences\nThis problem has a pretty linear solution without any fancy data structures. We’ll obtain it by cleverly speeding up a slower solution.\n\nOne solution in O(G*N) looks as follows: We will process the given sequence A backwards. Suppose we already processed A[n+1:] for some n. For each gene x, let L[x] be the length of the shortest invalid subsequence that starts with gene x, and C[x] be the number of such sequences.\n\nNote that once we know all L[x] and C[x], we can compute the final answer for the sequence we already processed in O(G) time by taking all x for which L[x] is minimal, and summing the corresponding C[x].\n\nHow do the values L and C change when we consider the sequence A[n:] instead of the sequence A[n+1:]? Clearly, the best counterexamples that start with genes other than A[n] don’t change, all of them still work. We just need to recompute the values L[A[n]] and C[A[n]]. Doing this is fairly easy: a DNA of the form A[n]+w is not a subsequence of A[n:] if and only if w is not a subsequence of A[n+1:]. Thus, the new value L[A[n]] is 1 + the optimal length for A[n+1:], and the new C[A[n]] is the number of optimal sequences for A[n+1:].\n\nThe key observation that will lead to the faster solution we promised is as follows: at any moment, the values in L can differ only by at most 1. For example, if there is a bad DNA of length 7 that starts with gene 47, you can have a bad DNA of length 8 starting with any gene you like, just append that 7-element DNA to it.\n\nGiven this observation, we can get rid of the O(G) step. Instead, we can simply maintain two integer variables: the number of x such that L[x] = min(L), and the sum of C[x] over all such x. Whenever you update a value in L and C, both of these variables can be updated in amortized constant time. This gives us an O(N) solution.\n\n(In my implementation I first handle cases with G > N as a special case, and then I can use plain arrays to store L and C.)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-766-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5uWmqsoxj1eGmjzw1aK0ts","type":"Entry","createdAt":"2020-04-20T12:43:25.142Z","updatedAt":"2026-02-06T20:43:09.947Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 769","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java","Python"],"creationDate":"2020-03-24T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 769 Editorials\n\n## BallsOnAMeadow \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15742)\n__Used as: Division Two - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 250       |\n| __Submission Rate__       | 147 / 165 (89.09%)      |\n| __Success Rate__          | 128 / 147 (87.07%)  |\n| __High Score__            | resh.root for 248.38 points (2 mins 18 secs)     |\n| __Average Score__         | 213.16 (for 128 correct submissions)     |\n\nThe answer is the number of times “(” appears in the meadow + the number of times “)” appears in the meadow - the number of times “()” appears in the meadow.Code by Patrik:\n\n```\ndef count(self, m):\ns = 0\nfor i in range(len(m)):\nc = m[i]\nif c == '(':\ns += 1\nelif c == ')' and m[i-1] != '(':\ns +=1\nreturn s\n```\n\n## ReallyMagicSquare \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15743)\n__Used as: Division Two - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 500       |\n| __Submission Rate__       | 56 / 165 (33.94%)      |\n| __Success Rate__          | 45 / 56 (80.36%)   |\n| __High Score__            | qixiao for 452.75 points (9 mins 22 secs)      |\n| __Average Score__         | 275.64 (for 45 correct submissions)  |\n\nLet’s name the matrix, a. Let’s construct the matrix row by row. The first row is given. How to find the second row?\n\na[1][1] (0-based) is given. We know a[0][0] + a[1][1] + a[2][2] + … + a[n - 1][n - 1] = a[0][1] + a[1][0] + a[2][2] + … + a[n - 1][n - 1] ⇒ a[0][0] + a[1][1] = a[0][1] + a[1][0]\n\nTo generalize the fact, for every r1, r2, c1, c2 ⇒ a[r1][c1] + a[r2][c2] = a[r1][c2] + a[r2][c1].\n\nSo a[1][0] = a[0][0] + a[1][1] - a[0][1].\n\nTo generalize, for a[1][i] (i > 1): a[1][i] = a[0][i] + a[1][1] - a[0][1].\n\nTo generalize for other rows, when i ≠ j, a[i][j]  = a[0][j] + a[i][i] - a[0][i].Code by cntswj (modified):\n\n```\ndef reconstruct(self, topRow, mainDiagonal):\nn = len(topRow)\nsquare = [[None] * n for _ in range(n)]\nsquare[0] = topRow\nfor i in range(1, n):\nsquare[i][i] = mainDiagonal[i]\nfor j in range(n):\nif i != j:\nsquare[i][j] = square[0][j] + square[i][i] - square[0][i]\nret = []\nfor row in square:\nret += row\n\nreturn ret\n```\n\n## PrimePruning \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15755)\n__Used as: Division Two - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 1000       |\n| __Submission Rate__       | 9 / 165 (5.45%)     |\n| __Success Rate__          | 0 / 9 (0.00%)   |\n| __High Score__            | null for null points (NONE)       |\n| __Average Score__         | No correct submissions     |\n\n__Used as: Division One - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 250       |\n| __Submission Rate__       | 95 / 116 (81.90%)    |\n| __Success Rate__          | 67 / 95 (70.53%)  |\n| __High Score__            | tourist for 236.94 points (6 mins 44 secs)      |\n| __Average Score__         | 174.68 (for 67 correct submissions)    |\n\nGreedy. We try to make the first character maximum possible. Then try to make the second character maximum possible, …\n\nLet H = N - E.\n\nWhat is the best option for the first character? Look for the maximum character in the first N - H + 1 characters (choose the first, in case of tie). Similarly for the next characters. The time complexity is O(NH). Although we can improve it to O(N log N), it’s not needed.\n\nThe fact comes to mind is, after some N, we always have H “z” characters, so we can choose them all and this is the best possible answer.\n\nCode by tourist:\n\n```\nstring maximize(int N, int E) {\nint keep = N - E;\nstring s = \"\";\nvector<int p;\nint cc = 0;\nfor (int i = 2; ; i++) {\nbool prime = true;\nfor (int j = 2; j * j <= i; j++) {\nif (i % j == 0) {\nprime = false;\nbreak;\n}\n}\nif (!prime) {\ncontinue;\n}\ns += (char) ('a' + i % 26);\ncc += (s.back() == 'z');\nif (cc == keep || (int) s.size() == N) {\nbreak;\n}\n}\nN = (int) s.size();\nint start = 0;\nstring ret = \"\";\nfor (int i = 0; i < keep; i++) {\nint rm = N - start;\nchar mx = ' ';\nint pos = -1;\nfor (int j = start; j <= N - keep + i; j++) {\nif (s[j] mx) {\nmx = s[j];\npos = j;\n}\n}\nret += s[pos];\nstart = pos + 1;\n}\nreturn ret;\n}\n```\n\n## SchedulingWoes \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15756)\n__Used as: Division One - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 500       |\n| __Submission Rate__       | 60 / 116 (51.72%)  |\n| __Success Rate__          | 42 / 60 (70.00%)   |\n| __High Score__            | neal_wu for 469.47 points (7 mins 20 secs)      |\n| __Average Score__         | 345.22 (for 42 correct submissions)    |\n\nSort exams by their date. Let’s keep the best answer while iterating exams from the first one to the last one.\n\nConsider till a specific exam like (D, T) we succeed in passing several exams. Now there are two cases to consider:\n\nWe can add (D, T) to the answer too. It can be checked if we keep the number of mornings we have studied for current passed exams.\n\nWe can not add (D, T) to the answer. Let’s try to substitute it with another exam in the current answer. The substitution is affordable if there is a passed exam in the current answer which needs more time to pass. So we can remove the unprofitable exam from the answer and add (D, T) to the answer instead. This can be done if we keep exams in a heap (C++ std::set or std::priority_queue).\n\nTotal time complexity is O(n log n).Code (neal_wu):\n\n```\nint study(int N, int seed, vector<int Dprefix, int maxD, vector<int Tprefix, int factor) {\nvector<long long random(2 * N);\nrandom[0] = seed;\n\nfor (int i = 1; i < 2 * N; i++)\nrandom[i] = (random[i - 1] * 1103515245 + 12345) % (1LL << 31);\n\nvector<long long D(N), T(N);\n\nfor (int i = 0; i < (int) Dprefix.size(); i++) {\nD[i] = Dprefix[i];\nT[i] = Tprefix[i];\n}\n\nfor (int i = (int) Dprefix.size(); i < N; i++) {\nD[i] = 1 + random[2 * i] % maxD;\nlong long maxT = max(1LL, D[i] / factor);\nT[i] = 1 + random[2 * i + 1] % maxT;\n}\n\nvector<pair<long long, long long exams;\n\nfor (int i = 0; i < N; i++)\nexams.emplace_back(D[i], T[i]);\n\nsort(exams.begin(), exams.end());\npriority_queue<long long pq;\nint pass_count = 0;\nlong long current_day = 0, free_days = 0;\n\nfor (pair<long long, long long &exam : exams) {\nlong long D = exam.first;\nlong long T = exam.second;\n\nfree_days += D - current_day;\ncurrent_day = D;\n\nif (free_days < T && !pq.empty() && pq.top() T) {\nfree_days += pq.top();\npass_count--;\npq.pop();\n}\n\nif (free_days = T) {\nfree_days -= T;\npass_count++;\npq.push(T);\n}\n}\n\nreturn pass_count;\n}\n```\n\n## ThreeColorTrees \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15754)\n__Used as: Division One - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 1000       |\n| __Submission Rate__       | 30 / 116 (25.86%)    |\n| __Success Rate__          | 1 / 30 (3.33%)   |\n| __High Score__            | Petr for 361.20 points (43 mins 22 secs)       |\n| __Average Score__         | 361.20 (for 1 correct submission)     |\n\nLet’s start with an easier task. The tree is given, just count the number of ways to color it. Here is it:\n\n```\nstatic double count(int[] p) {\nif (p[0] != -1) throw new RuntimeException();\nfor (int i = 1; i < p.length; ++i) if (p[i] = i) throw new RuntimeException();\ndouble[][] res = new double[p.length][4];\nfor (int i = 0; i < p.length; ++i) {\nres[i][0] = 2 * DELTA;\nres[i][1] = 1 * DELTA;\n}\nfor (int i = p.length - 1; i 0; --i) {\ndouble[] nr = new double[4];\nfor (int a = 0; a < 4; ++a) {\nfor (int b = 0; b < 4; ++b) {\nif ((a & 1) != 0) {\nif (b != 0) continue;\n}\nif ((a & 2) != 0) {\nif ((b & 1) != 0) continue;\n}\nnr[(a | (b << 1)) & 3] += res[p[i]][a] * res[i][b] * INVDELTA;\n}\n}\nres[p[i]] = nr;\n}\ndouble s = 0;\nfor (double x : res[0]) s += x;\nreturn s;\n}\n```\n\nThe function uses dp on a tree to count the number of ways. To avoid inf values, it uses DELTA = 1e-130 and INVDELTA = 1e130.\n\nNow, we need to check some patterns. Path works for small n’s. Binary tree is not good. Generating some good random trees with small n leads to trees like this:\n\n![SRM 769](//images.ctfassets.net/piwi0eufbb2g/nG3h9AiDxzmK4J1pGitQA/37cde3010a41410376d758fcb0df6894/SRM_769.webp)\nTrees like ternary tree, but added a vertex on each edge. We can generate them by this code:\n\n```\nfor (int i = 1; i < n; ++i)\nres[i] = i % 2 == 0 ? i - 1 : i / 6;\n```\nCheck it against any possible n. It doesn’t work for 12, 24, 36. The first idea comes to mind is to change it to:\n\n```\nfor (int i = 1; i < n; ++i)\nres[i] = i % 2 != 0 ? i - 1 : i / 6;\n```\nAnd it works!\n\nHere is the code (by Arpa):\n\n```\npublic int[] construct(int n) {\nint[] res = new int[n];\nif(n % 12 == 0)\nfor (int i = 1; i < n; ++i)\nres[i] = i % 2 != 0 ? i - 1 : i / 6;\nelse\nfor (int i = 1; i < n; ++i)\nres[i] = i % 2 == 0 ? i - 1 : i / 6;\nreturn Arrays.copyOfRange(res, 1, res.length);\n}\n```\nAlso, this code by Petr uses local search and it works:\n\n```\nimport java.util.Arrays;\nimport java.util.Random;\n\npublic class ThreeColorTrees {\nstatic double DELTA = 1e-130;\nstatic double INVDELTA = 1e130;\n\npublic int[] construct(int N) {\nint[] res = new int[N];\nfor (int i = 0; i < N; ++i) res[i] = i - 1;\ndouble need = (1 + 1e-9) * DELTA;\nfor (int i = 0; i < N; ++i) need *= 2.62;\ndouble sofar = count(res);\nRandom random = new Random(754315351351L);\nwhile (sofar < need) {\nint cur = 2 + random.nextInt(N - 2);\nint dest = random.nextInt(cur);\nif (dest != res[cur]) {\nint saved = res[cur];\nres[cur] = dest;\ndouble got = count(res);\nif (got sofar) {\nsofar = got;\n} else {\nres[cur] = saved;\n}\n}\n}\nreturn Arrays.copyOfRange(res, 1, res.length);\n}\n\nstatic double count(int[] p) {\nif (p[0] != -1) throw new RuntimeException();\nfor (int i = 1; i < p.length; ++i) if (p[i] = i) throw new RuntimeException();\ndouble[][] res = new double[p.length][4];\nfor (int i = 0; i < p.length; ++i) {\nres[i][0] = 2 * DELTA;\nres[i][1] = 1 * DELTA;\n}\nfor (int i = p.length - 1; i 0; --i) {\ndouble[] nr = new double[4];\nfor (int a = 0; a < 4; ++a) {\nfor (int b = 0; b < 4; ++b) {\nif ((a & 1) != 0) {\nif (b != 0) continue;\n}\nif ((a & 2) != 0) {\nif ((b & 1) != 0) continue;\n}\nnr[(a | (b << 1)) & 3] += res[p[i]][a] * res[i][b] * INVDELTA;\n}\n}\nres[p[i]] = nr;\n}\ndouble s = 0;\nfor (double x : res[0]) s += x;\nreturn s;\n}\n\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-769-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"E7MWCzjck2iAIZS6C7ykD","type":"Entry","createdAt":"2020-04-20T12:42:15.918Z","updatedAt":"2026-02-01T23:44:57.644Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":41,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 760","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-06-27T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 760 Editorials\n\n## NBAFinals\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15528)\n\nSolution: \n\nWe fill all the missing places greedily. Whenever a character in team is missing its always beneficial to fill it with W because giving some points to Warriors is always better than giving them to Raptors. Now, that we have no missing characters in team, whenever score is missing, if Raptors scored it, we want to give them the minimum possible (i.e 1) and for Warriors maximum possible (i.e 4). This is the best possible way of filling a Warriors fan could have done. So after filling team and score accordingly we can  check if Warriors have more points in this optimistic way of filling. If they have more then answer is 1, otherwise any other filling cannot give Warriors the lead. Hence answer is 0.\n\nCode:\n\n```\npublic int dubsAgain(int[] scores, String team1){\nchar[] team = team1.toCharArray();\nint n = scores.length;\nint i;\nfor(i=0;i<n;i++){\nif(team[i]=='?')\nteam[i]='W';\n}\nint ans=0;\nfor(i=0;i<n;i++){\nif(scores[i]==0){\nif(team[i]=='R')\nscores[i]=1;\nelse\nscores[i]=4;\n}\nif(team[i]=='R')\nans-=scores[i];\nelse\nans+=scores[i];\n}\nif(ans0)\nreturn 1;\nelse\nreturn 0;\n}\n```\n\nTime Complexity: O(n) where n is number of characters in team\n\n## FrogJumps\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15495)\nFirstly we need to observe that we do not need the diagonal moves. We can simulate any diagonal move using two of the moves from (left, right, top, down). Now, we can see that for a frog at (x1,y1) which can jump such that its either coordinates change by k1, all the points it can reach will be of the form (x1 + a*k1, y1 + b*k1) , where a,b are integers.\n\nSimilarly frog at (x2,y2) which can jump such that its either coordinates change by k2, all the points it can reach will be of the form (x2 + c*k2, y2 + d*k2) , where c,d are integers.\n\nSo now for them to meet, x1+a*k1 = x2+c*k2, and y1+b*k1 = y2+d*k2,\n\nNow x1-x2 = -a*k1 + c*k2 (This is true only when abs(x1-x2) is divisible by gcd(k1,k2))\n\nSimilarly abs(y1-y2) must also be divisible by gcd(k1,k2).\n\nSo now we can check these two conditions and return appropriate answer.\n\nCode:\n\n```\npublic long gcd(long a,long b){\nif(a<b){\nlong temp=a;\na=b;\nb=temp;\n}\nif(b==0)\nreturn a;\nreturn gcd(b,a%b);\n}\npublic int canMeet(long x1,long y1,long x2,long y2,long k1,long k2){\nlong val = x2-x1;\nif(val < 0){\nval*=-1;\n}\nlong gg = gcd(k1,k2);\nif(val%gg!=0){\nreturn 0;\n}\nval=y2-y1;\nif(val < 0){\nval*=-1;\n}\nif(val%gg!=0){\nreturn 0;\n}\nreturn 1;\n}\n```\n\nTime Complexity: O(log(k1) + log(k2) ) for calculating the gcd. Rest are O(1) operations.  \n\n## HomeAwayLeague\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15504)\n\nSolution:\n\nFirstly let us select the n/2 teams which host the home game in first round. This can be done in C(n,n/2) ways.\n\nNext, we need to assign away teams for the home games in the first round. For this we can assume home teams are lined in some order (for example lexicographic). And we can take n! possible orderings of away teams and allot ith home team with ith away team and so on. So now, each of the n! orderings give different schedule for first round. \n\nHence , first round can be organised in n! * C(n,n/2) ways.\n\nNow given a first round, home teams for second round are already decided which will be away teams of first round. We can assume there is some ordering among home teams again. Now , we want to take orderings of away teams such no team plays the same team they played in previous round. This is same as counting number of derangements of size n/2 because each one does not go to exactly one place(let us represent by D(n/2) ).\n\nDerangements can be calculated using recursion D(n) = (n-1)*(D(n-1)+D(n-2)).\n\nTherefore , total ways are n! * C(n,n/2)* D(n/2).\n\nCode:\n\n```\nint N = 500005;\nlong[] fact = new long[N];\nlong[] derang = new long[N];\nlong mod = (1000*1000*1000+7);\npublic long powe(long a, long b){\nlong ans=1;\nwhile(b0){\nif(b%2==1){\nans*=a;\nans%=mod;\n}\na*=a;\na%=mod;\nb/=2;\n}\nreturn ans;\n}\npublic long inver(long val){\nreturn powe(val,mod-2);\n}\npublic long range(int l,int x,int r){\nif(l<=x && x<=r){\nreturn 1;\n}\nreturn 0;\n}\npublic int matches(int n){\nint i;\nfact[0]=1;\nfor(i=1;i<N;i++){\nfact[i]=fact[i-1]*i;\nfact[i]%=mod;\n}\nderang[1]=0;\nderang[2]=1;\nfor(i=3;i<N;i++){\nderang[i]=(derang[i-1]+derang[i-2])*(i-1);\nderang[i]%=mod;\n}\nlong ans=fact[n];\nans*=inver(fact[n/2]);\nans%=mod;\nans*=derang[n/2];\nans%=mod;\nreturn (int)ans;\n}\n```\n\nTime Complexity: O(n).\n\n## CatAndMice\nAuthor : misof\n[Problem Details](https://archive.topcoder.com/ProblemStatement/pm/15530)\n\nSolution:\n\nFirstly let us handle case C = N, then the only rays are either diagonals or vertical or horizontal. We will prove soon that for other rays, number of lattice points is less than N.\n\nSo from here on lets assume C!=N. \n\nWe can first see that we can calculate the number of rays in first quadrant and see that due to symmetry it will be same in the rest of the quadrants.And since C!=N,each ray uniquely belongs to a single quadrant. So we can find number of rays in first quadrant and multiply answer with 4.\n\nNow, we have reduced to counting rays in first quadrant. We can further use symmetry along line x=y and reduce question to finding number of rays in the first 45 degrees. And multiply it by 2.\n\nNow any ray equation in the first 45 degrees looks like  y = a*x/b where (0```<```a```<```b and a and b are co prime). Different pairs of (a,b) give different rays. (we are not considering diagonal and horizontal directions because for them C=N).\n\nNow, we can notice from 0```<```a```<```b constraint that b```>=```2.  (remember this we will use later).\n\nNext number of lattice points on the ray y = a*x/b. x can take values b,2*b and so till floor(n/b). Since a<b, y will always be less than x and hence if x is in the range then y is also in the range. Hence number of lattice points on the ray will be floor(n/b). \n\nNow , since b```>=```2, maximum number of lattice points on such a ray will be floor(N/2) (```<``` N) (Proof that C=N cases are completely described above).\n\nSince number of lattice points on a ray does not depend on a, we can iterate on b. And see what for all values of b we have floor(N/b) = C.\n\nNow we want to count for a particular b , number of values possible for a such that a```>=```1 and a```<```b and a is co prime to b. This is exactly phi(b) (euler totient function).\n\nSo now answer will be sum of phi(b) over all b that satisfy floor(N/b) = C.\n\nCode (By misof ):\n\n```\npublic long countDirections(int N, int C) {\nint[] primeDivisor = new int[N+1];\nfor (int n=2; n<=N; ++n) if (primeDivisor[n] == 0) for (int i=n; i<=N; i+=n) primeDivisor[i] = n;\nint[] phi = new int[N+1];\nphi[1] = 1;\nfor (int n=2; n<=N; ++n) {\nint x = n, p = primeDivisor[n];\nphi[n] = p - 1;\nx /= p;\nwhile (x % p == 0) {\nphi[n] *= p;\nx /= p;\nphi[n] *= phi[x];\nif (C == N) return 8;\nlong answer = 0;\nfor (int b=2; b<=N; ++b) if (1L*C*b <= N && 1L*(C+1)*b N) answer += 8*phi[b];\nreturn answer;\n```\n\nTime Complexity:\n\nO(nlogn) to calculate euler totient function for the first n natural numbers.  \n\n## ComponentsForever\n[Problem Details  ](https://archive.topcoder.com/ProblemStatement/pm/15508)\n\nSolution:\n\nFirst thing is (x+y)modulo 2 value is constant across hops. So a frog at (x1,y1) cannot reach a frog (x2,y2) in any number of hops if (x1+y1) modulo 2  != (x2+y2) modulo 2.\n\nSo let us separate the frogs based on (x+y)modulo 2 and add the answers of the both cases. Because there will not be any common promise among both groups because they cannot talk to each other ever.\n\nCase 1:\n\nNow, we will work with group where all the frogs have (x+y)modulo 2 =0. From now on, in this case whenever we refer to a frog,we assume its coordinates are such that sum of them is even.\n\nFor, two frogs at (x1,y1) and (x2,y2)\n\nif (x2-x1) modulo 2 =1, then frog 1 can reach second frog only after odd number of hops. Similarly, for (x2-x1)modulo 2 =0, we can reach only in even number of hops.\n\nMinimum number of hops needed for frog 1 to reach frog 2 is max(abs(x2-x1),abs(y2-y1)).  \n\nProof: this minimum cannot be less than this because each hop x and y coordinate will change atmost by 1. Now, we will show a construction. Lets assume abs(x2-x1) ```> =``` abs(y2-y1). Now, first abs(y2-y1) moves we move y1 towards y2 and x1 towards x2. For rest of the moves we oscillate y1 near y2 (like move from y2 to y2+1 and back from y2+1 to y2) and move x1 to x2.\n\nAlso now we can see that if minimum number of hops is d, there always exist a path of length d+2k for any whole number k because after minimum hops we can move to adjacent vertex and back. And we have proved above that parity of path lengths is always same. Hence, these are the only path lengths possible.\n\nSo now,  Let us take a walkie talkie with range (L```<```R) . Now this can connect frog 1 and 2 only if \n\nR```>=```max(abs(x2-x1),abs(y2-y1)) because [L,R] will consist of atleast two consecutive integers and in every two consecutive integers above minimum hops one of them can be path lengths. So now, connectivity does not depend on L.\n\nSince L is not important for us. We will just focus on R and for each R , for every valid L answer will be same.\n\nNow, for each R, we will construct a connectivity graph and compute number of components in it. Since in each component we can make different promise,we  need expected number of components in the graph.\n\nWe can start from R = a, and keep increasing R gradually and add edges as they become eligible (an edge becomes eligible only when min hops between the two frogs ```<=``` R). If you can see this procedure is very close to kruskal algorithm to finding MST. Also another parallel is only when an MST edge is added, count of components changes. So, the only important R values where number of components change will be the edge weights of MST edges. \n\nSo now, we will have n-1 important R values and between each pair of adjacent R values components do not change. So we can count number of [L,R] pairs with that number of components and use it for finding expectation.\n\nFinally we are left with finding MST in this graph. Now, there will be O(n*n) edges. Hence, it is not feasible to construct the graph and use kruskal algorithm.\n\nFor two points (x1,y1) and (x2,y2), max(abs(x2-x1),abs(y2-y1)) is called Chebyshev distance .\n\nLet us consider transformation of point (x,y) to ((x+y)/2,(x-y)/2)\n\nNow, if we take ((x1+y1)/2,(x1-y1)/2) and ((x2+y2)/2,(x2-y2)/2),  manhattan distance between them will turn out to be max(abs(x2-x1),abs(y2-y1)). Hence, graph constructed with edge length as manhattan distance between the transformed points will be same as previous graph. Now since the graph is same, MST will also be same. So we need Manhattan MST between these transformed points which is a standard problem (Link here). \n\nHence, we can now construct the MST fastly and solve the problem. \n\nA small trick to avoid doubles, the case where points have (x+y)modulo 2 as odd, we can move all the points 1 unit right. This will not change anything in the problem since all distances will remain same.\n\ncounting number of pairs of [L,R] such that R is between R1 and R2 . Assume a```<=```R1```<=```R2```<=```b.\n\nNumber of pairs will be (R1-a)+(R1+1-a)+...(R2-a) = R2*(R2+1)/2 - (R1-1)*R1/2 - a*(R2-R1+1).\n\nCode (C++):\n\n```\n//teja349\n#include <bits/stdc++.h\n\n#define f(i,a,b) for(i=a;i<b;i++)\n#define rep(i,n) f(i,0,n)\n#define fd(i,a,b) for(i=a;i=b;i--)\n#define pb push_back\n#define mp make_pair\n#define vi vector< int\n\n#define vl vector< ll\n\n#define ss second\n#define ff first\n#define ll long long\n#define pii pair< int,int\n\n#define pll pair< ll,ll\n\n#define inf (1000*1000*1000+5)\n#define all(a) a.begin(),a.end()\n#define tri pair<int,pii\n\n#define vii vector<pii\n\n#define vll vector<pll\n\n#define viii vector<tri\n\n#define mod (1000*1000*1000+7)\n#define pqueue priority_queue< int\n\n#define pdqueue priority_queue< int,vi ,greater< int\n\nll xx[212345],yy[212345];\nconst int maxn = 2e5 + 5;\nconst int oo = (int) (1e9+10);\nstruct Point {\nint x, y, idx;\nPoint() {x = y = idx = 0;}\nPoint(const Point& rhs) : x(rhs.x), y(rhs.y), idx(rhs.idx) {}\nint operator < (const Point& rhs) const {\nreturn make_pair(x, make_pair(y, idx)) < make_pair(rhs.x, make_pair(rhs.y, rhs.idx));\n}\n};\npair<int, int fen[maxn];\nvoid upd(int p, pair<int, int val) {\np++;\nfor (; p 0; p -= p & -p) fen[p] = min(fen[p], val);\n}\nint query(int p) {\np++;\npair<int, int res = make_pair(oo, -1);\nfor (; p < maxn; p += p & -p) {\nres = min(res, fen[p]);\n}\nreturn res.second;\n}\nint dj[maxn];\nvoid init() {\nfor (int i = 0; i < maxn; i++) dj[i] = i;\n}\nint find(int u) {\nreturn dj[u] == u ? dj[u] : dj[u] = find(dj[u]);\n}\nint join(int u, int v) {\nint p = find(u);\nint q = find(v);\nif (p != q) {\ndj[p] = q;\nreturn 1;\n}\nreturn 0;\n}\nint n;\nPoint p[maxn];\npriority_queue<pair<int, pair<int, int , vector<pair<int, pair<int, int , greater<pair<int, pair<int, int pq;\nint dist(Point a, Point b) {\nreturn abs(a.x - b.x) + abs(a.y - b.y);\n}\nvoid add(int u, int v, int d) {\npq.push(make_pair(d, make_pair(u, v)));\n}\nvoid manhattan() {\nwhile(!pq.empty())\npq.pop();\nfor (int i = 0; i < n; i++) p[i].idx = i;\nfor (int dir = 0; dir < 4; dir++) {\nfor (int i = 0; i < maxn; i++) {\nfen[i] = make_pair(oo, -1);\n}\nif (dir == 1 || dir == 3) {\nfor (int i = 0; i < n; i++) swap(p[i].x, p[i].y);\n}\nelse if (dir == 2) {\nfor (int i = 0; i < n; i++) p[i].x = -p[i].x;\n}\nsort(p, p + n);\nvector<int v; static int a[maxn];\nfor (int i = 0; i < n; i++) v.push_back(a[i] = p[i].y - p[i].x);\nsort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());\nfor (int i = 0; i < n; i++) a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin();\nfor (int i = n - 1; i = 0; i--) {\nint pos = query(a[i]);\nif (~pos) add(p[i].idx, p[pos].idx, dist(p[i], p[pos]));\nupd(a[i], make_pair(p[i].x + p[i].y, i));\n}\n}\n}\nll getgg(ll a,ll b,ll Llo,ll Rhi){\na=max(a,Llo);\nb=min(b,Rhi);\nif(b<a){\nreturn 0;\n}\nll ans=b*(b+1)/2-a*(a-1)/2 - Llo*(b-a+1);\nans%=mod;\nreturn ans;\n}\nll solve(int nn,int Llo,int Rhi){\nn=nn;\nmanhattan();\nll comps=n;\ninit();\nll ans = 0;\nll prevr=1;\nwhile (pq.size()) {\nint u = pq.top().second.first;\nint v = pq.top().second.second;\nint w = pq.top().first;\npq.pop();\nif (join(u, v)) {\nans+=comps*getgg(prevr,w-1,Llo,Rhi);\nans%=mod;\ncomps--;\nprevr = w;\n}\n}\nans+=comps*getgg(prevr,Rhi,Llo,Rhi);\nans%=mod;\nreturn ans;\n}\nll powe(ll a,ll b){\nll ans=1;\nwhile(b){\nif(b%2){\nans*=a;\nans%=mod;\n}\nb/=2;\na*=a;\na%=mod;\n}\nreturn ans;\n}\nclass ComponentsForever{\npublic:\nint countComponents(int nn, vector<int Xprefix, vector<int Yprefix, int seed, int Xrange, int Yrange, int Llo, int Rhi){\nint sz=Xprefix.size();\nint i;\nfor(i=0;i<sz;i++){\nxx[i] = Xprefix[i];\nyy[i] = Yprefix[i];\n}\nll state = seed;\nll bigmod = (1LL<<31);\nfor(i=sz;i<nn;i++){\nstate = (1103515245 * state + 12345);\nxx[i] = state%Xrange;\nstate=state%bigmod;\nstate = (1103515245 * state + 12345);\nyy[i]=state%Yrange;\nstate=state%bigmod;\n}\nint cnt=0;\nint j=0;\nfor(i=0;i<nn;i++){\nif((xx[i]+yy[i])%2==0){\np[j].x = (xx[i]+yy[i])/2;\np[j].y = (xx[i]-yy[i])/2;\nj++;\ncnt++;\n}\n}\nll ans=0;\nif(cnt)\nans = solve(cnt,Llo,Rhi);\ncnt=0;\nj=0;\nfor(i=0;i<nn;i++){\nif((xx[i]+yy[i])%2==1){\nxx[i]--;\np[j].x = (xx[i]+yy[i])/2;\np[j].y = (xx[i]-yy[i])/2;\nj++;\ncnt++;\n}\n}\nif(cnt) {\nans += solve(cnt,Llo,Rhi);\n}\nll val=getgg(Llo,Rhi,Llo,Rhi);\nans*=powe(val,mod-2);\nans%=mod;\nreturn ans;\n}\n};\n```\n\nTime Complexity: Constructing Manhattan MST takes O(nlogn) time.\n\ncounting number of pairs of [L,R] such that R is between two consecutive change points (that is for all these R number of components is constant) is O(1). Since its just some formulas. And there are O(n) such intervals . So O(n) complexity.\n\nHence, total time complexity is O(nlogn).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"ngf3PiJzyUzZn7ouBvbJv","type":"Entry","createdAt":"2020-04-20T12:42:16.217Z","updatedAt":"2020-04-20T12:42:16.217Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"teja349","tcHandle":"teja349"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/single-round-match-760-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"61XHXzc67ONjFNnQh7kRZO","type":"Entry","createdAt":"2020-04-20T12:43:23.184Z","updatedAt":"2026-02-01T23:26:01.738Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":32,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 767","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-10-09T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 767 Editorials\n\n## MojtabaMahdiDooz\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15620)\nIf ‘W’ can be moved to the next cell, move it. If the next cell is ‘B’ and the next cell of the next cell is ‘-’, jump 2 cells.\n\n```\npublic static String replace(String s, int p, char c){\nreturn s.substring(0, p) + c + s.substring(p + 1);\n}\npublic static String play(String board) {\nfor(int i = 0; ; i++)\nif(i + 1 = board.length() || board.charAt(i + 1) == 'B' && (i + 2 = board.length() || board.charAt(i + 2) == 'B'))\nreturn replace(replace(board, 0, '-'), i, 'W');\n}\n\nfor i in range(50):\nboard = board.replace('W-','-W')\nboard = board.replace('WB-','-BW')\n```\n\n## ArpaKonkoori\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15619)\n\ns = (a + b)(a - b). So (a + b) must be one of the divisors of s. For each divisor of s like div:\n\nlet div = (a + b) ⇒ s / div = (a - b)\n\n⇒ a = (div + s / div) / 2, b = (div - s / div) / 2.\n\nCheck if gcd(a, b) is d or not.\n\n```\nprivate static long gcd(long a, long b){\nreturn b != 0 ? gcd(b, a % b) : a;\n}\npublic static long getA(long d, long s) {\nfor(long diff = 1; diff * diff <= s; diff++)\nif(s % diff == 0){\nlong sum = s / diff;\nlong a = (sum + diff) / 2, b = sum - a;\nSystem.err.println(String.format(\"%d %d %d %d\", sum, diff, a, b));\nif(sum % 2 == diff % 2 && b = 0 && gcd(a, b) == d)\nreturn a;\n}\nreturn -1;\n}\n\nif S % (D*D): return -1\nmaxA = -1\nS //= D*D\nfor S1 in range(1,1000001):\nif S1 * S1 S: break\nif S % S1: continue\nS2 = S // S1\nif (S1 % 2) != (S2 % 2): continue\nA, B = (S1+S2) // 2, (S2-S1) // 2\nif gcd(A,B) == 1:\nmaxA = max( maxA, A )\nif maxA == -1: return -1\nreturn maxA * D\n```\n\n## MahdiJumping\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15618)\nOne can build the graph simply. But using Dijkstra to find the distance will not work because of the constraint (n might be 5,000,000).\n\nThe solution is to keep the Dijkstra queue (or BFS queue), updated in another way. Consider a ```<``` b, and v is on the top of the queue. (v * A + B) % n must be inserted at the end of the queue. Consider we can find the correct position to insert v + 1 in the queue and keep the iterator. While going forward, the iterator goes forward.\n\nSo, we need to define the queue as linked list. Another solution is to keep two queues.\n\nWhen we are on node v, d[u] ```<``` d[v] + a is satisfied for all of the elements in the first queue like u. Also, d[u] ```>```= d[v] + a is satisfied for all of the elements in the second queue like u.\n\nWhen you want to add v + 1 (which has and edge with weight a to v), add it at the end of the first queue. When you want to add (v * A + b) % n (which has and edge with weight b to v), add it at the end of the second queue. \n\nKeep the first condition satisfied while going forward. While the first element of the second queue (let it be u) satisfy the condition d[u] < d[v] + a, pop it from the second queue and push it into the first one.\n\n```\npublic static long minDis(int n, int A, int B, int a, int b) {\nArrayDeque<Integer q1 = new ArrayDeque<();\nArrayDeque<Integer q2 = new ArrayDeque<();\nq1.addLast(0);\nlong d[] = new long[n];\nfor(int i = 1; i < n; i++)\nd[i] = (long) 1e18;\nd[0] = 0;\nwhile (true){\nif(q1.isEmpty()) {\nq1.add(q2.getFirst());\nq2.removeFirst();\n}\nInteger v = q1.getFirst();\nq1.removeFirst();\nif(v == n - 1)\nreturn d[v];\nwhile(!q2.isEmpty() && d[q2.getFirst()] < Math.min(d[v] + a, d[v] + b)) {\nq1.addLast(q2.getFirst());\nq2.removeFirst();\n}\nif(d[v + 1] d[v] + a){\nd[v + 1] = d[v] + a;\nif(a b)\nq2.addLast(v + 1);\nelse\nq1.addLast(v + 1);\n}\nif(d[(int) (((long) v * A + B) % n)] d[v] + b){\nd[(int) (((long) v * A + B) % n)] = d[v] + b;\nif(a < b)\nq2.addLast((int) (((long) v * A + B) % n));\nelse\nq1.addLast((int) (((long) v * A + B) % n));\n}\n}\n}\n```\n\n## ArpaAsDevotee\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15617)\nThere are several conditions to verify data:\n\na[i] ```>=``` b[i]\n\n a[i] = a[j] ⇒ b[i] = b[j]\n\n a[i] ```>``` a[j] ⇒ b[j] = b[i] or b[i] ```>``` a[j]\n\nTo answer a query, find two adjacent a’s to t (using binary search is not necessary), you can find the answer easily. Check the solution for more information.\n\n```\nprivate final static int maxt = 86400, maxn = 50;\nstatic class ArrayComparator implements Comparator<ArrayList<Integer {\n@Override\npublic int compare(ArrayList<Integer a, ArrayList<Integer b) {\nif(a.get(0) < b.get(0))\nreturn -1;\nif(a.get(0) b.get(0))\nreturn 1;\nif(a.get(1) < b.get(1))\nreturn -1;\nif(a.get(1) b.get(1))\nreturn 1;\nreturn 0;\n}\n}\npublic static String[] solve(int n, int q, int[] a, int[] lastSeen, int[] t){\nArrayList<ArrayList<Integer data = new ArrayList<();\nfor (int i = 0; i < n; i++) {\nArrayList<Integer tmp = new ArrayList<();\ntmp.add(a[i]);\ntmp.add(lastSeen[i]);\ndata.add(tmp);\nif(a[i] < lastSeen[i])\nreturn new String[0];\n}\ndata.sort(new ArrayComparator());\nfor(int i = 1; i < n; i++)\nif(data.get(i).get(0).equals(data.get(i - 1).get(0))) {\nif (!data.get(i).get(1).equals(data.get(i - 1).get(1)))\nreturn new String[0];\n}\nelse if(!(data.get(i).get(1).equals(data.get(i - 1).get(1)) || data.get(i).get(1) data.get(i - 1).get(0)))\nreturn new String[0];\nString[] ans = new String[q];\nfor(int i = 0; i < q; i++){\nint lo = 0, hi = n;\nwhile(hi - lo 1){\nint mid = (lo + hi) / 2;\nif(data.get(mid).get(0) <= t[i])\nlo = mid;\nelse\nhi = mid;\n}\nif(data.get(lo).get(0) t[i])\nlo--;\nif(lo = 0 && data.get(lo).get(1).equals(t[i]) || lo < n - 1 && data.get(lo + 1).get(1).equals(t[i]))\nans[i] = \"Yes\";\nelse if(lo < n - 1 && data.get(lo + 1).get(1).compareTo(t[i]) < 0 || lo = 0 && data.get(lo).get(0).equals(t[i]) && data.get(lo).get(1).compareTo(t[i]) < 0)\nans[i] = \"No\";\nelse\nans[i] = \"Not Sure\";\n}\nreturn ans;\n}\n```\n\n## InThePathToMosque\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15615)\nConsider a query starting from a vertex like v. If we have a few liters of fuel, we’ll stop on v itself. Consider we pass the edge connecting v and its parent somehow, then we have at least 2 * (length of the edge from v to its parent) liters of fuel. So, if we stop on a vertex like u, the length of an edge connecting u to its parent is at least 2 * (length of the edge from v to its parent). So, for every value for f, answer to the query (starting from vertex v) can have at most O(log(10^9)) cases.\n\nFor each vertex, keep vertices that can be the answer to the query if we start from v (in the code below, block[v]). The remaining part is to handle parked cars. Keep a Fenwick tree. A Fenwick tree with updates on vertices and queries on the sum of values written on a path.\n\nThe code below can make everything clear.\n\n```\nprivate static int[] startingTime = new int[maxn];\nprivate static int[] finishingTime = new int[maxn];\nprivate static int[] topEdgeWeight = new int[maxn];\nprivate static ArrayList<ArrayList<Integer g, blocks;\nprivate static int[] par = new int[maxn];\nprivate static long[] sumWeights = new long[maxn];\n\nprivate static class Fenwick{\nlong[] fen = new long[maxn + 1];\nFenwick(){\nArrays.fill(fen, 0);\n}\nlong get(int p){\np = startingTime[p];\nlong ans = 0;\nfor(p++; p != 0; p ^= p & -p) ans += fen[p];\nreturn ans;\n}\nvoid upd(int p, long v){\nfor(p++; p <= maxn; p += p & -p)\nfen[p] += v;\n}\nvoid upd(int l, int r, long v){ // adds v to range [l, r)\nupd(l, v);\nupd(r, -v);\n}\nvoid update(int vertex, long value){\nupd(startingTime[vertex], finishingTime[vertex], value);\n}\n\nlong getPath(int u, int par) {\nreturn get(u) - get(par);\n}\n}\nprivate static Integer currentTime = 0;\nprivate static void getStartingTimeFinishingTime(int vertex){\nstartingTime[vertex] = currentTime++;\nfor (int i = 0; i < g.get(vertex).size(); i++) {\nint u = g.get(vertex).get(i);\ngetStartingTimeFinishingTime(u);\n}\nfinishingTime[vertex] = currentTime;\n}\nprivate static ArrayList<Integer reverse(ArrayList<Integer arrayList){\nArrayList<Integer ret = new ArrayList<();\nfor (int i = arrayList.size() - 1; i = 0; i--)\nret.add(arrayList.get(i));\nreturn ret;\n}\nprivate static void getBlocks(int v, ArrayDeque<Integer bls) {\nwhile (bls.size() 1 && topEdgeWeight[bls.getLast()] <= 2 * topEdgeWeight[v])\nbls.removeLast();\nbls.addLast(v);\nblocks.get(v).addAll(bls);\nblocks.set(v, reverse(blocks.get(v)));\nfor (Integer u : g.get(v)) {\nArrayDeque<Integer finalBls = new ArrayDeque<Integer();\nfinalBls.addAll(bls);\ngetBlocks(u, finalBls);\n}\n}\n\npublic static long solve(int n, int q, int A, int B, int t){\ncurrentTime = 0;\ng = new ArrayList<();\nblocks = new ArrayList<();\nfor (int i = 0; i < n; i++) {\ng.add(new ArrayList<());\nblocks.add(new ArrayList<());\n}\nint p = 0, w = 0;\nfor (int i = 1; i < n; i++) {\np = Math.max(0, (int) (i - ((long) p * A + B) % t - 1));\nw = (int) (((long) w * A + B) % maxt);\ng.get(p).add(i);\ntopEdgeWeight[i] = w;\npar[i] = p;\nsumWeights[i] = sumWeights[p] + w;\n}\ngetStartingTimeFinishingTime(0);\ngetBlocks(0, new ArrayDeque<());\nFenwick fenwick = new Fenwick();\nint u = 0, f = 0;\nlong ans = 0;\nfor (int i = 0; i < q; i++) {\nu = (int) (((long) u * A + B) % n);\nf = (int) (((long) f * A + B) % maxt);\nint v = -1;\nfor (int j = 0; j < blocks.get(u).size(); j++) {\nv = blocks.get(u).get(j);\nif (v == 0 || f + sumWeights[u] - sumWeights[v] + fenwick.getPath(u, par[v]) < topEdgeWeight[v])\nbreak;\n}\nans += v;\nfenwick.update(v, f + sumWeights[u] - sumWeights[v] + fenwick.getPath(u, par[v]));\n}\nreturn ans;\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/single-round-match-767-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7pEBT6gMsmEW1y6dn4YTFx","type":"Entry","createdAt":"2020-04-20T12:43:23.420Z","updatedAt":"2026-02-01T23:13:13.199Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":31,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 768","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-10-10T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 768 Editorials\n\n## Div2-250 Alpha\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15601)\nGiven a string with lowercase English characters, find how long prefix matches the English alphabet. For example, given “abctyf”, return 3 because “abc” is also a prefix of English alphabet.\n\nOne naive solution is to copy the whole alphabet from the statement (“abcdefghijklmnopqrstuvwxyz”), save it as a string, and use a function to get a substring [0..i] of a string in order to compare two prefixes. It would be O(N^2) which is very fast for small constraints but we can do better. For every index i, we just need to compare the i-th character of the input with the i-th letter of the alphabet in O(N) total.\n\n```\npublic int maxPref(String s) {\nString good = \"abcdefghijklmnopqrstuvwxyz\";\nfor(int i = 0; i < s.length(); ++i) {\nif(s.charAt(i) != good.charAt(i)) {\nreturn i;\n}\n}\nreturn s.length();\n}\n```\n\nBut we can use the fact that we don’t just match two given strings. We compare one string with the English alphabet and it’s very easy to obtain the i-th character of the alphabet — just add i to ‘a’. For example, ‘a’ + 2 will give you ‘c’.\n\n```\npublic int maxPref(String s) {\nfor(int i = 0; i < s.length(); ++i) {\nif(s.charAt(i) != 'a' + i) {\nreturn i;\n}\n}\nreturn s.length();\n}\n```\n\n## Div2-500 BinaryDistance\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15734)\nIn a big binary tree, we need to find a vertex that is farthest from the given vertex V. The tree is very regular: it’s a perfect binary tree without some last (rightmost) leaves. Formally, we just say that for every vertex x from 2 to N, there is an edge between x and x/2.\n\nIt’s optimal to go up from vertex V to the root, then down to the other branch (if we entered the root from the left child, then go right, otherwise left). We need to compute the deepest vertex in that “other branch”. It will be either vertex N (which is the rightmost deepest leaf) or the first (leftmost) leaf in that branch. For example, for N=7, the interesting leaves are 4 and 6. Everything else is redundant. More details below.\n\nIf the tree wasn’t binary (just any tree), we could use DFS or BFS to find distances from V to all other vertices. We can’t do that here because the tree is too big and O(N) is too slow.\n\nFor any tree, the farthest vertex from a fixed vertex V must be a leaf. If the tree is a binary tree, every path starting from vertex V looks like this: keep going up for some time, then down to the other branch (if you came from a left child to a parent, then go to a right child, otherwise the opposite) and keep going down. When we start going down, the number of steps down we can make is equal to the depth of a subtree. Since the given binary tree is so regular, it’s always optimal to first go up to the root (instead of stopping earlier in order to go down) because our path keeps getting longer. Formally, we need to say: if vertex x has two children c1 and c2, then the depth of a subtree of c1 is smaller than 2 plus the depth of a subtree of c2. Then instead of going down from c1, it is better to go up to x and then down to c2.\n\nLet’s repeat the important observation: starting from V, it’s optimal to go up to the root, then down to the other branch (if we entered the root from the right child then go left, otherwise right). We just need to compute the distance from V to the root (which is just the depth of V in a tree) and then the depth of the other branch (the other child of the root).\n\nThe depth of some vertex can be computed by dividing it repeatedly by 2 (that is, x /= 2) till we get the root. Every step here means going to a parent and we know its index is x/2. Theoretically, we can use logarithm function to figure out the depth of x, but it’s a bad idea because the logarithm is computed with floating values. A precision error can produce an answer different by 1.\n\nWe can already solve the problem for a perfect binary tree: the answer is the depth of V plus the depth of any leaf (in particular, vertex N is a leaf). The given tree isn’t perfect though — some rightmost leaves are missing. If the vertex N is in a left branch (the subtree of vertex 2), then there are no leaves in the right branch (the subtree of vertex 3).\n\nOne solution is that we increase N to the next value of form 2^k - 1. That gives us a perfect binary tree, we can compute the answer, and then think about whether the answer should be decreased by 1 because of missing rightmost leaves. If V is in a left branch (which means using the deepest leaf in the right branch), and also original vertex N is in a left branch, leaves in the right branch are one less level deep, so we decrease the answer by 1.\n\nThe other solution is to directly compute the depth of the deepest leaf in “the other branch” (not the one in which vertex V is). Both solutions are O(log(N)).\n\n```\nint depth(int v) {\nint count = 0;\nwhile(v = 2) {\ncount++;\nv /= 2;\n}\nreturn count;\n}\nboolean is_left(int v) {\nif(v < 2) {\nthrow new IllegalArgumentException(\"bad v\");\n}\nwhile(v = 4) {\nv /= 2;\n}\nreturn v == 2; // else v == 3\n}\npublic int maxDist(int N, int V) {\nif(V == 1) {\nreturn depth(N);\n}\nif(is_left(V) && is_left(N)) {\nreturn depth(V) + depth(N) - 1;\n}\nreturn depth(V) + depth(N);\n}\n```\n\n## Div2-1000 MeanMedianCount\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15604)\nThere are N subjects and your default grade in each of them is 0, the maximum possible grade is 10. Count the number of sequence of N grades such the mean of grades at least needMean and the median of grades at least needMedian, modulo 1e9+7. Input constraints are quite small.\n\nRefer to Div1-250 MeanMedian for some more explanation of the required observations.\n\nWith small constraints and being asked to count sequences that satisfy something, you should definitely consider dynamic programming. It’s hard to keep track of the median, so we need an equivalent condition.\n\nThe median is at least X if and only if there are at least (N+1)/2 numbers that are X or higher because that would mean that after sorting the sequence the rightmost (N+1)/2 elements are at least X and thus also the middle element is X or higher.\n\nIn order to avoid floating values, the mean requirement can be changed to: the sum of all N numbers must be at least N*needMean.\n\nWe can choose sequence elements one by one and keep track of the number of elements “that are needMedian or higher” and the sum of elements. This can be done with dynamic programming like dp[prefix][countBig][sum]. The number of states O(N * N * SUM) = O(N * N * (N * 11)) = O(N^3 * G) where G=11 which can be skipped in complexity if we treat it as a constant. From each state, you should consider each of 11 possible grades and the time complexity is then O(N^3 * G^2).\n\n```\npublic int getCount(int N, int needMean, int needMedian) {\nint needSum = needMean * N;\nint needBig = (N + 1) / 2; // those with value at least needMedian\nlong[][] dp = new long[needSum+1][needBig+1];\ndp[0][0] = 1;\nfor(int subject = 0; subject < N; ++subject) {\nlong[][] new_dp = new long[needSum+1][needBig+1];\nfor(int grade = 0; grade <= 10; ++grade) {\nfor(int sum = 0; sum <= needSum; ++sum) {\nfor(int big = 0; big <= needBig; ++big) {\nnew_dp[min(needSum, sum + grade)][min(needBig, big + (grade = needMedian ? 1 : 0))] += dp[sum][big];\n}\n}\n}\nfor(int sum = 0; sum <= needSum; ++sum) {\nfor(int big = 0; big <= needBig; ++big) {\ndp[sum][big] = new_dp[sum][big] % MOD;\n}\n}\n}\nreturn (int) dp[needSum][needBig];\n}\n```\n\n## Div1-250 MeanMedian\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15557)\nThere are N subjects and your default grade in each of them is 0, the maximum possible grade is 10. You can study for d[i] days in order to increase the i-th grade by 1. What is the minimum possible number of study days in order to get the mean of grades at least needMean and the median of grades at least needMedian? Input constraints are quite small.\n\nIt’s better to spend time on subjects that require low effort. Let’s sort the given cost sequence d[n]. For example, this would give us {20, 25, 30} for the first example test. Then, the sequence of grades will be decreasing (well, non-increasing).\n\nIn order to satisfy the median constraint, the least we can do is to get grade needMedian in exactly (N+1)/2 subjects. For median 4 that would imply grades (4, 4, 0) and the cost of 4*20+4*25=180 for the example test. If the mean is small, that’s an optimal solution. Indeed, that’s the case for the first example test where the mean (4+4+0)/3 is not smaller than the required needMean of 2.\n\nIf we don’t have enough mean of grades yet, it just means we must increase the sum of grades because the equivalent condition is: the sum of grades is at least needMean*N.\n\nWe shouldn’t decrease any grades because we anyway need at least (N+1)/2 grades needMedian or higher. Instead, we should just increase low-effort subjects if necessary. The intended solution iterates over subjects (from lowest cost d[i]) and increases the grade by 1 as long as it’s necessary and we can’t exceed 10.\n\nWe sort in O(N*log(N)) and then can either do 10 increments for each subject or just use a formula like increase=min(10-currentGrade, needMean*10-currentSumOfGrades). The complexity is O(N*log(N)).\n\nOne alternative approach is dynamic programming like in knapsack. Since we have requirements about the sum of grades and the number of grades not smaller than needMedian, these two values should be dimensions of dp state. See MeanMedianCount for more detail (well, editorial will be posted later).\n\n```\npublic int minEffort(int needMean, int needMedian, int[] d) {\nint n = d.length;\nint already_sum = (n + 1) / 2 * needMedian;\nint need_sum = needMean * n;\nint answer = 0;\nsort(d);\nfor(int i = 0; i < n; ++i) {\nfor(int grade = 1; grade <= 10; ++grade) {\nif(i <= n / 2 && grade <= needMedian) { // satisfy the median condition\nanswer += d[i];\n}\nelse if(already_sum < need_sum) { // increase the sum of grades by 1\nalready_sum++;\nanswer += d[i];\n}\n}\n}\nreturn answer;\n}\n```\n\n## Div1-500 PBG\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15494)\nThere is a tournament with P polar, B brown and G grizzly bears (P, B, G <= 2000). Two random bears are chosen, they fight and one of them is eliminated, and the process continues till one bear remains. When two bears of the same species are chosen, the winner of this fight is chosen randomly (50-50 chance), otherwise a stronger species survives: grizzly > polar > brown. Find the EV (expected value) of place of Limak who is one of polar bears. Return the answer modulo 10^9+7.\n\nSmall constraints and computing EV should give you a hint that dynamic programming can be useful. Unfortunately, we can’t have three dimensions because that would be too slow. But it is a working solution: you can define that dp[P][B][G] as p-bility of getting to situation with exactly this many bears of each species and use top-down order, or alternatively define dp[P][B][G] as the answer (the EV of Limak’s place) and then move bottom-up.\n\nThe problem would be easier if Limak was one of grizzly (or brown) bears because we can then combine the other two species into one – we don’t have to distinguish between them and we just have dp[grizzly][others] and this is O(N^2) solution.\n\nHere come’s the “Aha!” moment. We can compute the EV of place of a grizzly bear, the EV of a place of a brown bear, and from these two values compute the EV of place of a polar bear. How? Well, the sum of places of all N=P+B+G bears needs to be 1+2+...+N, so the EV of place of a bear is that sum divided by N. Equivalently, you can compute the EV of sum of places of all polar bears and then divide the result by P.\n\nThe complexity is O(G*(P+B) + B*(P+G)) = O(N^2) where N=P+B+G.\n\nIf you don’t understand the details of this solution, first solve the problem Sushi (J) from Atcoder DP contest: https://atcoder.jp/contests/dp/tasks/dp_j.\n\n```\nint strong_ev(int STRONG, int WEAK) {\nint[] inv_pairs = new int[STRONG + WEAK + 1];\nfor(int i = 0; i <= STRONG + WEAK; ++i) {\ninv_pairs[i] = my_inv(i * (i - 1) / 2); // inverse modulo 1e9+7\n}\nlong[][] dp = new long[STRONG+1][WEAK+1];\ndp[STRONG][WEAK] = 1;\nint answer = STRONG + WEAK + 1; // default place\nfor(int strong = STRONG; strong = 0; --strong) {\nint p_strong_lives = mul(strong, my_inv(STRONG)); // division by 0 is ok\nfor(int weak = WEAK; weak = 0; --weak) {\nint here = (int)(dp[strong][weak] % MOD);\nanswer = (answer - mul(here, p_strong_lives)) % MOD;\nfinal int c = mul(here, inv_pairs[strong + weak]);\nif(strong = 2) {\ndp[strong-1][weak] += mul(c,strong * (strong - 1) / 2);\n}\nif(weak = 2) {\ndp[strong][weak-1] += mul(c, weak * (weak - 1) / 2);\n}\nif(strong = 1 && weak = 1) {\ndp[strong][weak-1] += mul(c, strong * weak);\n}\n}\n}\nreturn (answer + MOD) % MOD;\n}\npublic int findEV(int P, int B, int G) {\n// grizzly polar brown\nint g = strong_ev(G, P + B);\nint pg = strong_ev(P + G, B);\n// g * G + p * P = pg * (P + G)\n// p = (pg * (P + G) - g * G) / P\nint tmp = mul(pg, P + G) - mul(g, G);\ntmp = (tmp + MOD) % MOD;\nreturn mul(tmp, my_inv(P));\n}\n```\n## Div1-1050 LShape\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15741)\nWe are given N points, no two share x-coordinate or y-coordinate. Both N and x[i], y[i] are up to 3000. We are asked to compute the sum over L-scores of each triple of points. The L-score is the minimum total change of coordinates in order to get three points that resemble a letter L, possibly rotated. That is, we should be able to reorder points as (x1, y1), (x2, y2), (x3, y3) such that x1=x2 and y2=y3. Other equalities are allowed but not necessary.\n\nIt’s sometimes a good idea to get rid of one dimension. For example, in a problem of computing the sum of squared distances of all pairs in given N points – it turns out that the formula for squared distance can be split into the sum for x-coordinate and y-coordinate and we just need to compute something independently for each dimension.\n\nIn our problem, it’s almost correct to say that the score of a triple is:\n\nmin(|x1-x2|, |x1-x3|, |x2-x3|) + min(|y1-y2|, |y1-y3|, |y2-y3|)\n\nThis formula means that for each dimension we are looking for two closest points among the triple. It isn’t correct if some two points are close to each other in both dimensions. For example, if points are (0, 0), (2, 2), (3, 3), then one move is enough to get two points with same x-coordinate, also one move is enough to get two points with y-coordinate, but the answer isn’t just 1+1.\n\nBut if the formula was correct (BUT IT ISN’T!) then it isn’t hard to solve the problem. For each dimension separately: sort all coordinates (say, x[0] through x[n-1]), then in some smart way find the sum over min(x[j] - x[i], x[k] - x[j]) for triples of indices i < j < k. To do it fast, iterate over pairs (i, j) and find the number of indices k for which x[j] - x[i] would be the minimum in the triple. This just means asking how many indices k satisfy x[k] - x[j] > x[j] - x[i]. You can use binary search to get O(log(N)) (it was allowed here) or preprocessing to count values bigger than something in O(1).\n\nNow, let’s visualize a bad case – a situation when the formula doesn’t work:\n\n![SRM 768 1](//images.ctfassets.net/piwi0eufbb2g/7zI8mNZsBip0ktU9akA4iZ/c38a8f6c4da13c0a141f1e89a95320f9/SRM_768_1.webp)\nAs you can see, I think about the given points as cells of a grid. Here, two points A and B are very close to each other in both dimensions and then the score of (A, B, C) isn’t just X_MIN + Y_MIN. So, by how much is the previous formula wrong? If we can compute that quickly for all triples, we will increase the answer and we’re done.\n\nFor the situation shown in the drawing, the formula is wrong by min((C.x - B.x) - (B.x-A.x), (C.y-A.y)-(A.y-B.y)). This looks scary for now. Think about it as shifting point C in one dimension in such a way that the difference in x-coordinate B-A and C-B is the same, or the difference in y-coordinate is the same. Let’s visualize this.\n\n![SRM 768 2](//images.ctfassets.net/piwi0eufbb2g/10kQUu58KAuANNC5zDEmcg/e35d951ec94c40c7d2d4e595d0e2981e/SRM_768_2.webp)\n\nIf you think about a bounding box of points A and B, and draw something that is further by another distance A-B, you will get a point that is on the border – anything further will not work with the “formula” we used. And what happens in those bad regions is that you want to move every point C there towards the border. If you draw a diagonal of a bad region, everything above it should be moved towards one wall, everything below towards the other wall. This can be coded for sure with some segment trees and sweeping but let’s do it nicely.\n\nLet’s rotate the grid 4 times and just focus on cases with C that is above-and-on-left from A and B. Let’s iterate over pairs (A, B), and get the coordinates of the red corner in above-left from them. We need the sum of distances of all points C in that region towards a closer red wall. Let define this value as dp[x][y] for red corner at (x, y). This is easy to compute:\n\ndp[x][y] = dp[x-1][y-1] + cnt[x-1][y-1]\n\nWhere cnt[r][t] is the number of points up to cell (r, t). It works because every point C will have its distance increased by 1 if we move with red corner by +1 in both coordinates. The complexity is O(Z^2) where Z=MAX(N, coordinates). It’s ok to use binary search for extra logarithm in the first part.\n\n```\npublic long sumL(int Y[]) {\nfinal int N = Y.length;\nint[] X = new int[N];\nfor(int i = 0; i < N; ++i) {\nX[i] = i;\n}\nint C = 0;\nfor(int i = 0; i < N; ++i) {\nC = max(C, max(X[i], Y[i]));\n}\nC++;\nlong answer = 0;\nfor(int rep = 0; rep < 2; ++rep) {\n// sum over min(x2-x1, x3-x2) in this dimension\nint[] value = new int[N];\nfor(int i = 0; i < N; ++i) {\nvalue[i] = (rep == 0 ? X[i] : Y[i]);\n}\nsort(value);\nfor(int i = 0; i < N; ++i) {\nfor(int j = i + 1; j < N; ++j) {\n// you can get rid of BS with prefix/suffix sums\nint first_right = lower_bound(value, value[j] + (value[j] - value[i]));\nint first_not_left = lower_bound(value, value[i] - (value[j] - value[i]));\nint times = (N - first_right) + first_not_left;\nanswer += ((long) (value[j] - value[i])) * times;\n}\n}\n}\nfor(int rep = 0; rep < 4; ++rep) {\nfor(int i = 0; i < N; ++i) { // rotate by 90 degrees\nint tmp = X[i];\nX[i] = Y[i];\nY[i] = C-1-tmp;\n}\nfinal int INF = 1000 * 1000 * 1000 + 5;\nint[] from_x = new int[C];\nint[] from_y = new int[C];\nfor(int i = 0; i < C; ++i) {\nfrom_x[i] = from_y[i] = INF;\n}\nfor(int i = 0; i < N; ++i) {\nfrom_x[X[i]] = Y[i];\nfrom_y[Y[i]] = X[i];\n}\nlong[][] dp_count = new long[C][C];\nlong[][] dp_sum = new long[C][C];\n// dp[x][y] is pair (sum, count) in quarter up to (x, y)\nfor(int x = 0; x < C; ++x) {\nfor(int y = 0; y < C; ++y) {\nif(x 0 && y 0) {\ndp_sum[x][y] = dp_sum[x-1][y-1] + dp_count[x-1][y-1];\ndp_count[x][y] = dp_count[x-1][y-1];\n}\nif(from_x[x] <= y) {\ndp_count[x][y]++;\n}\nif(from_y[y] < x) {\ndp_count[x][y]++;\n}\n}\n}\nfor(int i = 0; i < N; ++i) {\nfor(int j = i + 1; j < N; ++j) {\nint x = min(X[i], X[j]) - abs(X[i] - X[j]);\nint y = min(Y[i], Y[j]) - abs(Y[i] - Y[j]);\nif(x = 0 && y = 0) {\nanswer += dp_sum[x][y];\n}\n}\n}\n}\nreturn answer;\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4egtSpZkcydCy82OTFtiwI","type":"Entry","createdAt":"2020-04-20T12:43:23.409Z","updatedAt":"2020-05-03T12:48:11.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Errichto","tcHandle":"Errichto","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1X3e1DpKoRfKDk0EMSnicL","type":"Asset","createdAt":"2020-05-03T12:48:07.179Z","updatedAt":"2020-05-03T12:48:07.179Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Errichto","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1X3e1DpKoRfKDk0EMSnicL/234c8f177e0a9ffc60fe4aaf076e4691/Errichto.jpeg","details":{"size":3969,"image":{"width":126,"height":140}},"fileName":"Errichto.jpeg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/single-round-match-768-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G09uBb948YLyyLMfMVncq","type":"Entry","createdAt":"2020-04-20T12:43:25.655Z","updatedAt":"2026-02-01T22:56:09.417Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":73,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 770","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","C++"],"creationDate":"2020-03-23T00:00:00.000Z","readTime":"20 min","content":"# Single Round Match 770 Editorials\n\n## MaximumMoves \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15736)\n__Used as: Division Two - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 250       |\n| __Submission Rate__       | 195 / 237 (82.28%)      |\n| __Success Rate__          | 94 / 195 (48.21%)   |\n| __High Score__            | kshitij_sodani for 246.76 points (3 mins 15 secs)       |\n| __Average Score__         | 202.98 (for 94 correct submissions)     |\n\nEvery number greater than 1 can be written using the sum of several twos and threes, for example, 7 = 2 + 2 + 3. The number n, needs n / 2 (rounded down) summands. For example, 7 needs 3 summands. 20 needs 10 summands.\n\nIf p ```>``` q or q - p = 1, the answer is -1. Else, the answer is (q - p) / 2 (rounded down).\n\n```\ndef getMaximumMoves(self, p, q):\nif pq:\nreturn -1\nif p==q:\nprint(0)\nd=q-p\nif d==1:\nreturn -1\nif d%2==0:\nreturn d//2\nelse:\nreturn d//2\n```\n\n## LayeredGlass \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15776)\n__Used as: Division Two - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 500       |\n| __Submission Rate__       | 116 / 237 (48.95%)     |\n| __Success Rate__          | 87 / 116 (75.00%)  |\n| __High Score__            | yongwhan for 436.60 points (11 mins 9 secs)     |\n| __Average Score__         | 287.84 (for 87 correct submissions)   |\n\nEach glass has 2 options to flip or not to flip and 4 options to rotate. We check each of the options for each glass and find the minimum. Note that we can skip 4 options of rotation of one of the glasses.\n\nHere is the code (by cntswj):\n\n```\ndef rotate(self, a):\nn = len(a)\nret = [[None] * n for _ in range(n)]\nfor i in range(n):\nfor j in range(n):\nret[j][n - i - 1] = a[i][j]\nret = [''.join(row) for row in ret]\nreturn ret\n\ndef flip(self, a):\nn = len(a)\nret = [[None] * n for _ in range(n)]\nfor i in range(n):\nfor j in range(n):\nret[i][j] = a[i][n - j - 1]\nret = [''.join(row) for row in ret]\nreturn ret\n\ndef check(self, a, b):\nn = len(a)\nret = 0\nfor i in range(n):\nfor j in range(n):\nif a[i][j] == 'X' or b[i][j] == 'X':\nret += 1\nreturn ret\n\ndef minDefects(self, a, b):\nn = len(a)\nret = n * n\nfor _ in range(2):\nfor _ in range(4):\nret = min(ret, self.check(a, b))\nb = self.rotate(b)\nb = self.flip(b)\nreturn ret\n```\n\n## DeleteArrays \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15738)\n__Used as: Division Two - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 900       |\n| __Submission Rate__       | 15 / 237 (6.33%)    |\n| __Success Rate__          | 5 / 15 (33.33%)  |\n| __High Score__            | taran_1407 for 481.22 points (33 mins 24 secs)     |\n| __Average Score__         | 431.97 (for 5 correct submissions) |\n\n__Used as: Division One - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 300       |\n| __Submission Rate__       | 110 / 167 (65.87%) |\n| __Success Rate__          | 89 / 110 (80.91%)  |\n| __High Score__            | Petr for 245.04 points (14 mins 7 secs)    |\n| __Average Score__         | 168.45 (for 89 correct submissions) |\n\nLet’s solve the problem case by case:\n\nOne of the arrays is longer than the sum of the length of the other arrays.Consider this array be A, sort A, some of the first elements of A will remain and others will be deleted using the first and third type of move.\n\nThe total number of elements is odd. An element will remain, the smallest element of an array.\n\nThe general case.Note that the number of moves we should do on a particular type of move is fixed. For example, consider a = b = c = 4. We must use the first, second, and, third type of move 2 times each.In fact, we should solve a system of equations with three variables. \n\nThe following code uses the NumPy library to solve the system of equations (by wilkluka).\n\n```\ndef doDelete(self, a, b, c, x, y, z):\nA = [33, 42]\nfor i in xrange(2, a):\nA.append((5 * A[i - 1] + 7 * A[i - 2]) % 1000000007 + 1)\n\nB = [13]\nfor i in xrange(1, b):\nB.append((11 * B[i - 1]) % 1000000007 + 1)\n\nC = [7, 2]\nfor i in xrange(2, c):\nC.append((5 * C[i - 1] + 7 * C[i - 2]) % 1000000007 + 1)\nmm = 0\naa = len(A)\nbb = len(B)\ncc = len(C)\nif aa bb+cc:\nA.sort()\nn = aa-bb-cc\nmm = sum(A[:n])\nA = A[n:]\nelif bb aa + cc:\nB.sort()\nn = bb - aa - cc\nmm = sum(B[:n])\nB = B[n:]\nelif cc aa + bb:\nC.sort()\nn = cc - aa - bb\nmm = sum(C[:n])\nC = C[n:]\nif (len(A) + len(B) + len(C)) % 2 == 1:\nmm = min(A)\ncost = x + z\ntb = A\nif (mm == min(B) and cost < x + y) or (mm min(B)):\nmm = min(B)\ncost = x + y\ntb = B\nif (mm == min(C) and cost < y + z) or (mm min(C)):\nmm = min(C)\ncost = z + y\ntb = C\ntb.remove(mm)\na = np.array([[1, 1, 0], [0, 1, 1], [1, 0, 1]])\nb = np.array([len(A), len(B), len(C)])\nsolutions = np.linalg.solve(a, b).astype(int)\nreturn mm, (solutions * np.array([z, x, y])).sum() + sum(A) + sum(B) + sum(C)\n\nAnd a c++ code (by ecnerwal):\n\nvector<long long doDelete(int NA, int NB, int NC, long long wx, long long wy, long long wz) {\nvector<ll A(NA);\nvector<ll B(NB);\nvector<ll C(NC);\nA[0] = 33;\nA[1] = 42;\nfor (int i = 2; i <= NA-1; i++) {\nA[i] = (5*A[i-1] + 7*A[i-2]) % 1000000007 + 1;\n}\n\nB[0] = 13;\nfor (int i = 1; i <= NB-1; i++) {\nB[i] = (11*B[i-1]) % 1000000007 + 1;\n}\n\nC[0] = 7;\nC[1] = 2;\nfor (int i = 2; i <= NC-1; i++) {\nC[i] = (5*C[i-1] + 7*C[i-2]) % 1000000007 + 1;\n}\n\nsort(A.begin(), A.end());\nsort(B.begin(), B.end());\nsort(C.begin(), C.end());\n\nvector<ll V[3];\nV[0] = A;\nV[1] = B;\nV[2] = C;\nint N[3];\nN[0] = NA;\nN[1] = NB;\nN[2] = NC;\nll W[3][3];\nmemset(W, 0, sizeof(W));\nW[0][1] = W[1][0] = wx;\nW[1][2] = W[2][1] = wy;\nW[0][2] = W[2][0] = wz;\n\nll S = 0;\nfor (int z = 0; z < 3; z++) {\nfor (int i = 0; i < N[z]; i++) {\nS += V[z][i];\n}\n}\n\nfor (int z = 0; z < 3; z++) {\nint x = (z+1)%3, y = (z+2) % 3;\nif (N[z] = N[x] + N[y]) {\nll ans = 0;\nfor (int i = 0; i < N[z] - N[x] - N[y]; i++) {\nans += V[z][i];\n}\nreturn {ans, N[x] * W[z][x] + N[y] * W[z][y] + (S - ans)};\n}\n}\nint s = (N[0] + N[1] + N[2]) / 2;\nif ((N[0] + N[1] + N[2]) & 1) {\nvector<ll ans;\nfor (int z = 0; z < 3; z++) {\nint x = (z+1)%3, y = (z+2) % 3;\nvector<ll cnd({V[z][0], W[x][y] * (s - (N[z]-1)) + W[y][z] * (s - N[x]) + W[x][z] * (s - N[y]) + (S - V[z][0])});\nif (z == 0) {\nans = cnd;\n} else {\nans = min(ans, cnd);\n}\n}\nreturn ans;\n} else {\nreturn {0, W[0][1] * (s - N[2]) + W[1][2] * (s - N[0]) + W[2][0] * (s - N[1]) + S};\n}\n}\n```\n\n## ShoppingSpree \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15702)\n__Used as: Division One - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 450       |\n| __Submission Rate__       | 79 / 167 (47.31%)|\n| __Success Rate__          | 42 / 79 (53.16%)  |\n| __High Score__            | Stonefeang for 424.48 points (7 mins 3 secs)   |\n| __Average Score__         | 315.28 (for 42 correct submissions) |\n\nThe problem is similar to find maximum-weight matching in bipartite graphs (solve it before continuing). One of the methods for solving the problem is to use minimum cost flow (read the article before you continue).\n\nFor each vertex like v, the first time we choose an edge which connects v to another vertex, we gain value of it, but next times we gain nothing.\n\nSo, here is the edges we should add:\n\n- Source to every shirt. Cost = -shirtValue[i]. Capacity = 1.\n- Source to every shirt. Cost = 0. Capacity = infinity.\n- Every jean to sink. Cost = -jeanValue[i]. Capacity = 1.\n- Every jean to sink. Cost = 0. Capacity = infinity.\n- shirtType[i] to jeansType[i]. Cost = 0. Capacity = infinity.\n\nNow when we calculate the minimum cost, it’s the answer. Three notes:\n\n- We can use k instead of infinity.\n- We should limit the initial flow from source to k.\n- We want to use the maximum gain but the algorithm calculates the minimum cost flow, so we need to set negative costs.\n\n```\n// flow part\nstruct kra {\nint cel, *prze1, *prze2;\nll koszt;\n};\nint n=0, zr, uj;\nconst ll inf=1e9;\nvector <vector <kra graf;\nvector <int bylo, aktu;\nvector <ll odl, pamodl;\nvoid vert(int v) {\nif (vn) {\nn=v;\ngraf.resize(n);\nbylo.resize(n);\naktu.resize(n);\nodl.resize(n);\npamodl.resize(n);\n}\n}\nvoid add_edge(int v, int u, int prze, ll koszt) {\nvert(v+1); vert(u+1);\nkra ret1{u, new int(prze), new int(0), koszt};\nkra ret2{v, ret1.prze2, ret1.prze1, -koszt};\ngraf[v].push_back(ret1);\ngraf[u].push_back(ret2);\n}\nvoid spfa() {\nfor (int i=0; i<n; i++) {\naktu[i]=1;\npamodl[i]=inf;\n}\naktu[zr]=pamodl[zr]=0;\nqueue <int kol;\nkol.push(zr);\nwhile(!kol.empty()) {\nint v=kol.front();\nkol.pop();\nif (aktu[v])\ncontinue;\naktu[v]=1;\nfor (kra i : graf[v]) {\nif (*i.prze1 && pamodl[v]+i.koszt<pamodl[i.cel]) {\npamodl[i.cel]=pamodl[v]+i.koszt;\naktu[i.cel]=0;\nkol.push(i.cel);\n}\n}\n}\n}\nvoid dij() {\nfor (int i=0; i<n; i++)\nodl[i]=inf;\npriority_queue < pair <ll,int dijks;\ndijks.push({0, zr});\nwhile(!dijks.empty()) {\nll dis=-dijks.top().first;\nint v=dijks.top().second;\ndijks.pop();\nif (odl[v]!=inf)\ncontinue;\nodl[v]=pamodl[v]+dis;\nfor (auto j : graf[v])\nif ((*j.prze1) && odl[j.cel]==inf)\ndijks.push({-(dis+pamodl[v]-pamodl[j.cel]+j.koszt), j.cel});\n}\n}\nint dfs(int v) {\nif (v==uj)\nreturn 1;\nbylo[v]=1;\nfor (int i=0; i<(int)graf[v].size(); i++) {\nif (!bylo[graf[v][i].cel] && (*graf[v][i].prze1) &&\nodl[v]+graf[v][i].koszt==odl[graf[v][i].cel] && dfs(graf[v][i].cel)) {\n(*graf[v][i].prze1)--;\n(*graf[v][i].prze2)++;\nreturn 1;\n}\n}\nreturn 0;\n}\npair <int,ll flow(int zrzr, int ujuj, int moge) {\nzr=zrzr; uj=ujuj;\nvert(zr+1); vert(uj+1);\nspfa();\npair <int,ll ret{0, 0};\nfor (int i=0; i<moge; i++) {\n//~ dij();\nspfa();\nodl=pamodl;\nfor (int i=0; i<n; i++)\nbylo[i]=0;\nif (!dfs(zr))\nbreak;\nret.first++;\nret.second+=odl[uj];\n}\nreturn ret;\n}\n};\n// end of flow part\n\nstruct ShoppingSpree\n{\nint maxValue(int k, vector <int shirtValue, vector <int jeansValue, vector <int shirtType, vector <int jeansType)\n{\nMinCost pawel;\nint n=shirtValue.size();\nint m=jeansValue.size();\nint d=shirtType.size();\nfor (int i=0; i<n; i++)\n{\npawel.add_edge(0, i+1, 1, -shirtValue[i]);\npawel.add_edge(0, i+1, k, 0);\n}\nfor (int i=0; i<m; i++)\n{\npawel.add_edge(n+1+i, n+m+1, 1, -jeansValue[i]);\npawel.add_edge(n+1+i, n+m+1, k, 0);\n}\nfor (int i=0; i<d; i++)\n{\npawel.add_edge(1+shirtType[i], n+1+jeansType[i], k, 0);\n}\nreturn -pawel.flow(0, n+m+1, k).second;\n}\n};\n```\n\n## RandomSelection \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15687)\n__Used as: Division One - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 900       |\n| __Submission Rate__       | 20 / 167 (11.98%)      |\n| __Success Rate__          | 12 / 20 (60.00%)     |\n| __High Score__            | bqi343 for 758.95 points (12 mins 44 secs)     |\n| __Average Score__         | 560.09 (for 12 correct submissions)    |\n\nWe add zero to the array and sort it at the first. Refer to this link next. The problem can be solved in the same way. Let’s calculate P(MAX ```<``` x), the probability that maximum (MAX) be less than x.\n\nNote that P(MAX ```<``` x) is a piecewise function. For a[i] ```<``` x ```<``` a[i + 1],\n\n![SRM 770](//images.ctfassets.net/piwi0eufbb2g/2bMlzmL8YWCAGkyO87UXOI/303fe183943c47af18503721f6dbecdb/SRM_770.webp)\n\nNote that array is zero-based and the function above just works in range (a[i], a[i + 1]).\n\nLet’s calculate the mathematical expectation (in the range (a[i], a[i + 1])):\n\n```\nauto A = Aprefix;\nll state = seed;\nwhile (sz(A) < n) {\nstate = (1103515245 * state + 12345) % (1LL<<31);\nA.pb(T+(state%Amod));\n}\nA.pb(0);\nsort(all(A));\nld ans = A.back();\nld prod = 1;\nROF(i,1,sz(A)) {\nint k = sz(A)-i;\nld p1 = A[i]*prod; // two zeroes?\nld p2 = 0;\nif (A[i] != 0) {\nprod *= pow((ld)A[i-1]/A[i],k);\np2 = A[i-1]*prod;\n}\nans -= (p1-p2)/(k+1);\n}\nreturn ans;\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-770-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2TqWyf1VABBGLOU8ZFvpg6","type":"Entry","createdAt":"2020-04-20T12:43:25.457Z","updatedAt":"2026-02-01T22:36:53.472Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":69,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 780","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2020-03-09T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 780 Editorials\n\nDiscuss problems [here](https://codeforces.com/blog/entry/74539). If there is any problem in the editorial, or any question, feel free to post a comment.\n\n## ElevatorButtons \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16010)\n__Used as: Division Two - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__                 | 300       |\n| __Submission Rate__       | 174 / 201 (86.57%)       |\n| __Success Rate__          | 146 / 174 (83.91%)      |\n| __High Score__            | racsosabe for 296.35 points (3 mins 9 secs)       |\n| __Average Score__         | 215.21 (for 146 correct submissions)      |\n\nKeep a boolean array, toVisit. toVisit[i] is true if and only if the button i is pressed. Now, consider currentDirection = -1, elevator will see floors currentFloor, currentFloor - 1, … to down and then it’ll come up to the highest floor.\n\n```\npublic int[] nextStops(int currentFloor, int currentDirection, int[] buttonsPressed) {\nboolean[] toVisit = new boolean[1001];\nfor (int x : buttonsPressed) toVisit[x] = true;\n\nint distinctFloors = 0;\nfor (boolean v : toVisit) if (v) ++distinctFloors;\nint[] answer = new int[distinctFloors];\nint idx = 0;\n\nif (currentDirection == 1) {\nfor (int f=currentFloor+1; f<=1000; ++f) if (toVisit[f]) answer[idx++] = f;\nfor (int f=currentFloor-1; f=0; --f) if (toVisit[f]) answer[idx++] = f;\n} else {\nfor (int f=currentFloor-1; f=0; --f) if (toVisit[f]) answer[idx++] = f;\nfor (int f=currentFloor+1; f<=1000; ++f) if (toVisit[f]) answer[idx++] = f;\n}\nreturn answer;\n}\n```\n\n## MemoryGame\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16009)\n__Used as: Division Two - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__       | 500       |\n| __Submission Rate__       | 88 / 201 (43.78%)      |\n| __Success Rate__       | 59 / 88 (67.05%)    |\n| __High Score__       | \tracsosabe for 404.15 points (14 mins 34 secs)      |\n| __Average Score__       | 279.58 (for 59 correct submissions)   |\n\nFollow the procedure in the statement. Note that at every moment, Alex has seen a prefix of cards. Start from the leftmost card, keep track of unmatched cards (seenValue in the code). Each time you pick a card if it’s has been seen before, match it, otherwise, pick the next card.\n\n```\npublic long countSteps(int N, int seed) {\nint[] location = new int[2*N];\nfor (int i=0; i<2*N; ++i) location[i] = i / 2;\nlong state = seed;\nfor (int i=2*N-1; i=1; --i) {\nint j = (int)(state % (i+1));\nint tmp = location[i]; location[i] = location[j]; location[j] = tmp;\nstate = (state * 1103515245 + 12345) % (1L << 31);\nint[] seenValue = new int[N];\nfor (int n=0; n<N; ++n) seenValue[n] = -1;\nint lastSeenLocation = -1;\nint matchedPairs = 0;\nint stepsTaken = 0;\nint knownPair = -1;\nwhile (matchedPairs < N) {\n++stepsTaken;\nif (knownPair != -1) {\n++matchedPairs;\nknownPair = -1;\ncontinue;\n}\n\nint v1 = location[++lastSeenLocation];\nif (seenValue[v1] != -1) {\n++matchedPairs;\ncontinue;\n}\nseenValue[v1] = lastSeenLocation;\n\nint v2 = location[++lastSeenLocation];\nif (v1 == v2) {\n++matchedPairs;\ncontinue;\n}\nif (seenValue[v2] != -1) {\nknownPair = v2;\n} else {\nseenValue[v2] = lastSeenLocation;\n}\n}\nreturn stepsTaken;\n}\n```\n\n## BeatTheStar \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16012)\n__Used as: Division Two - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__       | 1000       |\n| __Submission Rate__    | 19 / 201 (9.45%)   |\n| __Success Rate__       | 14 / 19 (73.68%)   |\n| __High Score__         | \theno239 for 848.12 points (12 mins 29 secs)     |\n| __Average Score__      | 725.35 (for 14 correct submissions)  |\n\nA player will win if his score is strictly more than n * (n + 1) / 4. Reordering games will not change the answer. Consider the game G is played first. We’re interested on scores like s, which s < n * (n + 1) / 4 (so it’s not enough for winning the game) and s + G > n * (n + 1) / 4 (so it’s enough for winning the game).\n\nNow we need dp[i] -- probability of gaining i scores in games other than G. It’s a classical knapsack problem.\n\nWe can describe the subproblem like the following: We have m items with weights w[1...m]. For a specified weight like W, calculate the probability that if we choose items randomly, the sum of weights of items equals W. The solution uses dynamic programming. dp[i][j] = consider the first i elements, what is the probability that if we choose items randomly, the sum of weights of items equals W. dp[i][j] = dp[i - 1][j] / 2 + dp[i - 1][j - w[i]] / 2.\n\n```\npublic double doesItMatter(int N, int G) {\ndouble[] oldpp = {1.};\nint maxscore = 0;\nfor (int n=1; n<=N; ++n) if (n != G) {\ndouble[] newpp = new double[maxscore+n+1];\nfor (int s=0; s<=maxscore; ++s) {\nnewpp[s] += oldpp[s] / 2;\nnewpp[s+n] += oldpp[s] / 2;\n}\nmaxscore += n;\noldpp = newpp;\n}\ndouble answer = 0;\nint total = N*(N+1) / 2;\nfor (int s=0; s<=maxscore; ++s) if (2*s < total && 2*(s+G) total) answer += oldpp[s];\nreturn answer;\n}\n```\n\n## Prominence\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16011)\n__Used as: Division One - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 450       |\n| __Submission Rate__    | 98 / 196 (50.00%)   |\n| __Success Rate__       | 63 / 98 (64.29%) |\n| __High Score__         | \ttourist for 416.62 points (8 mins 10 secs)    |\n| __Average Score__      |  261.25 (for 63 correct submissions) |\n\nThe problem is a combination of two separate problems.\n\nFor each mountain, find the next and previous mountain which is higher.\n\nRange Minimum Query.\n\nFor each mountain, let’s find the previous mountain which is higher. It’s possible with following pseudocode:\n\n```\nfor i = 1 to n\nwhile s is not empty and a[s.top()] <= a[i]:\ns.pop()\nif s is empty:\nl[i] = 0 # not found\nelse:\nl[i] = s.top()\ns.push(i)\n```\n\nFor RMQ problem, check this article.\n\n```\nint[] reversed(int[] seq) {\nint[] answer = new int[seq.length];\nfor (int i=0; i<seq.length; ++i) answer[i] = seq[ seq.length-1-i ];\nreturn answer;\n}\n\nint[] getBiggerLeft(int[] H) {\nint N = H.length;\nint[] answer = new int[N];\nint[] idx = new int[N+1];\nint[] hei = new int[N+1];\nidx[0] = -1;\nhei[0] = 1000000007;\nint cnt = 1;\nfor (int n=0; n<N; ++n) {\nwhile (hei[cnt-1] <= H[n]) --cnt;\nanswer[n] = idx[cnt-1];\nhei[cnt] = H[n];\nidx[cnt] = n;\n++cnt;\n}\nreturn answer;\n}\n\nint[] getBiggerRight(int[] H) {\nint N = H.length;\nint[] HR = reversed(H);\nint[] BL = getBiggerLeft(HR);\nint[] RBL = reversed(BL);\nfor (int n=0; n<N; ++n) RBL[n] = (N-1) - RBL[n];\nreturn RBL;\n}\n\nint L;\nint[][] T;\n\nint min_query(int lo, int hi, int r, int c, int tlo, int thi) {\nif (thi <= lo || hi <= tlo) return 1000000007;\nif (lo <= tlo && thi <= hi) return T[r][c];\nreturn Math.min( min_query(lo,hi,r+1,2*c,tlo,(tlo+thi)/2), min_query(lo,hi,r+1,2*c+1,(tlo+thi)/2,thi) );\n}\n\npublic long sumOfProminences(int N, int[] coef, int[] idx, int[] val) {\nint[] H = new int[N];\nfor (long i=0; i<N; ++i) {\nint parity = (int)(i % 2);\nlong a = coef[3*parity];\nlong b = coef[3*parity+1];\nlong c = coef[3*parity+2];\nH[(int)i] = (int)((((a*i + b) % 1000000007L)*i + c) % 1000000007L);\n}\nfor (int j=0; j<idx.length; ++j) H[ idx[j] ] = val[j];\n\nL = 0;\nwhile ((1 << L) < N) ++L;\nT = new int[L+1][];\nfor (int l=0; l<=L; ++l) {\nT[l] = new int[1<<l];\nfor (int i=0; i<(1<<l); ++i) T[l][i] = 1000000007;\n}\nfor (int n=0; n<N; ++n) T[L][n] = H[n];\nfor (int l=L-1; l=0; --l) for (int i=0; i<(1<<l); ++i) T[l][i] = Math.min( T[l+1][2*i], T[l+1][2*i+1] );\n\nint[] BL = getBiggerLeft(H);\nint[] BR = getBiggerRight(H);\nlong answer = 0;\nint peaks = 0;\n\nfor (int n=0; n<N; ++n) if ((n == 0 || H[n] H[n-1]) && (n+1 == N || H[n] H[n+1])) {\n++peaks;\nint bl = BL[n], br = BR[n];\nint bottom = 0;\nif (bl = 0) bottom = Math.max( bottom, min_query(bl+1,n,0,0,0,1<<L) );\nif (br < N) bottom = Math.max( bottom, min_query(n+1,br,0,0,0,1<<L) );\nanswer += H[n] - bottom;\n}\nreturn answer;\n}\n```\n\n## RestrictedLeaves\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15963)\n__Used as: Division One - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 1000       |\n| __Submission Rate__    | 38 / 196 (19.39%) |\n| __Success Rate__       | 36 / 38 (94.74%)|\n| __High Score__         | tourist for 934.16 points (7 mins 39 secs) |\n| __Average Score__      | 708.68 (for 36 correct submissions) |\n\nLet’s remind you about the same problem on tree (without new edges).\n\nWe used dp to solve the problem. dp[v][0] = number of independent sets in the subtree of vertex v if we don’t use v. In the same way, dp[v][1] = number of independent sets in the subtree of v if we can use v itself.\n\nThe problem is not so much different. What do we need in the subtree of vertex v?\n\nIf the vertex v is chosen.\n\nIf the leftmost leaf of the subtree is chosen.\n\nIf the rightmost leaf of the subtree is chosen.\n\nSo, let’s use dp[v][state of v][state of leftmost leaf][state of rightmost leaf]. Updating dp values is straightforward.\n\n```\nint MOD = 1_000_000_007;\nint N;\nint[] parent;\nint[][] children;\nlong[][][][] dp; // dp[vertex][x][y][z] == # of solutions for the subtree rooted at vertex given that the states of the vertex,\n// its leftmost leaf and its rightmost leaf are (x,y,z)\n\nvoid solve(int root) {\nif (children[root].length == 0) {\nfor (int r=0; r<2; ++r) for (int ll=0; ll<2; ++ll) for (int rl=0; rl<2; ++rl) dp[root][r][ll][rl] = ((r == ll && ll == rl) ? 1 : 0);\nreturn;\n}\nfor (int child : children[root]) solve(child);\n\nlong[][][] oldc = new long[2][2][2];\nlong[][][] newc = new long[2][2][2];\n\nint c0 = children[root][0];\nfor (int ll=0; ll<2; ++ll) for (int rl=0; rl<2; ++rl) {\noldc[1][ll][rl] = dp[c0][0][ll][rl];\noldc[0][ll][rl] = ( dp[c0][0][ll][rl] + dp[c0][1][ll][rl] ) % MOD;\n}\n\nfor (int i=1; i<children[root].length; ++i) {\nint ci = children[root][i];\n\nfor (int ll=0; ll<2; ++ll) for (int rl=0; rl<2; ++rl) {\nnewc[0][ll][rl] = newc[1][ll][rl] = 0;\nfor (int x=0; x<2; ++x) for (int y=0; y<2; ++y) if (x+y != 2) {\nnewc[1][ll][rl] += oldc[1][ll][x] * dp[ci][0][y][rl];\nnewc[1][ll][rl] %= MOD;\nnewc[0][ll][rl] += oldc[0][ll][x] * ( dp[ci][0][y][rl] + dp[ci][1][y][rl] );\nnewc[0][ll][rl] %= MOD;\n}\n}\nfor (int r=0; r<2; ++r) for (int ll=0; ll<2; ++ll) for (int rl=0; rl<2; ++rl) oldc[r][ll][rl] = newc[r][ll][rl];\n}\nfor (int r=0; r<2; ++r) for (int ll=0; ll<2; ++ll) for (int rl=0; rl<2; ++rl) dp[root][r][ll][rl] = oldc[r][ll][rl];\n// System.out.println(\"dp \" + root + \" = \" + dp[root][0][0] + \" \" + dp[root][0][1] + \" \" + dp[root][1][0] + \" \" + dp[root][1][1] );\n}\n\npublic int count(int[] _parent) {\nparent = _parent;\nN = parent.length;\nint[] outdegree = new int[parent.length];\nfor (int i=1; i<parent.length; ++i) ++outdegree[ parent[i] ];\nchildren = new int[N][];\nfor (int n=0; n<N; ++n) children[n] = new int[outdegree[n]];\nfor (int i=parent.length-1; i=1; --i) children[ parent[i] ][ --outdegree[parent[i]] ] = i;\n\ndp = new long[N][2][2][2];\nsolve(0);\nlong answer = 0;\nfor (int r=0; r<2; ++r) for (int ll=0; ll<2; ++ll) for (int rl=0; rl<2; ++rl) if (ll + rl != 2) answer += dp[0][r][ll][rl];\nreturn (int)(answer % MOD);\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-780-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7zZHvOq6ywSyiprhq9XfGM","type":"Entry","createdAt":"2020-04-20T12:43:25.747Z","updatedAt":"2026-02-01T22:25:55.102Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":27,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 771","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-11-28T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 771 Editorials\n\n## BagsOfMarbles\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15827)\nConsider the worst case:\n\n- a bag with no black marbles contains bagSize white marbles\n- a bag with no white marbles does not matter\n- a bag with some white marbles contains one white marble\n- a bag with some black marbles contains only black marbles, and thus does not matter\n\nThus, we can guarantee that we have enough white marbles if and only if the desired number is at most bagSize * noBlackBags + someWhiteBags.\n\nWhen actually picking up the white marbles we need, it’s always optimal to start with no-black bags (each marble we take is white) and only then to use the some-white bags (where in the worst case we first take bagSize-1 black marbles and then one white).\n\nCode:\n\n```\npublic int removeFewest(int desired, int bagSize, int noWhiteBags,\nint noBlackBags, int someWhiteBags, int someBlackBags)\n{\nint guaranteedWhiteBalls = bagSize * noBlackBags + someWhiteBags;\nif (guaranteedWhiteBalls < desired) return -1;\nif (desired <= bagSize * noBlackBags) return desired;\nint answer = bagSize * noBlackBags;\ndesired -= answer;\nreturn answer + desired * bagSize;\n}\n```\n\n## CollectAllCoins\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15784)\nFirst, suppose the number of columns is odd.\n\nWe can clearly pick up the entire first row of coins, left to right:\n\nHTTTTTT\nTTTTTTT - HHHHHHH\nTTTTTTT TTTTTTT\nTTTTTTT TTTTTTT\n\nCan we now pick up the entire second row? Not directly, left-to-right, because once we pick up the leftmost coin, its neighbor will flip from heads back to tails. As we go left to right, we can only pick up every second coin.\n\nHTTTTTT\nTTTTTTT - HHHHHHH - H H H\nTTTTTTT TTTTTTT HTHTHTH\nTTTTTTT TTTTTTT TTTTTTT\n\nThis looks great. Each coin in the topmost row got toggled twice, so they are back heads up and we can pick them up in a second pass.\n\nHTTTTTT\nTTTTTTT - HHHHHHH - H H H -\n\nTTTTTTT TTTTTTT HTHTHTH HHHHHHH\nTTTTTTT TTTTTTT TTTTTTT TTTTTTT\n\nAnd as this has brought us to the same situation with one fewer rows, we can simply repeat the above process until we pick up everything.\n\nIf the number of rows is odd, we can do the same thing but row-by-row instead of column-by-column. Probably the easiest implementation is to swap R and C, solve the task using the solution described above, and then to transpose the answer we got.\n\nFinally, it turns out that if both R and C are even, there is no solution. During the contest it was sufficient to play around with small patterns and to make an educated guess, but for the sake of completeness we include a proof of this fact.\n\nImagine a grid where the coins are at vertices and edges correspond to adjacency. Take a red pen. Each time you remove a coin, color red all the edges that now have both vertices without a coin.\n\nThe first coin is special: when you remove it, you don’t color anything red yet.\n\nFor each other coin (let’s call these ordinary coins), the number of red edges you’ll paint must be odd. (The coin starts tails, it must be heads when it is removed, so an odd number of its neighbors must have been removed before this coin was removed.)\n\nThere are R*C-1 ordinary coins. If both R and C are even, this number is odd. Thus, if it was possible to win the game, we would remove an odd number of ordinary coins, and for each of them we would draw an odd number of red edges. Thus, the total number of red edges we would draw would be odd.\n\nHowever, we can easily realize that when we win a game, all edges of the entire grid must be drawn in red (each exactly once). The grid has R(C-1) + C(R-1) edges, and for R, C even this number is even. Thus, it is not possible to win the game if both R and C are even.\n\n```\nint[] solve(int R, int C) { // assumes C is odd\nint[] answer = new int[R*C];\nint idx = 0;\nfor (int c=0; c<C; ++c) answer[idx++] = c;\nfor (int r=1; r<R; ++r) {\nfor (int c=0; c<C; c+=2) answer[idx++] = r*C+c;\nfor (int c=1; c<C; c+=2) answer[idx++] = r*C+c;\n}\nreturn answer;\n}\n\npublic int[] collect(int R, int C) {\nif (R%2 == 0 && C%2 == 0) return new int[0];\nif (C%2 == 1) return solve(R,C);\nint[] almost = solve(C,R);\nint[] answer = new int[R*C];\nfor (int i=0; i<R*C; ++i) {\nint r = almost[i]%R, c = almost[i]/R;\nanswer[i] = r*C + c;\n}\nreturn answer;\n}\n```\n\nAddendum: There are also other patterns that can be used in the cases when at least one of R and C is odd. For example, if C is odd, you can first pick up the first row, then column 0 top to bottom, column 2 top to bottom, column 4 top to bottom, …, and after you finish all even-numbered columns you can pick up all odd-numbered ones in the same way.\n\n## AllEven\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15832)\nThis is a counting problem and the answers are rather large, so it screams “dynamic programming”. We have to come up with a clever way of counting multiple numbers at the same time.\n\nThe crucial observation is that when you are building a number (i.e., a sequence of digits), all information we need about it is its length (which is less than 20) and for each digit a single bit of information: do we currently have an odd or an even number of pieces of this digit?\n\nLet dp[x][y] be the number of strings of digits of length x such that the bitmask y represents those digits that have an odd number of occurrences. For example, dp[8][0000000110_2] counts the strings of length 8 that have an odd number of 1s, odd number of 2s, and an even number of each other digit. (Note that these strings can start with a zero.)\n\nThese values are easy to precompute: dp[0][0] = 1, and for x 0 we have that dp[x][y] is simply the sum of dp[x-1][y with bit d toggled] over d = 0..9.\n\nOnce we have these values, we can easily implement a function that will take an integer N and count the good numbers in the half-open range [0,N). One possible way looks as follows:\n\nDetermine L = the number of digits in N.\n\nFor each length i < L, count all good numbers of length i. This can be done e.g. by trying all possibilities for the first digit (d=1..9) and then adding dp[i-1][only bit d is on].\n\nCount the good numbers of length L that are less than N. This can be done by trying all possibilities for the length of the prefix the number shares with N, and all possibilities for the next digit (which has to be smaller than the corresponding digit in N, and it has to be at least 1 if it’s the leading digit).\n\n## TwoMonthScheduling\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15829)\nThis is also a dynamic programming problem, but this time we will need to do some optimization as well. \n\nFor x < y, let dp[x][y] = minimum time to complete first y jobs if we do the second month of exactly the last y-x of them during last month (or infinity if we cannot do that at all). The solution to the task is then the minimum of dp[x][all jobs].\n\nBefore we start actually computing the dp[][] values, we’ll do one more thing: precompute the prefix sums for the two input arrays. That way we can take any range of jobs and in constant time determine the total number of workers they require each month.\n\nWhen computing dp[y][z], we have the following options:\n\nDuring the penultimate month we do only the first month of the last z-y jobs and nothing else. In this case the number of months we’ll need is 2 + minimum of dp[*][y].\n\nDuring the penultimate month we also do the second month of the immediately preceding x-y jobs, for some x < y such that we can do all those jobs at the same time. In this case the number of months we’ll need is 1 + dp[x][y].\n\nThis gives us a solution in O(n^3): we have O(n^2) states and O(n) options to consider for each of them.\n\nHowever, the above solution can be optimized as follows: Suppose we fix y and compute all dp[y][z] in decreasing order of z. As we decrease z, we decrease the number of jobs done in the last month, which means that the range of valid options for x either remains the same, or increases. Thus, each time we decrease z, we update the range of valid options for x and update the minimum solution produced by any of them.\n\nAfter this update, we can evaluate all the states dp[y][*] in O(n) time, bringing the total time complexity down to O(n^2).\n\n## TrianglePath\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15831)\nThis geometry problem gives you some freedom when constructing your solution, so it’s possible to solve it using some local optimization techniques -- if implemented well, they converge quickly. (Which is why I didn’t use this problem in a more serious round ;) ) However, there is also a deterministic solution and a nice proof that it always works. This is explained below.\n\nWe can restate the condition as follows: “The sum of squares of segment lengths must be at most equal to the square of the hypotenuse.” Stated this way, it should remind you of the Pythagorean theorem. And indeed, as illustrated in Example 0, when given the three corners of the triangle, the optimal solution is to use both legs of the triangle and then the condition is satisfied exactly.\n\nThe main trick in the deterministic solution is as follows: Suppose our triangle is ABC, with the right angle at A and going ccw. Drop an altitude from A onto BC and call its foot D. We have now divided the triangle into two smaller right triangles (both similar to the original one): DCA and DAB. Some of our points are inside DCA, some are not.\n\nWhy did we divide the triangle like this? Well, because now we can solve the problem recursively for each of the new triangles. From each of them we will get a polyline at most as long as its hypotenuse: that is, from DCA its length will be at most |AC|^2 and from DAB it will be at most |AB|^2. But the hypotenuses of the new triangles are the legs of the original one -- and as the total length is at most |AC|^2 + |AB|^2, it is at most |BC|^2, and we are done.\n\nTwo technical notes follow.\n\nFirst, the base case of the recursion is when all points we have in our triangle are at the same coordinates, and then the construction is trivial.\n\nSecond, the analysis above was a bit sloppy. It would be correct if we had a point at A in both of the smaller triangles, as then we could directly concatenate the two partial solutions at that point. What we actually do is we simply connect the last point of one of them to the first point in the other. This is still OK, as the square of the new segment is at most equal to the sum of squares of segments going from those two points to A.\n\n![SRM 771](//images.ctfassets.net/piwi0eufbb2g/h9TGJNbhuO9QX1XIFTLXy/1890a684ec8fe332ffe536e7447b482c/SRM_771.webp)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-771-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1146SUKJJrpINzpLm7kumg","type":"Entry","createdAt":"2020-04-20T12:43:23.200Z","updatedAt":"2026-02-01T22:19:32.914Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":36,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 765","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2019-08-27T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 765 Editorials\n\n## MilkConsumption\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15691)\nThe key observation is that whenever a bunch of countries has an average consumption of X litres per person, at least one of those countries must have an average consumption of at least X litres per person. (If all countries drink less than X litres per person, the average over them cannot be X.)\n\nHence, there is always an optimal solution that consists of a single country. We can compute the average for each country separately, and output any one country that reaches the maximum (or any subset of those countries).\n\nFor a nicer implementation, it is not necessary to compute the averages as floating-point numbers. Instead, we can compare any two countries exactly using 64-bit integers. Instead of evaluating whether milk1/people1 ```>``` milk2/people2 we can check the equivalent condition milk1*people2 ```>``` milk2*people1. (The checker does a similar computation when verifying the output of your submission, so that the verdict cannot be affected by rounding errors.)\n\n## Tunnel\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15692)\nThis is a very simple task on dynamic programming. We will process the tunnel one row at a time. For each cell of each row we will compute the following value: if it’s possible that the spaceship reached this cell by moving forward, what is the smallest number of keystrokes to bring it there?\n\nIn the first row, the only such cell is the cell where we start, and the number of keystrokes is zero.\n\nWhen processing a row, for each position you could reach try all valid number of keypresses (from -rate to +rate) and remember the best way in which you could reach each of the cells in the next row.\n\n```\npublic int minKeystrokes(String[] level, int rate) {\n// initialize the values for row 0\nint C = level[0].length();\nint[] where = new int[C];\nfor (int c=0; c<C; ++c) where[c] = 123456789;\nfor (int c=0; c<C; ++c) if (level[0].charAt(c) == 'v') where[c] = 0;\nfor (int r=1; r<level.length; ++r) {\n// use the values for row r-1 to compute the values for row r\n// initially, we do not know any way to get to row r\nint[] newwhere = new int[C];\nfor (int c=0; c<C; ++c) newwhere[c] = 123456789;\n// for each column in row r-1 that was reachable...\nfor (int c=0; c<C; ++c) if (where[c] < 123456789) {\n// ... try all possible movements left and right...\nfor (int c2=c-rate; c2<=c+rate; ++c2) {\n// make sure you don’t leave the level or hit a wall\nif (c2 < 0 || c2 = C) continue;\nif (level[r-1].charAt(c2) == '#') continue;\nif (level[r].charAt(c2) == '#') continue;\n// if you found a valid way to move, update info\nint curr = where[c] + Math.abs(c-c2);\nnewwhere[c2] = Math.min( newwhere[c2], curr );\n}\n}\n// and move on to the next row\nwhere = newwhere;\n}\nint answer = 123456789;\nfor (int x : where) answer = Math.min( answer, x );\nif (answer == 123456789) answer = -1;\nreturn answer;\n}\n```\n\nIt should also be possible to solve this task greedily, but I expect such solutions to be more complicated and error-prone. With the dynamic programming it’s clear that we are not missing any cases, because we tried all possibilities.\n\n## FixedPointReversals\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15693)\nWithout the fixed point, we can sort any array of length N in at most N-1 reversals. This is easy: always pick the largest element that is not in its place, and reverse the part between its current and desired location, inclusive.\n\nA clear necessary condition for a solution to exist is that the sorted array and the input array must have the same value at the fixed index. This is easy to check, and as we show below, this necessary condition is also sufficient -- if it holds, the solution does exist.\n\nThe condition about not changing the value at the fixed point is a bit of a red herring. Our solution has to work for inputs in which all values are distinct, and for those inputs not changing the value is the same as not moving the element at all. So we may simply look for a solution that does not move the fixed element at all. I.e., all reversals either happen on one side of the fixed element, or they have the fixed element in the middle.\n\nLet L and R be the number of elements to the left and to the right of the fixed point. We’ll show that we can always sort the array in at most 2*min(L,R) + max(L,R) - 1 <= 72 reversals.\n\nWLOG, let’s assume L >= R. We will first put the elements in the right part onto their correct places (using at most two reversals per element) and then we’ll sort the left part. We already know how to do the latter in at most L-1 reversals, so we just need to do the former.\n\nWe’ll process the right part from the largest element to the smallest. If the current element is already where it belongs, we do nothing. If it’s already in the right part, we can get it to its proper place in one reversal. And if it’s in the left part, we can do so in two reversals: The first reversal will be inside the left part, to get it to the place that is the mirror image of the place where it belongs (*), and the second is a reversal centered at the fixed point.\n\n(*) Here we are using the fact that L >= R, so that position always exists.\n\nHere’s an example of getting the number 47 where it belongs in two reversals. The last three values are already in place, and parentheses denote the fixed point. Note that the second reversal doesn’t mess up the part that is already sorted.\n\n```\naa bb 47 cc dd ee ff gg hh (ii) jj kk ll 48 49 50\n----------------------\naa bb ff ee dd cc 47 gg hh (ii) jj kk ll 48 49 50\n----------------------\naa bb ff ee dd cc ll kk jj (ii) hh gg 47 48 49 50\n```\n\n## NiceMultiples\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15695)\nIf U/M is small (up to, say, 5,000,000), we can check each of the U/M multiples of M that are small enough separately. As U <= 10^12, the above covers all cases with M > 200,000.\n\nAs now we are left only with inputs in which M is reasonably small, we can solve those using dynamic programming. Suppose that in base B the number U has D digits. We now want to count all strings of exactly D digits that:\n\n- represent numbers at most equal to U\n- only contain zeros at the beginning\n- are divisible by M\n\nOne reasonably easy implementation is to imagine that we construct the number from the left to the right. For each prefix, we will ask the question: “How many valid solutions begin with this prefix?”\n\nFor a fixed prefix, there are three possibilities:\n\n- We know that the number will be too big: Return 0.\n- The current prefix is a prefix of U: Recursively try all possibilities for the next digit and sum the answers. (This only happens a few times during the entire solution, so it doesn’t impact the time complexity.)\n- We know that the number will be too small: The answer to our question depends only on three things -- the number of digits left, the remainder the prefix gives modulo M, and a boolean flag whether the current prefix is still zero or not (if not, we cannot use zeros any more). Do the same as in the previous case, but memoize the answer.\n\nWith memoization, this gives us a solution with 2*M*log_B(U) states and at most B transitions from each state, and that is fast enough to solve the remaining cases.\n\n## SteelMill\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15696)\nThere is an obvious dynamic programming solution that is too slow: For each amount of steel we store the cheapest way to get it, we process the mines one at a time, and for each mine and each state we try all possible ways of mining.\n\nThe above solution can be sped up using some heavy-duty data structures, but there is also a clever observation we can make that will make the implementation really simple and painless.\n\nThe problem looks like greedy should work somehow -- converting ore cheaply should be better than converting other ore more expensively, right? That’s not entirely true because of the shipping costs, but we can combine the greedy strategy with the above DP. The key observation is described below.\n\nSuppose we ignore the shipment cost for now, and we order the mines according to cost per producing 1 kg of steel, in descending order. We will now process the mines in this order, one at a time.\n\nImagine that we already processed some mines, and that for each integer amount of steel we know the cheapest way of producing it using ore from those mines. Now we are adding one additional mine. We already know what happens if we don’t buy the shipment from this mine, so we just need to examine what happens if we do buy it. If we already paid for the shipment, we now have a bunch of ore from this mine, and among all mines we currently have, this ore is the cheapest to process. Hence, in the optimal solution we want to process as much of it as possible.\n\nThus, instead of trying all possible amounts, we just try one: min( the amount available, the total we are currently trying to produce ).\n\nWith this improvement we now have a solution that runs in O(number of mines * desired amount of steel), and that is fast enough.\n\n```\n// below we assume that costPerKg is sorted in = order\nlong[] dp = new long[goal+1];\nfor (int i=1; i<=goal; ++i) dp[i] = 1L << 62;\nfor (int m=0; m<shipmentCost.length; ++m) {\nfor (int i=goal; i=1; --i) {\nint take = Math.min( i, shipmentSize[m] );\nlong pay = shipmentCost[m] + 1L * take * costPerKg[m];\ndp[i] = Math.min( dp[i], dp[i-take] + pay );\n}\n}\nreturn dp[goal];\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-765-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"40Fm3t9HKiTCWREOcnTO2g","type":"Entry","createdAt":"2020-04-20T12:43:24.658Z","updatedAt":"2026-02-01T00:02:54.040Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":53,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 772","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java","Python"],"creationDate":"2020-03-24T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 772 Editorials\n\n## PlusCastle \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15777)\n__Used as: Division Two - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 250       |\n| __Submission Rate__    | 100 / 146 (68.49%)  |\n| __Success Rate__       | 42 / 100 (42.00%)  |\n| __High Score__         | gravito12345 for 238.62 points (6 mins 15 secs) |\n| __Average Score__      | 172.98 (for 42 correct submissions)  |\n\nThe first fact is spaces are not useful. Deleting a space doesn’t reduce the number of closed figures.\n\nNow consider count is a complete square number, i. e. count = x * x. We create a full square with a side of length x. So the answer is (x - 1)^2. It also works for non-complete square counts.\n\nCode by agw02010:\n```\ndef maximiseClosedFigures(self, k):\nret = int((k ** 0.5 - 1) ** 2)\nreturn ret\n```\n\n## PermutationAndMultiplication \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15778)\n__Used as: Division Two - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 500       |\n| __Submission Rate__    | 70 / 146 (47.95%) |\n| __Success Rate__       | 25 / 70 (35.71%) |\n| __High Score__         | BKM009 for 464.92 points (7 mins 55 secs)|\n| __Average Score__      | 299.49 (for 25 correct submissions)  |\n\nWe can remove additional trailing zeros from A it will not affect the answer. Now, A = 2^ones-1 and B = 2^(ones+zeros-1) + 2 ^ (ones - 1) - 1⇒ A * B = 2^(ones+ones+zeros-1) + 2^(ones+ones-1) - 2^ones - (2^(ones+zeros-1) + 2 ^ (ones - 1) - 1).\n\nAdding (and subtracting) two numbers can be done in O(n).\n\nCode by BKM009:\n\n```\npublic static int multiplyAndCount(int m, int n)\n{\nif (m == 1)\n{\nreturn 1;\n}\nif (m <= n)\n{\nreturn 2 * m;\n}\nif (m == 2 && n == 1)\n{\nreturn 4;\n}\nif (n == 1)\n{\nreturn m + 1;\n}\nreturn m;\n}\n```\n\n## AntiprimeNumbers \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15782)\n__Used as: Division Two - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 1000       |\n| __Submission Rate__    | 9 / 146 (6.16%) |\n| __Success Rate__       | 3 / 9 (33.33%) |\n| __High Score__         | moririn2528 for 590.15 points (28 mins 11 secs)|\n| __Average Score__      | 545.22 (for 3 correct submissions)  |\n\nWe solve the problem for D = 8. We can create 3^N numbers with digits 4, 6, 8. Let’s involve digit “1”. “1” could be never placed after “1”, “4”, or “6”. Also, “1” could be never placed after two “8”s. We have 3^(n-1) options with placing 1 at the start of the string and fill the remaining with 4, 6, 8. Also, we have 3^(n-2) options to start with “81” and fill the remaining with 4, 6, 8.Code by Tomii9273:\n\n```\ndef countAntiPrimes(self, N, D):\ns = int(N)\nd = D\n\nmod = 10**9+7\ndef pow(x, y):\nif y==0:\nreturn 1\nans = 1\nwhile y 0:\nif y % 2 == 1:\nans = (ans * x) % mod\nx = (x * x) % mod\ny //= 2\nreturn ans\n\nif d < 4:\nif s == 1:\nans = 1\nelse:\nans = 0\nelif d < 6:\nans = 2\nelif d < 8:\nif s == 1:\nans = 3\nelse:\nans = (pow(2, s-1) * 3) % mod\nelse:\nif s == 1:\nans = 4\nelif s == 2:\nans = 13\nelse:\nans = (4*pow(3, s-1) + pow(3, s-2)) % mod\nreturn ans\n```\n\n## SmoothPermutations \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15783)\n__Used as: Division One - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 250       |\n| __Submission Rate__    | 91 / 126 (72.22%) |\n| __Success Rate__       | 64 / 91 (70.33%) |\n| __High Score__         | square1001 for 233.16 points (7 mins 44 secs)|\n| __Average Score__      | 146.01 (for 64 correct submissions) |\n\nLet f(n, k, x) be the number of permutations of numbers 1 to n such that the largest element among the first k elements is at most equal to x.\n\nf(n, k, x) = (n - k) * (n - 1 - k) * (n - 2 - k) * … * (x + 1 - k) * x * (x - 1) * (x - 2) * … * 1.\n\nBut there are a lot of queries. We need to calculate it faster. It’s possible with a segment tree or a sparse table. Let sp(i, j) be i * (i + 1) * (i + 2) * … * (i + 2 ^ j - 1) and precompute this function. Now calculating of every L * (L + 1) * (L + 2) * … * R is possible using this values in O(log).\n\nTotal complexity is O(T * log(MX)).Code by square1001:\n\n```\nint sz, mod;\nvector<int seg;\nint query(int a, int b, int k, int l, int r) {\nif (a <= l && r <= b) return seg[k];\nif (r <= a || b <= l) return 1;\nint lc = query(a, b, k * 2, l, (l + r) 1);\nint rc = query(a, b, k * 2 + 1, (l + r) 1, r);\nreturn 1LL * lc * rc % mod;\n}\nint query(int a, int b) {\nif (a <= 0) return 0;\nreturn query(a, b, 1, 0, sz);\n}\nlong long countPermutations(int T, int M, int MX, int seed, vector<int prefN, vector<int prefK, vector<int prefX) {\nmod = M;\nvector<int A(3 * T);\nA[0] = seed;\nfor (int i = 1; i < 3 * T; ++i) {\nA[i] = (A[i - 1] * 1103515245LL + 12345) % 2147483648LL;\n}\nvector<int N(T), K(T), X(T);\nint LEN = prefN.size();\nfor (int i = 0; i < LEN; ++i) {\nN[i] = prefN[i];\nK[i] = prefK[i];\nX[i] = prefX[i];\n}\nfor (int i = LEN; i < T; ++i) {\nN[i] = (A[i] % MX) + 1;\nK[i] = (A[T + i] % N[i]) + 1;\nX[i] = (A[2 * T + i] % N[i]) + 1;\n}\nsz = 1;\nwhile (sz <= MX) sz *= 2;\nseg.resize(sz * 2);\nfor (int i = 0; i < sz; ++i) {\nseg[i + sz] = i;\n}\nfor (int i = sz - 1; i = 1; --i) {\nseg[i] = 1LL * seg[2 * i] * seg[2 * i + 1] % mod;\n}\nlong long ans = 0;\nfor (int i = 0; i < T; ++i) {\nint lc = query(X[i] - K[i] + 1, X[i] + 1);\nint rc = query(1, N[i] - K[i] + 1);\nint sub = 1LL * lc * rc % M;\nans += sub;\n}\nreturn ans;\n}\n```\n\n## MaxPoints \n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15761)\n__Used as: Division One - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 500       |\n| __Submission Rate__    | 25 / 126 (19.84%) |\n| __Success Rate__       | 23 / 25 (92.00%) |\n| __High Score__         | tourist for 432.96 points (11 mins 33 secs)|\n| __Average Score__      | 308.40 (for 23 correct submissions) |\n\nLet’s reform the validation formula. Let s be the total sum between every two points. Let overall(S) be the sum of all pairwise distances between any point in S and any other point (in S or not in S).\n\nNow, inside(S) - outside(S) = overall(S) - s. Why? Let divide pair of points to three parts:\n\nOne from S, another from S: in overall(S), this distance counted twice. In s, it subtracted once.\n\nOne from S, another from outside of S: counted once in overall(S), subtracted once in s.\n\nOne from outside of S, another from outside of S: never counted in overall(S), once counted in s.\n\nLet’s calculate sum[i], the sum of distances from i to every point. Sort points. sweep from left to right and for each point calculate its x difference to all other points. Same for y.\n\nNow, sort points by their sum. Add them one by one while overall(S) - s ```<=``` k.\n\nCode by tourist:\n\n```\nint MaxPoints::findMaxPoints(int N, vector <int XG, vector <int YG, long long K, int seedX, int seedY) {\nvector<long long A(N);\nA[0] = seedX;\nfor (int i = 1; i < N; i++) {\nA[i] = (A[i - 1] * 1103515245 + 12345) % 2147483648LL;\n}\nvector<int X(N);\nfor (int i = 0; i < (int) XG.size(); i++) {\nX[i] = XG[i];\n}\nfor (int i = (int) XG.size(); i < N; i++) {\nX[i] = (A[i] % 2000001) - 1000000;\n}\nvector<long long B(N);\nB[0] = seedY;\nfor (int i = 1; i < N; i++) {\nB[i] = (B[i - 1] * 1103515245 + 12345) % 2147483648LL;\n}\nvector<int Y(N);\nfor (int i = 0; i < (int) YG.size(); i++) {\nY[i] = YG[i];\n}\nfor (int i = (int) YG.size(); i < N; i++) {\nY[i] = (B[i] % 2000001) - 1000000;\n}\nvector<long long sum(N);\nfor (int rot = 0; rot < 2; rot++) {\nvector<pair<int, int xs(N);\nfor (int i = 0; i < N; i++) {\nxs[i] = make_pair(rot == 0 ? X[i] : Y[i], i);\n}\nsort(xs.begin(), xs.end());\nlong long s = 0;\nfor (int i = 1; i < N; i++) {\ns += xs[i].first - xs[0].first;\n}\nfor (int i = 0; i < N; i++) {\nsum[xs[i].second] += s;\nif (i < N - 1) {\ns += (xs[i + 1].first - xs[i].first) * 1LL * (i + 1 - (N - i - 1));\n}\n}\n}\nsort(sum.begin(), sum.end());\nlong long cur = -accumulate(sum.begin(), sum.end(), 0LL) / 2;\nif (cur K) {\nreturn -1;\n}\nint ans = 0;\nfor (long long s : sum) {\nif (cur + s <= K) {\ncur += s;\n++ans;\n}\n}\nreturn ans;\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-772-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"LpmNIx2xOgQoiJclbO96s","type":"Entry","createdAt":"2020-04-20T12:43:24.763Z","updatedAt":"2026-01-31T23:47:32.992Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 773","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Graph Theory","Greedy","Math"],"creationDate":"2020-01-16T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 773 Editorials\n## Christmas Crackers\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15833)\n\nIf each of N people wants to crack at least C crackers, we need at least N*C/2 crackers total (because each cracker is cracked by two people). If N*C is odd, this number is not an integer: for example, if 3 people want to crack 3 crackers each, we need at least 4.5 crackers - and thus the smallest integer number of crackers is 5. In general, we need at least ceiling(N*C/2) crackers.\n\nThis can always be done. Probably the easiest way to do it is to assign the people to crack crackers in a “round-robin” fashion: 0,1,2...,n-1,0,1,2,...,n-1, and so on. Thus, if N*C is even, we can simply return an array in which the sequence 0,1,...,n-1 is repeated C times, and if N*C is odd, the returned array will contain an extra 0 (or any other number) at the end.\n\n## Christmas Pudding\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15864)\nIf we look at an optimal solution, we can observe the following properties:\n\n- a sweet pudding will only be touched if all the tastier sweet puddings have been eaten completely\n- a savory pudding will only be touched if all the tastier puddings (of any kind) have been eaten completely\n\nIn both cases the reason is obvious: in the opposite situation there would be a better solution that includes eating fewer spoons of this pudding and more spoons of that tastier one.\n\nThus, we can construct the optimal solution greedily as follows:\n\n1. Order all puddings according to their tastiness in decreasing order.\n2. Go through all the puddings and whenever you encouter a sweet pudding, eat from it. Do this until you either filled in the minimum requirement on sweet pudding, or until you have eaten all sweet puddings, whichever happens sooner. (Note that if we, for example, still need at least 30 spoons of a sweet pudding and we encounter a sweet pudding that has 100 spoons, at this point we only eat 30 of them.)\n3. Go once again through all the puddings (in decreasing order of tastiness), this time considering both savory puddings and uneaten sweet puddings. Eat them until you reach the requirement on total consumption, or until you eat them all.\n\nThe time complexity is O(n log n), where n is the number of puddings. (Interestingly, the task can also be solved without sorting, in O(n) time. Can you see how?)\n\n## Christmas Song Broadcast\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15866)\n\nConsider a graph in which the households are vertices and calls are (undirected, weighted) edges. Add another vertex representing the broadcast center, and edges between that vertex and the households representing all possible uses of the towers. In this graph, the optimal broadcast schedule corresponds to the minimum spanning tree (MST). This is because the set of edges we’ll use must make the graph connected, so we cannot do better, and if we choose any minimum spanning tree, we can use it to make a valid broadcast e.g. by doing BFS from the broadcast center.\n\nThe graph has at most 51 vertices, so we can use any polynomial MST algorithm (e.g., Jarník-Prim or Kruskal).\n\nThe only remaining issue is the huge number of “tower” edges. To get rid of these, we need to solve one more subproblem: for each household, what is the cheapest tower we should use?\n\nMathematically, we have the following question: find the smallest among the numbers of the form (Ax+B) mod (10^9 + 7), where x is in {0,...,T-1}.\n\nWe know that the number A is in [1,100]. Thus, the answer is either B (if Ax+B never exceeds 10^9+7) or it is at most 99 (as the first time Ax+B exceeds 10^9+7, the value of that term will be at most 99). Thus, one straightforward way is to solve the equation Ax+B = y for each y in [0,99] and pick the smallest one for which x<T, if any.\n\nAnother solution is to just traverse all possible x in a more efficient way: if you know the current value of (Ax+B) mod (10^9+7), in constant time you can compute the next x such that Ax+B will exceed 10^9+7 and jump straight to that value. This approach is probably more error-prone but it only uses highschool mathematics, as opposed to the previous solution (which needs to compute A^(-1) efficiently in order to solve the equation quickly).\n\n## Christmas Travel\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15865)\n\nIf we have N airports, there are N(N-1)/2 pairs of airports, so that is the maximum number of airlines we can have. What is the minimum? We’ll show that with A airlines we can have at most 2^A airports.\n\nClaim: If there are more than 2^A airports, some airline must have an odd cycle.\n\nProof: By induction. We know it’s true for A=1. Suppose it’s true for some A, and suppose we now have A+1 airlines and more than 2^(A+1) airports. Take any one airline. If this airline has an odd cycle, we are done. If it doesn’t, the graph formed by its flights is bipartite. Take the bigger partition: it has more than 2^A airports and those have to be served by A airlines. From the induction hypothesis it follows that on this graph one of the airlines must have an odd cycle.\n\nThis proof also gives us a construction how to serve 2^A airports using A airlines: Split them into halves, have one airline do all traffic between those halves, and solve each half recursively using the remaining airlines.\n\nThe full solution now looks as follows:\n\n1. Given N and A, check whether A is in the range where a solution exists.\n2. Find the smallest A’ such that 2^A’ >= N.\n3. Construct a valid schedule for A’ airlines and 2^A’ airports.\n4. Discard the extra airports to have a valid schedule for A’ airlines and N airports.\n5. While you don’t have enough airlines, take any airline that has multiple pairs of cities and give one of its pairs to a new airline. (Removing flights from an airline will never create an odd cycle for that airline, and an airline with a single edge also doesn’t have any odd cycles.)\n\n## Christmas Candy Split\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15867)\n\nOne possible solution is to construct a solution for the set {1,2,...,22} somehow. Then, for any input we can simply fill in the missing numbers and append that solution. This task can be solved on paper, but as the main idea of the construction (at least the one I used) generalizes to an arbitrary test case, I’ll describe that one below. There are also other correct general constructions than the one I describe below. Can you find a more efficient one (in terms of the largest number used)?\n\nWe’ll start by addressing a special case: if there is only one number, we do not need to do anything, we already have a valid solution. (The reference solution returns {2x,3x} for the input {x}, just because it can, but returning {} is also valid.)\n\nFrom this point on, we can assume that the sum S of all the numbers we have is strictly bigger than each of our numbers. The strategy we’ll use will consist of two rounds: first we’ll add some nice multiples of S to make sure that the new sum is divisible by each of the original numbers (except possibly for powers of 2), and then we’ll add some more numbers to make sure the new new sum is divisible also by all the remaining numbers.\n\nAfter the first phase, we want the new sum to be the multiple of all numbers in the input - i.e., to be a multiple of their least common multiple (LCM). Let’s denote it L. Note that LCM([1,22]) is less than 10^9, so L is always reasonably small.\n\nSo, now we have two parameters: S and L. Let’s write L = 2^A * B.\n\nSuppose, for example, that B = 21 = 16 + 8 + 1. Our current sum is 1*S. If we now add the numbers 8*S and 16*S, we will have the sum B*S. This is what we’ll do in the first phase in general: we’ll split B into powers of 2 and add the corresponding multiples of S.\n\nNow all that remains is to add the numbers B*S, 2*B*S, 4*B*S, and so on, until we have a power of 2 that is both at least equal to A and at least equal to the largest power of 2 we used among the numbers added in the first phase. The largest number used is at most equal to SB^2, so for our input it still fits into the given constraints.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-773-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1CVavgzyA8kGZHFHXCbZX8","type":"Entry","createdAt":"2020-04-20T12:43:24.658Z","updatedAt":"2026-01-31T23:29:18.597Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 775","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2020-01-17T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 775 Editorials\n\n## CompletelyDifferentStrings\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15871)\nEach position in the output string is completely independent of the others. For each position we know the letters we cannot use: the ones that are present in the forbidden array at that position. For example, if forbidden = {“cat”, “dog”, “doe”}, we know that:\n\n- At index 0 we cannot use ‘c’ or ‘d’.\n- At index 1 we cannot use ‘a’ or ‘o’.\n- At index 2 we cannot use ‘t’, ‘g’, or ‘e’.\n\nOnce we know which letters we cannot use at some index, we also know how many different letters can be used at that index. The answer is simply the product of those counts.\n\nFor example, if we have the forbidden strings mentioned above and S = 26, we have 24 options for character 0, 24 options for character 1, and 23 options for character 2, so there are 24*24*23 strings that are completely different from the forbidden ones.\n\n```\npublic int count(int S, String[] forbidden) {\nint N = forbidden.length, L = forbidden[0].length();\nint answer = 1;\nfor (int i=0; i<L; ++i) {\nboolean[] seen = new boolean[S];\nfor (int n=0; n<N; ++n) seen[ forbidden[n].charAt(i) - 'a' ] = true;\nint unseen = 0;\nfor (boolean s : seen) if (!s) ++unseen;\nanswer *= unseen;\n}\nreturn answer;\n}\n```\n\n## EnlargeTheCave\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15872)\nAs the first step of our solution we will process the kobolds: for each kobold we mark all rocks that are around the kobold as rocks that cannot be excavated. This is clearly both necessary and sufficient to make sure none of the kobolds can enter our cave.\n\nOnce we did that, we can use any kind of graph traversal (e.g., DFS or BFS) to enlarge our cave. Below, we’ll describe how to use BFS. We’ll start by placing all vertices of the current cave into the BFS queue. Then we run BFS until one of two things happens: either our cave becomes exactly as large as we need, or the queue becomes empty. In the first case we return the current map, in the second case we know that we excavated everything we could and it still wasn’t enough, so there is no solution.\n\nA single iteration of the BFS looks as follows: take a cell from the queue. For each rock that is adjacent to this cell and not marked as protected due to the kobolds, if the cave still isn’t large enough, excavate that cell and put it into the BFS queue.\n\nThe time complexity of this solution is linear in the size of the map.\n\n```\npublic String[] enlarge(String[] cave, int desiredArea) {\nint[] DR = {-1, 1, 0, 0};\nint[] DC = {0, 0, -1, 1};\n\nint R = cave.length;\nint C = cave[0].length();\n\nint currentArea = 0;\nboolean[][] isExcavated = new boolean[R][C];\nboolean[][] canBeExcavated = new boolean[R][C];\nint[] Q = new int[2*R*C + 47];\nint qs=0, qf=0;\n\n// find all cave cells and put them into a BFS queue\nfor (int r=0; r<R; ++r) for (int c=0; c<C; ++c)\nif (cave[r].charAt(c) == '.') {\n++currentArea;\nisExcavated[r][c] = true;\nQ[qf++] = r;\nQ[qf++] = c;\n}\n\n// find all kobolds, mark cells around them as impossible to excavate\nfor (int r=0; r<R; ++r)\nfor (int c=0; c<C; ++c) canBeExcavated[r][c] = true;\nfor (int r=0; r<R; ++r) for (int c=0; c<C; ++c)\nif (cave[r].charAt(c) == 'K') {\ncanBeExcavated[r][c] = false;\nfor (int d=0; d<4; ++d) {\nint nr = r+DR[d], nc = c+DC[d];\nif (nr < 0 || nr = R || nc < 0 || nc = C) continue;\ncanBeExcavated[nr][nc] = false;\n}\n}\n\n// run BFS until cave is large enough or until the queue becomes empty\nwhile (currentArea < desiredArea && qs < qf) {\nint cr = Q[qs++];\nint cc = Q[qs++];\nfor (int d=0; d<4; ++d) {\nint nr = cr+DR[d], nc = cc+DC[d];\nif (nr < 0 || nr = R || nc < 0 || nc = C) continue;\nif (isExcavated[nr][nc]) continue;\nif (!canBeExcavated[nr][nc]) continue;\n++currentArea;\nisExcavated[nr][nc] = true;\nQ[qf++] = nr;\nQ[qf++] = nc;\nif (currentArea == desiredArea) break;\n}\n}\n\nif (currentArea < desiredArea) return new String[0];\n\nString[] answer = new String[R];\nfor (int r=0; r<R; ++r) {\nanswer[r] = \"\";\nfor (int c=0; c<C; ++c)\nif (isExcavated[r][c]) answer[r] += '.';\nelse answer[r] += cave[r].charAt(c);\n}\nreturn answer;\n}\n```\n\n## IterateOverACube\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15895)\nThe outline of our solution is as follows:\n\nFind a formula that will tell us, for a given s, how many cells (x,y,z) have x+y+z = s.\n\nIterate over all s to find the correct one and the index of the cell we seek among those. That is, after this step we have a specific s and we know that we are looking for the index’-th cell among those with this s.\n\nFind a formula that will tell us, for a given s and x, how many cells (x,y,z) have x+y+z = s.\n\nIterate over all x to find the correct one and the index of the cell we seek among those. That is, after this step we know s and x, and we know that we are looking for the index’’-th cell among those.\n\nIterate over all y to find the right cell.\n\nThe second formula is easy. As s=x+y+z, we have y+z = s-x. If the value s-x is not in the range [0,2n-2], there are no such (y,z). If s-x is in [0,n-1], there are s-x+1 such (y,z): y can be anything between 0 and s-x, inclusive, and z is the rest. The remaining case is symmetric.\n\nTwo thirds of the first formula are also easy. If we have s in [0,n-1], the cells (x,y,z) with x+y+z = s form a “triangle” and there’s clearly (s+2 choose 2) such cells. (For a combinatorial argument, imagine s balls and two barriers arranged in a row. Each arrangement of these objects corresponds to one way of splitting s into x+y+z.)\n\nIf we have s in [2n-2,3n-3], the answer is the same by symmetry. More precisely, the answer for s in this range is the same as the answer for 3n-3-s.\n\nThe tricky part is the middle: the part where the cut of the cube is essentially a hexagon. A neat way of computing the number of cells for s in (n-1,2n-2) is as follows: Imagine that instead of our cube we are cutting the entire first octant of the space. The cut will be a triangle, just like in the first case. Of course, not all of those cells lie inside our cube, so we have to subtract those that don’t. But this is easy: the extra cubes are three identical triangles (corresponding to x=n, y=n, and z=n, respectively), and as we know their size (which is m = s-n+1), we can compute the number of cells they contain. Hence, the formula for the middle cuts is (s+1)(s+2)/2 - 3*m*(m+1)/2.\n\n```\nlong cutSize(long N, long S) {\nif (S <= N-1) return (S+1)*(S+2)/2;\nif (S = 2*N-2) { S = 3*N-3-S; return (S+1)*(S+2)/2; }\nlong full_triangle = (S+1)*(S+2)/2;\nlong missing_side = S - (N-1);\nlong missing_area = missing_side * (missing_side+1) / 2;\nreturn full_triangle - 3*missing_area;\n}\n\npublic int[] findCell(int N, long index) {\n// find the correct sum\nint S = 0;\nfor (; S<=3*N-3; ++S) {\nlong cs = cutSize(N,S);\nif (cs <= index) index -= cs; else break;\n}\n\n// find the correct x\nint x = 0;\nfor (; x<N; ++x) {\nint remains = S-x;\nif (remains < 0) continue;\nif (remains 2*N-2) continue;\nlong cs = (remains <= N-1) ? remains+1 : 2*N-1-remains;\nif (cs <= index) index -= cs; else break;\n}\n// find the correct y and z\nfor (int y=0; y<N; ++y) {\nint z = S-x-y;\nif (z < 0 || z = N) continue;\nif (index == 0) return new int[] {x,y,z};\n--index;\n}\nreturn new int[0]; // should not happen\n}\n```\n\n## CardDrawGame\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15830)\nThe constraints are rather small, so we should be able to try all possibilities if we don’t do it in a too naive way.\n\nThe first observation is that we can have up to 2000 different cards, but only 20 different values. So, we won’t iterate over all (roughly 2000^3) possibilities of the three cards we can draw but we will iterate over all (only roughly 20^3) possibilities for the three values we’ll draw. For each of these we will determine the probability that we draw those exact cards (this is easy) and the probability that we’ll win from having those cards in hand (this is explained below). The answer we seek is simply a weighted sum of the probability of winning over all these possibilities.\n\nThe subproblem that remains is the following one: I know the three cards in my hand and I know the multiset of cards in my deck. What is the optimal way of swapping some cards, and what win probability does it produce?\n\nIn my solution, I solved this problem using some simple dynamic programming. Given the cards in deck, I compute the probabilities p(x,y): given that I draw x cards from the deck at random (where 0 ```<=``` x ```<=``` 3), what is the probability that I will draw cards with sum y?\n\nOnce I know these values, I can iterate over all subsets of cards I can keep (making sure not to discard more than I have left to draw). Once I fix the cards I want to keep, I know their sum, hence I know the sum I want to see on the cards I draw, and that’s exactly what I precomputed above.\n\n```\nvector< vector<long long get_ways(int target, const vector<int &count) {\nvector< vector<long long answer(4, vector<long long(target+1,0));\nanswer[0][0] = 1;\nfor (int m=0; m<int(count.size()); ++m) {\n// process cards with value m\nfor (int c=3; c=1; --c)\nfor (int u=1; u<=min(c,count[m]); ++u)\nfor (int v=u*m; v<=target; ++v)\nanswer[c][v] += binomial(count[m],u) * answer[c-u][v-u*m];\n}\nreturn answer;\n}\n\ndouble winChance(int target, vector<int count) {\nlong long totalCards = accumulate(count.begin(), count.end(), 0);\nlong long totalChoices = (totalCards*(totalCards-1)*(totalCards-2)) / 6;\n\ndouble answer = 0;\n\nint M = count.size()-1;\nfor (int a=0; a<=M; ++a)\nfor (int b=a; b<=M; ++b)\nfor (int c=b; c<=M; ++c) {\n// initial hand (a,b,c)\nlong long waysToDraw = 0;\nif (a < b && b < c)\nwaysToDraw = 1LL * count[a] * count[b] * count[c];\nif (a == b && b == c)\nwaysToDraw = 1LL * count[a] * (count[a]-1) * (count[a]-2) / 6;\nif (a < b && b == c)\nwaysToDraw = 1LL * count[a] * count[b] * (count[b]-1) / 2;\nif (a == b && b < c)\nwaysToDraw = 1LL * count[a] * (count[a]-1) * count[c] / 2;\n\nvector<int newcount = count;\n--newcount[a]; --newcount[b]; --newcount[c];\nif (newcount[a] < 0 || newcount[b] < 0 || newcount[c] < 0) continue;\n\ndouble maxWinProb = 0.;\nif (a+b+c == target) maxWinProb = 1.;\n\nauto ways = get_ways(target, newcount);\n\n// try discarding 1-3\nif (totalCards = 4) {\n{ int needed = target-a-b; if (0 <= needed && needed <= target) maxWinProb = max( maxWinProb, 1. * ways[1][needed] / (totalCards-3) ); }\n{ int needed = target-a-c; if (0 <= needed && needed <= target) maxWinProb = max( maxWinProb, 1. * ways[1][needed] / (totalCards-3) ); }\n{ int needed = target-b-c; if (0 <= needed && needed <= target) maxWinProb = max( maxWinProb, 1. * ways[1][needed] / (totalCards-3) ); }\n}\nif (totalCards = 5) {\n{ int needed = target-a; if (0 <= needed && needed <= target) maxWinProb = max( maxWinProb, 2. * ways[2][needed] / (totalCards-3) / (totalCards-4) ); }\n{ int needed = target-b; if (0 <= needed && needed <= target) maxWinProb = max( maxWinProb, 2. * ways[2][needed] / (totalCards-3) / (totalCards-4) ); }\n{ int needed = target-c; if (0 <= needed && needed <= target) maxWinProb = max( maxWinProb, 2. * ways[2][needed] / (totalCards-3) / (totalCards-4) ); }\n}\nif (totalCards = 6) {\n{ int needed = target; if (0 <= needed && needed <= target) maxWinProb = max( maxWinProb, 6. * ways[3][needed] / (totalCards-3) / (totalCards-4) / (totalCards-5) ); }\n}\n\n// add to answer\nanswer += waysToDraw * maxWinProb;\n}\nreturn answer / totalChoices;\n}\n```\n\n## FairSplit\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15894)\nFour consecutive bags are easy to split: x + (x+3) is the same as (x+1) + (x+2). Thus, whenever (A,B) is fair, (A,B+4k) must also be fair. And, in particular (A,A+4k+3) is always fair. That was the easy part.\n\nGiven (A,A+n), the total number of candies is (2A+n)(n+1)/2. A necessary condition for the solution to exist is that this sum must be even. As 2A+n and n+1 have different parities, one of them must therefore be divisible by 4. The value n+1 being a multiple of 4 gives us the case mentioned above. The other case differs based on the parity of A: for even A we may have solutions with n=4k, for odd A solutions with n=4k+2.\n\nThe problem with this second type of solutions is that it not always exists. For example, if A=7 and n=2, we have the bag sizes {7,8,9}. Their sum is even, but the pair (7,9) clearly isn’t fair.\n\nWhere’s the problem? Well, first of all, we should realize that both for n=4k and for n=4k+2 the total number of bags we have is odd. Thus, one of the boys must get more bags than the other. This gives us a second necessary condition: Clearly, a solution does not exists if the boy with more bags is guaranteed to have more candy. The split that gives the boy with more bags the least candy is the split where the boy gets the n/2 + 1 smallest bags and his brother gets the n/2 largest. If this split gives the first boy too many candies, there is no solution.\n\nLuckily for us, the above condition is not just necessary but also sufficient: if, for this particular split of bags, the first boy has too few candies, we can gradually change the split by one candy in each step by always swapping some bag with x candies for a bag with x+1 candies from his brother.\n\nWhen we work out the formulas for the sum of the smallest and biggest bags, this condition simplifies to a very simple condition: the pair (A,A+n) is fair if n has the correct remainder modulo 4 and (n/2)^2 ```>=``` A.\n\nTo compute the final answer, we can now proceed as follows: Split all A into groups according to their remainder modulo 4. For each group, calculate the number of fair pairs of the first type (this is an arithmetic sequence with difference -1). Then, split all those As into new groups according to the smallest x such that x^2 ```>=``` A. For each of these new groups, calculate the number of fair pairs of the second type. (Again, this is an arithmetic sequence with difference -1, as all those As share the same smallest n that works.)\n\nThe total number of cases we consider is O(sqrt(max value)), which is fast enough by a wide margin.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-775-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2gqV6npZO7aCwiVLFBT6AM","type":"Entry","createdAt":"2020-04-20T12:43:24.992Z","updatedAt":"2026-01-31T23:20:47.765Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":35,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 776","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2020-01-29T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 776 Editorials\n\n## CheatingAfterTests\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15901)\nThere are multiple good ways how to implement a solution to this problem. One possible solution is pure brute force that can be summarized using the following pseudocode:\n\nfor each old_score in the report:\nfor each new_score in 0..99:\nif new_score can be obtained from old_score:\ncompare the new sum to the best one we have so far\n\nA slightly more clever solution is based on doing some casework:\n\nIf we have a score that is between 0 and 9, the best we can do is to improve it to a 9.\n\nIf we have a score that is between 10 and 89, the best we can do is to improve its first digit to a 9. (This will always increase the number at least by 10, and thus it is better than changing the second digit.)\n\nIf we have a score that is between 90 and 99, the best we can do is to improve it to a 99.\n\nHaving this insight we can now iterate over all scores in the report and for each score we can compute the optimal way to change it. In the end, we will just pick the option that improves the sum by the largest margin.\n\n```\npublic int cheat(int[] report) {\nint sumScores = 0;\nint bestImprovement = 0;\nfor (int score : report) {\nsumScores += score;\nint newScore = 0;\nif (score < 10) newScore = 9;\nif (10 <= score && score < 90) newScore = 90 + (score % 10);\nif (score = 90) newScore = 99;\nbestImprovement = Math.max( bestImprovement, newScore - score );\n}\nreturn sumScores + bestImprovement;\n}\n```\n\n## BinaryHeapLeaf\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15915)\nClearly, maxleaf >= the number of leaves, because if we have X leaves, the best we can do is to fill them with values 1, 2, …, X.\n\nThe above is actually always a valid solution: if we fill the heap with values N, N-1, … from the top to the bottom, we will get a valid heap with maxleaf = number of leaves. Thus, the first value we should return is simply the number of leaves in the heap.\n\nWhat is the biggest value we can place into a leaf? If the leaf is in depth D under the root (with the root itself being at depth 0), clearly it cannot contain a value bigger than N-D. This is because if we start in the leaf and go towards the root, in each step we have to move to a bigger number. Thus, maxleaf <= N-D.\n\nAnd again, this bound can actually always be obtained. We have just determined all values on the path from the root to the chosen leaf. Once we fix those, we can simply enter the remaining values as before (going from the top of the heap to the bottom, and placing the values from largest to smallest). Again, it’s clear that this way we’ll create a valid heap: whenever we place a value somewhere, the value in its parent is guaranteed to be larger.\n\nExample for N = 9. Here’s an empty heap, with just an X in place of each value:\n\nX\n/ \\\nX X\n/ \\ / \\\nX X X X\n/ \\\nX X\n\nWe pick one of the leaves that are closest to the root, and we put the biggest values onto the path to that leaf:\n\n9\n/ \\\n8 X\n/ \\ / \\\nX 7 X X\n/ \\\nX X\n\nAnd then we fill the remaining values (6-1) top to bottom:\n\n9\n/ \\\n8 6\n/ \\ / \\\n5 7 4 3\n/ \\\n2 1\n\nand voila, we have a valid heap with the number 7 in a leaf.\n\nThus, the answer is {the number of leaves, N - the depth of the most shallow leaf}. There is a formula for both, but given how small N is, the easiest solution is to actually iterate over the whole heap and check each vertex. This is what I do in the reference solution posted below.\n\n```\nboolean isLeaf(int N, int v) {\nreturn 2*v N;\n}\n\npublic int[] maxDiff(int N) {\nint numberOfLeaves = 0;\nint minLeafDepth = N + 47;\n\n// iterate over all possible depths\nfor (int depth = 0; ; ++depth) {\n// given the depth, compute the IDs of the vertices in this depth\nint lo = 1 << depth, hi = 1 << (depth+1);\n// if we are already too deep, stop\nif (lo N) break;\n// look at all vertices and count leaves among them\nfor (int v = lo; v < hi; ++v) {\nif (v N) break;\nif (isLeaf(N,v)) {\n++numberOfLeaves;\nminLeafDepth = Math.min( minLeafDepth, depth );\n}\n}\n}\nreturn new int[] { numberOfLeaves, N - minLeafDepth };\n}\n```\n\n## EncloseArea\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15917)\nA bit of experimentation will quickly show that the enclosed area must always be an even integer. Here’s how to show that. Imagine that we already placed the first wall somewhere:\n\n![SRM 776 Enclose Area](//images.ctfassets.net/piwi0eufbb2g/SWG5cOuch0xMtwVUXvOfj/06199a8dd0460e70380b868be88143d7/SRM_776_Enclose_Area.webp)\n\nThe thick red line is the first wall we placed. Once we did so, we can sketch a new grid (the thin red lines in the figure). It is obvious that the whole boundary of the enclosed area will lie on this new red grid. And therefore, the enclosed area will consist of some red squares. To conclude the proof, note that the area of a single red square is 2.\n\nWhat is the biggest area we can enclose? The 50x50 board has 196 cells on the boundary. From each of these cells we can enclose at most one half, thus the best we can do is 2500 - 98 = 2402. This is indeed possible (and the last example shows how: just draw a wavy line along the entire border of the chessboard). Thus, the valid areas are even numbers between 2 and 2402, inclusive.\n\nAnd the above observation with the red grid also gives us a neat idea how to enclose a specific area: if you want to enclose an area A, pick any A/2 adjacent squares and draw their boundary.\n\nBelow is one nice systematic numbering of the red squares (illustrated on an 8x8 grid instead of 50x50) with the property that for any K, the smallest K numbers form a connected area.\n\n![SRM 776 Enclose Area 2](//images.ctfassets.net/piwi0eufbb2g/5JKi2QzczBGbjf6s0oaBwO/6ef063a756cba8aef1c22e7d8e0d5add/SRM_776_Enclose_Area_2.webp)\n\nFor one final trick to make the implementation pleasant, just note that the boundary of a set of squares is the xor of the boundaries of the individual squares, so we can simply draw each of the first A/2 squares, making sure that the walls drawn a second time disappear. The full implementation of this solution is shown below.\n\n```\nvoid toggle(char[][] board, int r, int c, char wanted) {\nif (board[r][c] == wanted) board[r][c] = '.'; else board[r][c] = wanted;\n}\n\npublic String[] enclose(int A) {\nif (A % 2 == 1) return new String[0];\nif (A 2500 - 50 - 48) return new String[0];\n\nchar[][] board = new char[50][50];\nfor (int i=0; i<50; ++i) for (int j=0; j<50; ++j) board[i][j] = '.';\n\nint squaresWanted = A/2;\nint[] X = new int[squaresWanted];\nint[] Y = new int[squaresWanted];\nint id = 0;\nfor (int x=0; x<=24; ++x) for (int y=x; y<=48-x; ++y)\nif (id < squaresWanted) { X[id] = x; Y[id] = y; ++id; }\nfor (int x=-1; x=-24; --x) for (int y=-x; y<=48+x; ++y)\nif (id < squaresWanted) { X[id] = x; Y[id] = y; ++id; }\n\nfor (int i=0; i<squaresWanted; ++i) {\nint dr = Y[i]-X[i], dc = Y[i]+X[i];\ntoggle(board,dr,dc,'/');\ntoggle(board,dr+1,dc,'\\\\');\ntoggle(board,dr,dc+1,'\\\\');\ntoggle(board,dr+1,dc+1,'/');\n}\n\nString[] answer = new String[50];\nfor (int r=0; r<50; ++r) {\nanswer[r] = \"\";\nfor (int c=0; c<50; ++c) answer[r] += board[r][c];\n}\nreturn answer;\n}\n```\n\n## StringRings\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15916)\nThis would be easy to solve for A, B <= 1000 using dynamic programming, but the bounds in the statement look way more scary. Let’s not get scared and let’s try to go through the same thought process, we’ll see what happens if we start to unravel this problem by pulling the right string (pun intended).\n\nSuppose we have at least one red-green string (i.e., B > 0). Let’s pick an arbitrary one red-green string and let’s look at its green end. This end has to be paired with one of the 2A+B available red ends, and each of those should be equally likely. Let’s examine what happens:\n\n- With probability 2A / (2A+B) we will pick an end of a red-red rope. If we tie our two ends together, we will get a new rope that is red on both ends. So, the net effect is that we have one fewer red-green rope and no new rings.\n- With probability 1 / (2A+B) we will pick its own red end. We will have one fewer red-green rope and one new ring.\n- With probability (B-1) / (2A+B) we will pick the red end of another red-green string. Tying them together changes the two separate red-green strings into one new red-green string. So, yet again, the net effect is one fewer red-green rope and no new rings.\n\nSo, perhaps surprisingly, the effect is always exactly the same: one red-green string disappears. The only difference between the three cases is that in one of them we also get a new ring.\n\nIf we only have A red-red and A green-green strings, we can proceed as follows. We pick an arbitrary red-red rope, an arbitrary green-green rope, and we tie their ends together. Once we do that, we decreased A by 1 but increased B to 1, so in the next step we can again apply the previous paragraph once.\n\nBy linearity of expectation, the expected total number of rings is the sum of expected numbers of rings created in each step of the above process. Thus, whenever we process a red-green string, we increment the answer by 1 / (2A+B).\n\n```\npublic double expectedRings(int A, int B) {\ndouble answerB = 0;\nfor (int b=B; b0; --b) answerB += 1. / (2*A+b);\ndouble answerA = 0;\nfor (int a=A; a0; --a) answerA += 1. / (2*a-1);\nreturn answerA + answerB;\n}\n```\n\n## FinishingDice\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15918)\nThe distribution of all possible rolls on a die with numbers A[0], …, A[n-1] can be represented using its generating function: sum_i x^A[i]. In particular, for a standard die this generating function is S_n(x) = (x+x^2+...+x^(n-1)+x^n).\n\nThe distribution of possible rolls for two dice corresponds to the product of their generating functions. For example, if we have two standard 4-sided dice, the product of their generating functions is (x+x^2+x^3+x^4)^2 = (1x^2 + 2x^3 + 3x^4 + 4x^5 + 3x^6 + 2x^7 + x^8). The term s*x^t tells us that there are s ways to roll the sum t.\n\nSometimes it is possible to find pairs of dice other than the two regular ones with the property that they produce the same probability distribution on results. Instead of directly looking for the values on the sides of those dice, we can look for their generating functions instead. More precisely, we want two polynomials P, Q such that:\n\n- Their product is (S_n(x))^2.\n- The constant term of each polynomial is 0 (no empty faces allowed).\n- All coefficients are nonnegative (we cannot have -3 faces with 7 pips each).\n- The sum of coefficients of each polynomial is n (we want two n-sided dice).\n\nThe key observation is that the number of such pairs (P,Q) has to be quite small. This is because each P and each Q must be a factor of (S_n(x))^2 in polynomials over Z.\n\nThus, a viable approach looks as follows: We know that both P and Q have a factor x each. Factor S(x)/x into irreducible polynomials. (See [https://en.wikipedia.org/wiki/Cyclotomic_polynomial](https://en.wikipedia.org/wiki/Cyclotomic_polynomial) for explanation of this step.) This gives you the factorization of (S(x)/x)^2. Try all possibilities for how to split the factors between P and Q. For each of those, check whether P and Q satisfy the requirements above, and if they do, check whether the corresponding dice can be produced from the partial dice that were given in the input.\n\nFor the given constraints the factorization of S(x)/x always has at most 11 terms, which gives us at most 3^11 = 177,147 possibilities for the pair (P,Q). (Only a few of those actually produce valid pairs of dice, so if it turns out that your program cannot try 3^11 possibilities fast enough, you can precompute and store the indices of those possibilities that actually produce valid pairs of dice.)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-776-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2KVo8yAeoF0jDmlYbX0mx7","type":"Entry","createdAt":"2020-04-20T12:43:25.805Z","updatedAt":"2026-01-31T23:12:01.968Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 777","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","Java"],"creationDate":"2020-02-05T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 777 Editorials\n\n## LimpingDog\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15920)\nWe can simulate the process since time is small enough\n\n```\nclass LimpingDog():\ndef countSteps(self, time):\nres = 0\nwhile time 0:\ntime -= 1\nif res%4==2:\ntime -=1\nif time =0:\nres +=1\nif res%47==0:\ntime -=42\nreturn res\n```\n\n## StringTransformationEasy\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15922)\nDivide the string into blocks of equal letters. You can never erase a block completely, but you can always erase it down to the last one or two characters (based on parity) by using one character from an adjacent block and three from your block.\n\nSpecial case: if all letters are the same, you cannot erase anything.\n\n```\ndef rle(S):\nanswer = [1]\nfor n in range(1,len(S)):\nif S[n] == S[n-1]:\nanswer[-1] += 1\nelse:\nanswer.append(1)\nreturn answer\n\nclass StringTransformationEasy:\ndef getResult(self, S, T):\nif len(T) len(S): return \"NO\"\nif T[0] != S[0]: return \"NO\"\nRS, RT = rle(S), rle(T)\nif len(RS) != len(RT): return \"NO\"\nif len(RS) == 1:\nreturn \"YES\" if RS==RT else \"NO\"\nfor s,t in zip(RS,RT):\nif t s: return \"NO\"\nif t%2 != s%2: return \"NO\"\nreturn \"YES\"\n```\n\n## BlackAndWhiteBallsEasy\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15921)\nFirst, we can expand the sequence to sum(balls) length. Now, we can do a dp solution. dp[i] is the number ways to split the first i balls. We can iterate through j, count the number of white balls or black balls between balls i+1 and j, and add dp[i] to dp[j] if it satisfies the conditions.\n\n```\n#include <bits/stdc++.h\n\nusing namespace std;\n\nconst int MOD = 1000000007;\n\nstruct BlackAndWhiteBallsEasy {\nint getNumber(vector<int _balls, int W, int B) {\nvector<int balls;\nfor (int n=0; n<int(_balls.size()); ++n) for (int i=0; i<_balls[n]; ++i) balls.push_back(n%2);\nint N = balls.size();\n\nvector<int psum(1,0);\nfor (int b : balls) psum.push_back( psum.back()+b );\n\nvector<int dp(N+1);\ndp[0] = 1;\nfor (int n=1; n<=N; ++n) {\nfor (int last=1; last<=n; ++last) {\nint countb = psum[n] - psum[n-last];\nint countw = last - countb;\nif (countw == W) dp[n] = (dp[n] + dp[n-last]) % MOD;\nif (countb == B) dp[n] = (dp[n] + dp[n-last]) % MOD;\n}\n}\nreturn dp[N];\n}\n};\n```\n\n## PreviousOccurence\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15923)\nThis problem can be solved by simulation. When defaultValue = 1, the sequence is just 0, 1, 1, 1, …, so the answer doesn’t exist unless query is 0 or 1. Otherwise, a simulation works. Since there’s only a limited number of defaultValues, you can try them all and see that they will contain all query values if you go up to 10^7 or so. We can efficiently simulate the process by keeping a map from seen integers to their last occurence, allowing us to generate each element in constant time.\n\n```\nimport java.util.*;\nimport java.util.regex.*;\nimport java.text.*;\nimport java.math.*;\n\npublic class PreviousOccurrence\n{\npublic int findValue(int defaultValue, int query)\n{\nHashMap<Integer, Integer last = new HashMap<Integer, Integer();\nif (query == 0) {\nreturn 0;\n}\nint prev = 0;\nfor (int i = 1; i < 10000000; i++) {\nint value = 0;\nif (last.containsKey(prev)) {\nvalue = i - 1 - last.get(prev);\n} else {\nvalue = defaultValue;\n}\nif (value == query) {\nreturn i;\n}\nlast.put(prev, i - 1);\nprev = value;\n}\nreturn -1;\n}\n\n}\n```\n\n## StringTransformation\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15775)\nLet's get the run length encoding of both sequences, and call each of these parts a block. A block has a color and number. If there is only one block in T, then T and S must be the same.\n\nIt helps to look at things backwards as adding characters from T to S. Each block in T must correspond to a compatible block in S, where a block in T is \"compatible\" with a block in S if it has the same color, it has the same parity, and the number is equal or less.\n\nIf we look at the matched blocks of S, we must somehow generate everything else, and this is several independent problems between matched blocks. We can figure out when we can generate everything in between two already matched blocks in S. We can solve this with a little case work, and find out this is possible if the two blocks are already adjacent (nothing to generate), or all blocks in between have even size and the colors, including endpoints, don't alternate between only two colors (this can be proven with induction).\n\nThis leads to a dp solution, dp[i][j] - true iff we can match first i blocks in T with first j blocks in S. For a fixed i, we sweep from lower j to higher j and keep track of some information to figure out if all previous blocks between the last possible matched position are even size and don't alternate.\n\n```\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class StringTransformation {\nString x = \"RGB\";\nstatic class Block {\nint c;\nint n;\n\npublic Block(int c, int n) {\nthis.c = c;\nthis.n = n;\n}\npublic boolean inside(Block other) {\nreturn other.c == this.c && other.n = this.n && (other.n % 2) == (this.n % 2);\n}\n}\npublic List<Block chunk(String s) {\nList<Block ret = new ArrayList<();\nchar last = s.charAt(0);\nint count = 0;\nfor (char c : s.toCharArray()) {\nif (c == last) count++;\nelse {\nret.add(new Block(x.indexOf(last), count));\nlast = c;\ncount = 1;\n}\n}\nret.add(new Block(x.indexOf(last), count));\nreturn ret;\n}\n\npublic String getResult(String s, String t) {\nreturn _getResult(s, t) ? \"YES\" : \"NO\";\n}\npublic boolean _getResult(String s, String t) {\nList<Block a1 = chunk(s), a2 = chunk(t);\nif (a2.size() == 1) {\nreturn a1.size() == 1 && a1.get(0).c == a2.get(0).c && a1.get(0).n == a2.get(0).n;\n}\nboolean[] dp = new boolean[a1.size()];\ndp[0] = a2.get(0).inside(a1.get(0));\nfor (int i = 1; i < a2.size(); i++) {\nBlock b2 = a2.get(i);\nboolean[] ndp = new boolean[a1.size()];\nint msk = 0;\nboolean first = false;\nfor (int j = 0; j < a1.size(); j++) {\nBlock b1 = a1.get(j);\nint c = b1.c;\n\nif (b2.inside(b1)) {\nif (j 0 && dp[j-1]) ndp[j] = true;\nif (first) msk |= 1 << c;\nndp[j] |= msk == 7;\n}\n\nif (b1.n % 2 == 1) {\nfirst = false;\nmsk = 0;\n}\n\nfirst |= dp[j];\nif (first) msk |= 1 << c;\n}\ndp = ndp;\n}\nreturn dp[a1.size()-1];\n}\n}\n```\n\n## BlackAndWhiteBalls\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15774)\nLet’s say we have two types of segments - type 0 (where number of zeros is X), and type 1 (where the number of ones is Y). Let’s do a bit of a different DP, dp[b][t], which means we’ve covered the first b blocks of balls with segments, and the type of the last segment that the b-th block has included is t. Note that the b-th block might not be completely covered yet. The DP transition will iterate over k, and cover the next k blocks with segments of type t^1. Basically, we are doing DP, but in one turn covering a contiguous range of segments of the same type.\n\nWe’ll also assume that if the color of the b-th block is t, then it was decided before how many balls of that block ended up in previous segments, and how many are left for the next one. It’s OK for us to assume this since we’re placing segments of type t^1 and balls of type t are irrelevant.\n\nIf the color of the b-th block is not equal to t, then we assume it was NOT yet decided how many balls of that segment ended up in previous segments, and we’ll decide it now during the current dp transition.\n\nBased on that, we can work out the dp transitions. A hard case is when while placing a range of segments of type t^1 and the b-th block and (b+k)-th block are color t^1, we need to decide how many of the balls of those two ‘separator’ blocks end up in segments of type t, and this can affect how we split blocks of color t in the interior. This is doable since there are at most n interesting modulos to consider, and the formulas can get a bit messy.\n\n```\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.*;\n\npublic class BlackAndWhiteBalls {\nclass PairII {\npublic int first;\npublic int second;\n\npublic PairII(int first, int second) {\nthis.first = first;\nthis.second = second;\n}\n}\n\nclass Ranges {\npublic long first;\npublic ArrayList<PairII second;\n\npublic Ranges(long first, ArrayList<PairII second) {\nthis.first = first;\nthis.second = second;\n}\n}\n\nclass PairPI implements Comparable<PairPI {\npublic PairII first;\npublic int second;\n\npublic PairPI(PairII first, int second) {\nthis.first = first;\nthis.second = second;\n}\n\npublic int compareTo(PairPI c) {\nif (first.first < c.first.first) return -1;\nif (first.first c.first.first) return 1;\nif (first.second < c.first.second) return -1;\nif (first.second c.first.second) return 1;\nif (second < c.second) return -1;\nif (second c.second) return 1;\nreturn 0;\n}\n}\n\nclass PairIP implements Comparable<PairIP {\npublic int first;\npublic PairII second;\n\npublic PairIP(int first, PairII second) {\nthis.first = first;\nthis.second = second;\n}\n\npublic int compareTo(PairIP c) {\nif (first < c.first) return -1;\nif (first c.first) return 1;\nif (second.first < c.second.first) return -1;\nif (second.first c.second.first) return 1;\nif (second.second < c.second.second) return -1;\nif (second.second c.second.second) return 1;\nreturn 0;\n}\n}\n\nfinal int MOD = 1000000007;\nfinal int INF = 1000000000;\nfinal int MAX = 256;\nint A[];\nint C[];\nlong R[][];\nlong W[][];\nint c[];\nint n;\nint it;\n\nlong get(long x, int t) {\nif (x <= 0) return 0;\nreturn x / c[t];\n}\n\nlong get(long l, long r, int t) {\nif (l r) return 0;\nreturn get(r, t) - get(l-1, t);\n}\n\nlong getCoefLeft(int l, int r, int t) {\nlong res = 1, sum = 0;\nfor (int i = l; i <= r; ++i) {\nif (C[i] == t) {\nsum += A[i];\n} else {\nif ((sum % c[t] == 0) && sum 0) {\nres = res * (A[i]+1) % MOD;\n}\n}\n}\n\nreturn res;\n}\n\nlong getCoefRight(int l, int r, int t) {\nlong res = 1, sum = 0;\nfor (int i = r; i = l; --i) {\nif (C[i] == t) {\nsum += A[i];\n} else {\nif ((sum % c[t] == 0) && sum 0) {\nres = res * (A[i]+1) % MOD;\n}\n}\n}\n\nreturn res;\n}\n\nRanges getRanges(long l, long r, long m) {\nlong ta = 0;\nArrayList<PairII Q = new ArrayList<PairII();\nfor (long i = l; i <= r; ) {\nif (i % m == 0) {\nlong c = (r-i) / m;\ni += c*m;\nta += c;\n}\n\nlong t = (i/m+1)*m;\nlong p = Math.min(r, t-1);\nQ.add(new PairII((int)(i % m), (int)(p % m)));\ni = p + 1;\n}\n\nreturn new Ranges(ta, Q);\n}\nlong countTot(int l, int r, int t, long s) {\nRanges resA = getRanges(1, A[l]-1, c[t]);\nint tl = (int)((-(A[r] % c[t]) + c[t] - s%c[t] + c[t]) % c[t]);\nRanges resB = getRanges(tl, (long)tl+A[r]-1, c[t]);\nlong ta = resA.first;\nlong tb = resB.first;\n\nArrayList<PairIP Q = new ArrayList<PairIP();\n\nfor (int i = 0; i < resA.second.size(); ++i) {\nQ.add(new PairIP(resA.second.get(i).first, new PairII(0, 0)));\nQ.add(new PairIP(resA.second.get(i).second+1, new PairII(0, 1)));\n}\n\nfor (int i = 0; i < resB.second.size(); ++i) {\nQ.add(new PairIP(resB.second.get(i).first, new PairII(1, 0)));\nQ.add(new PairIP(resB.second.get(i).second+1, new PairII(1, 1)));\n}\n\nQ.add(new PairIP(0, new PairII(2, 2)));\nQ.add(new PairIP(c[t], new PairII(2, 2)));\n\nCollections.sort(Q);\n\nlong curA = 0, curB = 0;\nlong res = 0;\n\nfor (int i = 0; i < Q.size()-1; ++i) {\n++ it;\nif (Q.get(i).second.first == 0) {\nif (Q.get(i).second.second == 0) ++ curA; else -- curA;\n} else if (Q.get(i).second.first == 1) {\nif (Q.get(i).second.second == 0) ++ curB; else -- curB;\n}\n\nif (Q.get(i).first != Q.get(i+1).first) {\nint cnt = (Q.get(i+1).first - Q.get(i).first) % MOD;\nres += (curA + ta) * (curB + tb) % MOD * cnt % MOD;\nres %= MOD;\n}\n}\n\nreturn res;\n}\n\nlong getCoefBoth(int l, int r, int t) {\nif (l == r) {\nlong k = A[l]/c[t];\nlong res = A[l] * k % MOD;\nlong d = k*(k+1)/2 % MOD;\nd = d * c[t] % MOD;\nres = (res - d + MOD) % MOD;\n\nreturn res;\n} else {\nlong s = 0;\nfor (int k = l+1; k < r; ++k)\nif (C[k] == t) s += A[k];\n\nlong cur = 0;\nArrayList<PairPI Q = new ArrayList<PairPI();\nfor (int k = l+1; k < r; ++k) {\n++ it;\nif (C[k] == t) cur += A[k];\nelse\n{\nint a = (int)((c[t] - (cur % c[t]) + c[t]) % c[t]);\nint b = (int)((c[t] - ((s - cur) % c[t]) + c[t]) % c[t]);\nQ.add(new PairPI(new PairII(a, b), A[k]+1));\n}\n}\n\nlong tot = countTot(l, r, t, s);\n\nCollections.sort(Q);\n\nint pos = 0;\nlong res = 0;\nwhile (pos < Q.size()) {\nint add = 0;\nlong d = 1;\nwhile (pos+add < Q.size() && Q.get(pos+add).first.first == Q.get(pos).first.first && Q.get(pos+add).first.second == Q.get(pos).first.second) {\nd = d * Q.get(pos+add).second % MOD;\n++ add;\n}\n\nlong cl = (A[l] - 1 - Q.get(pos).first.first) / c[t];\nif (Q.get(pos).first.first 0 && A[l] - 1 = Q.get(pos).first.first) ++ cl;\n\nlong cr = (A[r] - Q.get(pos).first.second) / c[t];\nif (Q.get(pos).first.second 0 && A[r] = Q.get(pos).first.second) ++ cr;\n\ntot = (tot - cl * cr % MOD + MOD) % MOD;\n\nres += cl * cr % MOD * d % MOD;\nres %= MOD;\n\npos += add;\n}\n\nres = (res + tot) % MOD;\n\nreturn res;\n}\n}\npublic int getNumber(int[] balls, int white, int black) {\nn = balls.length;\nA = new int[n];\nC = new int[n];\nfor (int i = 0; i < n; ++i) {\nA[i] = balls[i];\nC[i] = i % 2;\n}\n\nc = new int[2];\nc[0] = white;\nc[1] = black;\n\nR = new long[MAX][2];\nW = new long[MAX][2];\n\nfor (int i = n-1; i = 0; --i) {\nfor (int j = 0; j < 2; ++j) {\nlong s[] = new long[2];\nfor (int k = i; k < n; ++k) {\ns[C[k]] += A[k];\n\nif (C[k] == j) {\nW[i][j] += getCoefBoth(i, k, j) * R[k+1][j^1] % MOD;\nW[i][j] %= MOD;\n\nif (k == n-1) {\nW[i][j] += get(s[j]-A[i]+1, s[j]-1, j) * getCoefRight(i, k, j) % MOD;\nW[i][j] %= MOD;\n}\n}\nelse {\nW[i][j] += get(s[j]-A[i]+1, s[j]-1, j) * getCoefRight(i, k-1, j) % MOD * W[k][j^1] % MOD;\nW[i][j] %= MOD;\n\nif (k == n-1) {\nW[i][j] += get(s[j]-A[i]+1, s[j]-1, j) * getCoefRight(i, k-1, j) % MOD;\nW[i][j] %= MOD;\n} else {\nW[i][j] += get(s[j]-A[i]+1, s[j]-1, j) * getCoefRight(i, k-1, j) % MOD * R[k+1][j^1] % MOD;\nW[i][j] %= MOD;\n}\n}\n}\n}\n\nfor (int j = 0; j < 2; ++j) {\nlong s[] = new long[2];\nfor (int k = i; k < n; ++k) {\ns[C[k]] += A[k];\n\nif (C[k] == j) {\nR[i][j] += get(s[j]-A[k]+1, s[j], j) * getCoefLeft(i, k, j) % MOD * R[k+1][j^1] % MOD;\nR[i][j] %= MOD;\n\nif (k == n-1 && s[j] % c[j] == 0) {\nR[i][j] += getCoefLeft(i, k, j);\nR[i][j] %= MOD;\n}\n} else {\nif (s[j] % c[j] == 0 && s[j] 0) {\nR[i][j] += getCoefLeft(i, k-1, j) * W[k][j^1] % MOD;\nR[i][j] %= MOD;\n\nif (k == n-1) {\nR[i][j] += getCoefLeft(i, k-1, j);\nR[i][j] %= MOD;\n} else {\nR[i][j] += getCoefLeft(i, k-1, j) * R[k+1][j^1] % MOD;\nR[i][j] %= MOD;\n}\n}\n}\n}\n}\n}\n\nint res = (int)((R[0][0] + R[0][1]) % MOD);\nreturn res;\n}\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1zHxqubLKz2yYjNp00hFBu","type":"Entry","createdAt":"2019-09-18T07:37:46.512Z","updatedAt":"2019-10-15T16:13:07.041Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Lewin Gan","tcHandle":"lg5293"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-777-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"37MbdbSHhVoOc91RZK2B1C","type":"Entry","createdAt":"2020-04-20T12:43:24.330Z","updatedAt":"2026-01-31T23:03:20.745Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":73,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 778","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java","Python"],"creationDate":"2020-02-16T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 778 Editorials\n\n## OppositeParity\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15945)\n__Used as: Division Two - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 250       |\n| __Submission Rate__    | 157 / 186 (84.41%)   |\n| __Success Rate__       | 143 / 157 (91.08%)  |\n| __High Score__         | hp_Vardhan for 249.36 points (1 mins 26 secs)   |\n| __Average Score__      | 209.72 (for 143 correct submissions)|\n\nRead the input and keep two lists, one for even values and one for odd values. Take a for loop again on input. When you see an odd value, if the list of even values is empty, return an empty array. Otherwise, pick an element from the even list and pop it.\n\nThe overall complexity is O(n).\n\nHere is the solution in Python:\n\n```\nclass OppositeParity:\ndef __init__(self): pass\ndef rearrange(self, B):\nA = list(B)\nn, odd, even = len(A), filter(lambda x : x % 2 == 1, A), filter(lambda x : x % 2 == 0, A)\nif len(odd) != len(even): return ()\np, q = 0, 0\nfor i in range(n):\nif A[i] % 2 == 0: A[i], p = odd[p], p + 1\nelse: A[i], q = even[q], q + 1\nreturn tuple(A)\n```\n\nAnd here is the C++ code:\n\n```\nstruct OppositeParity{\nvector<int rearrange(vector<int a){\nvector<int v[2];\nfor(auto x : a)\nv[x % 2].push_back(x);\nvector<int ret;\nfor(auto x : a)\nif(v[!(x % 2)].empty())\nreturn {};\nelse\nret.push_back(v[!(x % 2)].back()), v[!(x % 2)].pop_back();\nreturn ret;\n}\n};\n```\n\n## AlienOccupation\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15946)\n__Used as: Division Two - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 500      |\n| __Submission Rate__    | 120 / 186 (64.52%) |\n| __Success Rate__       | 61 / 120 (50.83%)  |\n| __High Score__         | AmAtUrECoDeR for 452.89 points (9 mins 21 secs)   |\n| __Average Score__      | 310.85 (for 61 correct submissions)|\n\nHint: Use BFS.\n\nLet q be an empty queue. Add A to q at first. Now pick elements from q one by one like BFS. Keep a value for each planet, it’s level. Let the picked element be v. For each i (1 <= i <= K), check if u = (X[i] * v + Y[i]) modulo N has seen before or not. If not, set level[u] = level[v] + 1. At last, T is the number of seen planets. U is the maximum level. V is the level with the maximum number of vertices that are at this level.\n\nThe overall complexity is O(NK).\n\nHere is the solution in C++:\n\n```\nstruct AlienOccupation{\nconst int inf = 1e9;\nvector<int getInfo(int n, int a, vector<int x, vector<int y){\nqueue<int q({a});\nvector<int d(n, inf), w(n);\nd[a] = 0;\nint cnt = 0, mxh = 0, mxoih = 0;\nwhile(!q.empty()){\nint v = q.front();\nq.pop();\ncnt++;\nmxh = max(mxh, d[v]);\nif(v != a)\nmxoih = max(mxoih, ++w[d[v]]);\nfor(int i = 0; i < x.size(); i++){\nint nx = (x[i] * ll(v) + y[i]) % n;\nif(d[nx] == inf){\nd[nx] = d[v] + 1;\nq.push(nx);\n}\n}\n}\nreturn {cnt, mxh, mxoih};\n}\n};\n```\n\n## KRectangleIntersection\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15899)\n__Used as: Division Two - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 1000      |\n| __Submission Rate__    | 17 / 186 (9.14%) |\n| __Success Rate__       | 1 / 17 (5.88%)  |\n| __High Score__         | allllekssssa for 618.86 points (25 mins 56 secs)  |\n| __Average Score__      | 618.86 (for 1 correct submission)|\n\n__Used as: Division One - Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 250      |\n| __Submission Rate__    | 119 / 172 (69.19%) |\n| __Success Rate__       | 52 / 119 (43.70%)  |\n| __High Score__         | cerberus97 for 237.04 points (6 mins 42 secs)  |\n| __Average Score__      | 163.33 (for 52 correct submissions)|\n\nHint: Solve the problem in 1D.\n\nConsider the problem in 1D: There are several segments, what is the largest segment that is a subsegment of at least k segments?\n\nSort segments by their start point. Sweep them from left to right. At each point like x, we have several alive (not removed) segments. If they are more than k, sort them by their endings from end to beginning (so if there are two alive segments, one ending in 3 and one in 5, the sorted list will be {5, 3}). Let this list be e[0], e[1], … . The intersection of these alive segments is [x, e[k - 1] ]. It’s enough to manage to keep the list sorted. It’s possible using set in C++, for example.\n\nNow let’s solve the original problem. For each pair of (i, j) 1 <= xl[i] <= xl[j] <= n, consider the rectangles like k such that xl[k] <= xl[i] && xl[j] <= xr[k], the problem is now converted to 1D.\n\nThe overall complexity is O(n ^ 3 * log).\n\nHere is the solution in C++:\n\n```\nstruct KRectangleIntersection{\nll maxIntersection(vector<int xl, vector<int yl, vector<int xr, vector<int yr, int k){\nint n = xl.size();\nll ans = 0;\nfor(auto sx : xl)\nfor(auto ex : xr){\nif(ex <= sx)\ncontinue;\nvector<pair<int, int ava;\nfor(int i = 0; i < n; i++)\nif(xl[i] <= sx && ex <= xr[i])\nava.push_back({yl[i], yr[i]});\nsort(ava.begin(), ava.end());\nmultiset<int ends;\nauto it = ends.begin();\nfor(auto X : ava){\nint x = X.first, y = X.second;\nwhile(ends.size() && *ends.begin() < x)\nends.erase(ends.begin());\nends.insert(y);\nif(ends.size() = k){\nif(ends.size() == k)\nit = ends.begin();\nelse if(y = *it)\nit++;\nans = max(ans, ll(ex - sx) * (*it - x));\n}\n}\n}\nreturn ans;\n}\n};\n```\n\nHere is the solution is Java:\n\n```\n// O(N^3)\npublic long maxIntersection(int [] xl, int [] yl, int [] xh, int [] yh, int K){\nint n = xl.length;\nlong ret = 0;\n\nint [] compressedYH = new int[n];\nint [] revL = new int[n];\nint [] revH = new int[n];\nTreeSet<Integer st = new TreeSet();\nTreeMap<Integer, Integer compress = new TreeMap();\nfor(int i = 0; i < n; i++){\nst.add(yh[i]);\n}\n\nint cnt = 0;\nint [] ulta = new int[n];\nfor(int x : st){\ncompress.put(x, cnt);\nulta[cnt] = x;\ncnt++;\n}\n\nfor(int i = 0; i < n; i++){\ncompressedYH[i] = compress.get(yh[i]);\n}\n\nint [] order = new int[n];\n\nArrayList<Long al = new ArrayList<();\nfor(int i = 0; i < n; i++) al.add( (((long)yl[i])<<30) + i);\nCollections.sort(al);\n\nfor(int i = 0; i < n; i++){\norder[i] = (int)(al.get(i) & ((1 << 30) - 1));\n}\n\nfor(int i = 0; i < n; i++){\nfor(int j = 0; j < n; j++){\nif(xl[i] < xh[j]){\nint [] num = new int[cnt];\nint curr = 0, val = 0;\nint diff = xh[j] - xl[i];\nfor(int r = 0; r < n; r++){\nint k = order[r];\nif(xl[k] <= xl[i] && xh[k] = xh[j]){\nint pos = compressedYH[k];\nnum[pos]++;\nif(pos = curr) val++;\nwhile(curr < cnt && val - num[curr] = K){\nval -= num[curr];\ncurr++;\n}\nif(val = K){\nret = Long.max(ret, diff * 1L * (ulta[curr] - yl[k]));\n}\n}\n}\n}\n}\n}\nreturn ret;\n}\n// O(N^3 logN)\npublic long maxIntersectionSlower(int [] xl, int [] yl, int [] xh, int [] yh, int K){\nint n = xl.length;\nlong ret = 0;\nfor(int i = 0; i < n; i++){\nfor(int j = 0; j < n; j++){\nif(xl[i] < xh[j]){\nint diff = xh[j] - xl[i];\nArrayList<Long al = new ArrayList<();\nfor(int k = 0; k < n; k++) if(xl[k] <= xl[i] && xh[k] = xh[j]){\nlong L = yl[k];\nint R = yh[k];\nal.add((L << 30) + R);\n}\nCollections.sort(al);\n\nTreeSet<Long curr = new TreeSet<();\nfor(int r = 0; r < al.size(); r++){\nlong val = al.get(r);\nlong L = (val 30);\nlong R = (val & ((1 << 30) - 1));\ncurr.add((R << 30) + r);\nif(curr.size() K) curr.remove(curr.first());\nif(r + 1 = K){\nret = Long.max(ret, Long.max(0L, ((curr.first() 30) - L)) * diff);\n}\n}\n}\n}\n}\nreturn ret;\n}\n```\n\n## CollectingCoins\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15944)\n__Used as: Division One - Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 600      |\n| __Submission Rate__    | 67 / 172 (38.95%) |\n| __Success Rate__       | 17 / 67 (25.37%) |\n| __High Score__         | null for null points (NONE)  |\n| __Average Score__      | 323.48 (for 17 correct submissions)|\n\nHint: Try to convert the problem to knapsack problem. Consider we have dp[i, i + 2 * k]. Try to find dp values for every integer in [2 * i, 2 * i + 2 * k].\n\nAfter each power-down (among any k consecutive days there must be at least one day when the machine is powered down and does not produce any coins at all) everything is reset. So we can consider that we start everything from the beginning. \n\nLet several consecutive working days with a power-down day, a block. So for example, in the first sample case, the maximum income of a block with length 2 is 1 (a working day + a power-down day). The income of a block with length 3 is 2. We can’t have a block with a size more than k.\n\nWhat’s inside a block? For each type of coin, we stuck as much as possible of it into the block. Consider a block with size L and coin type i, we can gain v[i] * ((wd - 1) - (wd - 1) / d[i]) in this block with stocking (wd - 1) - (wd - 1) / d[i] coins of type i.\n\nIncrease m by 1. Now we need to put several blocks together and maximize the income. For sure, you’re thinking about knapsack. Yes! it’s a special type of knapsack problem. Let dp[i] be the answer for i days (last day is power-off). The point is, because of the small size of blocks, it’s enough that we have an interval around i / 2 with size k - 1. In other words, consider we know dp values for every integer in [i, i + 2 * k]. We can simply find dp values for every integer in [2 * i, 2 * i + 2 * k].\n\nBy doing this, we achieve complexity O(log m * k^2).\n\nHere is a slow solution that uses the key idea:\n\n```\nstruct CollectingCoins{\nmap<int, ll cache;\nvector<ll income;\nll f(int m, int k){\nif(m < income.size())\nreturn income[m];\nif(cache.count(m))\nreturn cache[m];\nll &ret = cache[m];\nfor(int i = min(m - k + 1, m / 2); i < min(m - k + 1, m / 2) + k - 1; i++)\nret = max(ret, f(i, k) + f(m - i, k));\nreturn ret;\n}\nll maxValue(int m, int k, vector<int v, vector<int d){\ncache.clear();\nincome = {0, 0};\nm++;\nll all = 0;\nfor(int wd = 1; wd < k; wd++){\nll ans = 0;\nfor(int i = 0; i < v.size(); i++)\nans += v[i] * (wd - wd / d[i]);\nincome.push_back(ans);\n}\nfor(int i = 0; i < k; i++)\nfor(int j = 1; j < i; j++)\nincome[i] = max(income[i], income[j] + income[i - j]);\nreturn f(m, k);\n}\n};\n```\n\nHere is the full solution:\n```\nprivate void lift(long [] f, int k){\nlong [] ret = new long[2 * k + 1];\nArrays.fill(ret, Long.MIN_VALUE / 10);\nfor(int i = 0; i <= 2 * k; i++)\nfor(int j = 0; j <= 2 * k; j++){\nif(f[i] < 0 || f[j] < 0) continue;\n//2 * n - k + i + j - k\nif(i + j = k && i + j <= 3 * k){\nret[i + j - k] = Long.max(ret[i + j - k], f[i] + f[j]);\n}\n}\nfor(int i = 0; i <= 2*k; i++) f[i] = ret[i];\n}\n\nprivate void shift(long [] f, long[] g, int k){\nlong val = Long.MIN_VALUE;\nfor(int i = 0; i < k; i++) val = Long.max(val, f[2 * k - i] + g[i + 1]);\nfor(int i = 0; i < 2 * k; i++) f[i] = f[i + 1]; f[2 * k] = val;\n}\n\npublic long maxValue(int m, int k, int[] v, int[] d){\nm++;\nint n = v.length;\nlong [] g = new long[k + 1];\nlong [] f = new long[2 * k + 1];\n\nArrays.fill(f, Long.MIN_VALUE / 10);\nfor(int i = 1; i <= k; i++){\nfor(int j = 0; j < n; j++) g[i] += v[j] * (i - 1 - (i - 1) / d[j]);\n}\nfor(int i = k; i <= 2 * k; i++){\nf[i] = g[i - k];\n}\nfor(int i = 30; i = 0; i--){\nlift(f, k);\nif((m i) % 2 == 1){\nshift(f, g, k);\n}\n}\nreturn f[k];\n}\n\n```\n\n## DominoPlacement\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15896)\n__Used as: Division One - Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__              | 900      |\n| __Submission Rate__    | 19 / 172 (11.05%) |\n| __Success Rate__       | 16 / 19 (84.21%)|\n| __High Score__         | Petr for 726.25 points (14 mins 38 secs) |\n| __Average Score__      | 577.47 (for 16 correct submissions)|\n\nHint: Use dp on bitmasks. Try to solve column by column.\n\nLet’s fix the number of rows is less than the number of columns. So the number of rows is at most 17, The dp state is: consider the matrix from i-th column to the last column.\n\nLet mask be the set of cells in i-th column which are filled by horizontal dominos (1*1 is assumed to be horizontal domino).\n\nFind the number of ways to cover the remaining cells by vertical dominos.\n\nLet nmask be the set of cells covered by horizontal dominos in (i+1)-th column.\n\nThen you should multiply by 2 ^ numberOfSetBits(mask & nmask). Because there are two options for each covered cell, to be continue of the previous covered cell (in i-th column) or to be a new horizontal domino.\n\nThe transform function (in the solution) does this efficiently, in O(n * 2^n) instead of O(3^n) or O(4^n).\n\nThe overall complexity is O(m * n * 2 ^ n).\n\nHere is the solution:\n```\npublic DominoPlacement(){\nf = new int[305];\nf[0] = 1;\nfor(int n = 1; n <= 300; n++) for(int i = 2; i <= n; i++) f[n] = add(f[n], f[n - i]);\n}\nstatic final int MOD = 1000*1000*1000 + 7;\nint add(int x, int y){x += y; if(x = MOD) x -= MOD; return x;}\nint mul(int x, int y){return (int) (x * 1L * y % MOD);}\nint [] f;\nvoid transform(int [] arr, int k){\nif(k == 0) return;\nint halfn = 1 << (k - 1);\nint [] lft = new int[halfn];\nint [] rgt = new int[halfn];\nfor(int i = 0; i < halfn; i++){\nlft[i] = arr[i];\nrgt[i] = arr[halfn + i];\n}\ntransform(lft, k - 1);\ntransform(rgt, k - 1);\nfor(int i = 0; i < halfn; i++){\narr[i] = add(lft[i], rgt[i]);\narr[i + halfn] = add(arr[i], rgt[i]);\n}\n}\nint get(int mask, int n){\nint ret = 1, lst = -1;\nfor(int i = 0; i < n; i++){\nif((mask i & 1) 0){\nret = mul(ret, f[i - lst - 1]);\nlst = i;\n}\n}\nret = mul(ret, f[n - 1 - lst]);\nreturn ret;\n}\npublic int countWays(String [] T){\nint n = T.length;\nint m = T[0].length();\nint [] masks = new int[Integer.max(n, m)];\nfor(int i = 0; i < n; i++){\nfor(int j = 0; j < m; j++){\nif(T[i].charAt(j) == '#'){\nif(n m) masks[i] |= 1 << j;\nelse masks[j] |= 1 << i;;\n}\n}\n}\nif(n m){\nn ^= m; m ^= n; n ^= m;\n}\nint [] curr = new int[1 << n];\ncurr[0] = 1;\n\nfor(int i = 0; i < m; i++){\ntransform(curr, n);\nfor(int mask = 0; mask < (1 << n); mask++){\nif((mask & masks[i]) != 0){\ncurr[mask] = 0;\n}\nelse curr[mask] = mul(curr[mask], get(mask ^ masks[i], n));\n}\n}\nlong ret = 0;\nfor(int x : curr) ret += x;\nreturn (int) (ret % MOD);\n}\n```\n\nYou can also check [https://www.overleaf.com/8336967563zvfyczpmmsrh](https://www.overleaf.com/8336967563zvfyczpmmsrh) for another editorial wrote by the setter.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/blog/single-round-match-778-editorials"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2zuqjPI2f8v5ZRkZRgvQaY","type":"Entry","createdAt":"2020-04-20T12:43:25.844Z","updatedAt":"2026-01-31T22:39:21.150Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 779","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python","C++"],"creationDate":"2020-02-24T00:00:00.000Z","readTime":"25 min","content":"# Single Round Match 779 Editorials\n\n## OperateString\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15956)\nConsider the characters written around a circle, in the clockwise order. Consider an arrow A, initially pointing to the first character. The first operation moves A forward for X times. The second operation moves A backward (counter-clockwise) -X times.\n\nSo, keep the position of A and at last, print the string starting from A and going in clockwise order.\n\n```\nclass OperateString:\ndef operate(self, s, moves):\nprint( len(s), len(moves), min(moves), max(moves), sum(moves) % len(s) )\nshift = sum(moves) % len(s)\nreturn s[shift:] + s[:shift]\n```\n\n## OneGcd\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15961)\nConsider Y is the power of two. It’s easy to calculate the numbers in the range [X, X + Y) which are coprime with Y. Consider Y is in the form of 2^a * 3^b. Now the number of the numbers in the range [1, Y] which are coprime with Y is Y - Y / 2 - Y / 3 + Y / 6 (Take floor when dividing, just like C++). So the problem seems easy now. Consider P as the set of primes dividing Y (|P| is at most 4), the answer for the range [1, Y] is: - \n\nAs the range given is [X, X + Y - 1], the answer is:-\n\nOverall time complexity is O(2^4 * N).\n\nBones: Y can be any number, not just divisible by primes less than 10. The solution to that would be using Phi(Y[i])\n\n```\ndef phi(Y):\nanswer = Y\nfor p in [2, 3, 5, 7]:\nif Y % p == 0:\nanswer = (answer * (p-1)) // p\nreturn answer\n\nclass OneGcd:\ndef solve(self, X, Y):\nreturn [ phi(y) for y in Y ]\n```\n\n## ArraySorting\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15960)\nIt’s easy to prove that the answer is at most N - 1. So, there is at least an element that doesn’t change. Let dp[i] be the number of changes needed in the range [0, i) to make [0, i] sorted while the i-th element itself will not change.\n\nWhile calculating dp[i], we need to find the last element like j in the range [0, i) such that j will not change.\n\nn3X77YQUVoCEOiZ8C0BEZMOa1E0iSAbXGLAiWPoT4qNLXzBdIhOQjhwjKlr47r0Ruf56cK9y1tpWC1x2pQB0H_k1MTFPl40BzId1DhU32f029oYIip0LV6vaAQf1d0Altg\nNow, the answer could be calculated easily by fixing the last element which will not change. If we consider this element to be i, the answer will be n - i - 1 + dp[i].\n\nThe overall complexity is O(n^2). It’s possible to solve the problem in O(n log n), find LIS and change the other elements.\n\n```\n#include <bits/stdc++.h\n\nusing namespace std;\nconst int MAX = 2048;\nint N;\nint A[MAX];\nint dp[MAX][MAX], dp2[MAX][MAX];\n\nstruct ArraySorting {\nvector<int arraySort(vector<int _A) {\nN = _A.size();\nint MAXVAL = *max_element( _A.begin(), _A.end() );\nfor (int n=0; n<N; ++n) A[n] = _A[n];\nfor (int current_index=N-1; current_index=0; --current_index) {\nfor (int current_value=MAXVAL; current_value=0; --current_value) {\nint this_edit = (A[current_index] == current_value ? 0 : 1);\nif (current_index == N-1) {\ndp[current_index][current_value] = dp2[current_index][current_value] = this_edit;\nif (current_value < MAXVAL) dp2[current_index][current_value] = min( dp2[current_index][current_value], dp2[current_index][current_value+1] );\n} else {\ndp[current_index][current_value] = dp2[current_index][current_value] = this_edit + dp2[current_index+1][current_value];\nif (current_value < MAXVAL) dp2[current_index][current_value] = min( dp2[current_index][current_value], dp2[current_index][current_value+1] );\n}\n}\n}\n\ncout << \"N = \" << N << \" approx edits \" << dp[0][0] << endl;\n\nvector<int B;\nint previous_value = 1;\nfor (int n=0; n<N; ++n) {\nint best_edits = N+47, best_value = -1;\nfor (int current_value=previous_value; current_value<=MAXVAL; ++current_value) {\nint current_edits = dp[n][current_value];\nif (current_edits < best_edits) { best_edits = current_edits; best_value = current_value; }\n}\nB.push_back( best_value );\nprevious_value = best_value;\n}\nreturn B;\n}\n};\n```\n\n## SubstringQueries\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15740)\nThe first fact is for every Q(L), 0 <= Q(L) < |S| is satisfied.\n\nLet str(i) = s[i], s[i + 1], …, s[n - 1], s[0], s[1], …, s[i - 1].\n\nSort str’s in the lexicographically order (it’s possible in O(|S| ^ 2 * log(|S|) easily, while using suffix array, O(|S| log(|S|) is achievable). \n\nFor now, consider k is infinitly large. Let’s answer Q(L) when 1 <= L <= |S|.\n\nConsider the first strings in the sorted order that their first L characters are equal. Find the minimum index between them, Q(L) is found now.\n\nConsider L = |S|. If several strings in the sorted order are equal, say str(i), str(j), for each L, starting from i going L characters forward makes an equal string with starting from j.\n\nSo, for L > |S|, answer is same as answer for L = |S|.\n\nNow, let’s involve k. For each L, Q(L) + L <= |S| * k must be satisfied. As we have Q(L) < |S|, for L <= k * (|S| - 1), there is no problem. After that, we should delete inappropriate indices from our list. For example, when L = k * (|S| - 1) + 1, Q(L) is not |S| - 1 for sure (because we can’t have string with such length starting at |S| - 1). So, delete |S| - 1 from the list. Go on and find the answer for the last |S| values of Q.\n\nUsing suffix array, O(|S| log |S|) is possible. But with the naive method, the overall complexity is now O(|S| ^ 2 log |S|).\n\n```\n#include<bits/stdc++.h\n\n#define pb push_back\nusing namespace std;\n\nclass SubstringQueries\n{\npublic:\nstatic const int maxN = 5002;\nstatic const long long mo1 = 1e9 + 7 ;\nstatic const long long mo2 = 1e9 + 9 ;\nstatic const long long b1 = 31;\nstatic const long long b2 = 71;\n\nint best[maxN];\nint bestL[maxN];\nint n;\nlong long hes1[maxN], hes2[maxN], d1[maxN], d2[maxN];\n\nint check(int x, int y, string &t)\n{\nfor (int i=0;i<n;i++)\nif (t[x+i]<t[y+i]) return x; else\nif (t[x+i] t[y+i]) return y;\n\nreturn x;\n}\n\nint check_lex(int f, int s, int len, string &t)\n{\nint l = 0;\nint r = len + 1;\n\nwhile(l<r-1)\n{\nint mid = l+r1;\n\nlong long val1f = (hes1[f+mid-1] - hes1[f-1])*d1[s-f]%mo1;\nif (val1f<0) val1f+=mo1;\nlong long val1s = (hes1[s+mid-1] - hes1[s-1])%mo1;\nif (val1s<0) val1s+=mo1;\nif (val1f == val1s) l = mid; else r = mid;\n}\n\nif (r == len+1) return 0;\nreturn t[s + r -1]<t[f + r - 1];\n}\n\nvoid solve_smaller(string &t)\n{\nint m = t.size();\n\nd1[0] = 1;\nd2[0] = 1;\n\nfor (int i =1;i<maxN;i++)\n{\nd1[i] = d1[i-1]*b1%mo1;\nd2[i] = d2[i-1]*b2%mo2;\n}\n\nfor (int i=1;i<m;i++)\n{\nhes1[i] = (hes1[i-1] + (t[i]-'a')*d1[i])%mo1;\nhes2[i] = (hes2[i-1] + (t[i]-'a')*d2[i])%mo2;\n}\n\nfor (int i=1;i<=n;i++){\n\nint cur = 1;\nfor (int j=2;j<=min(m-i, n + 1);j++)\nif (check_lex(cur,j, i, t)) cur = j;\n\nbestL[i] = cur;\n}\n}\n\nvector<long long solve(string s, long long k, vector<long long queries)\n{\nn = s.size();\n\nlong long len = k*n;\n\nstring t =\"\";\nif (k==1) t = \"#\" + s; else\nt = \"#\" + s + s;\n\nif (k1){\n\nbest[1] = 1;\n\nfor (int i = 2;i<=n;i++)\nbest[i] = check(best[i-1], i, t);\n}\n\nsolve_smaller(t);\n\nvector<long long res;\n\nfor (int i:queries)\n{\nif (i<=n){\nres.pb(bestL[i] - 1);\ncontinue;\n}\nlong long poz = min(len - i +1, 1ll*n);\nres.pb(best[poz] - 1);\n}\n\nreturn res;\n}\n\n};\n```\n\n## ParadePlanner\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15873)\nLet the path be v1, v2, v3, v4, v5, v6. Let’s fix the middle street, v3-v4. What we need now?\n\nFor v3, we need to count the number of possible pairs of (v1, v2), the other side, say (v5, v6) can be found similar.\n\nLet P(v) be number of paths of length 2 starting from v. P(v) = sum for each u in adjacent list v, number of adjacents of u - 1.\n\nNumber of pairs (v1, v2) is P(v3) - (number of adjacents of v3 - 1).So, we finished? No. We are counting each triangle 3 times, also squares, two times. There is another bad case. Consider a, b, c, d, and edges a-b, a-c, b-c, b-d. Subtract these values from the answer.\n\nComplexity: O(n ^ 3).\n\n```\npublic long count(int N, int seed, int threshold, int[] toggle) {\n\nboolean[][] G = new boolean[N][N];\n\nfor (int a=0; a<N; ++a) for (int b=0; b<N; ++b) G[a][b] = false;\n\nlong state = seed;\nfor (int a=0; a<N; ++a) for (int b=a+1; b<N; ++b) {\nstate = (state * 1103515245 + 12345) % (1L << 31);\nif (state < threshold) G[a][b] = G[b][a] = true;\nif (N <= 10 && state < threshold) System.out.println(\"adding edge \"+a+\" \"+b);\n}\n\nfor (int i=0; 2*i<toggle.length; ++i) {\nint a = toggle[2*i], b = toggle[2*i+1];\nG[a][b] = !G[a][b];\nG[b][a] = !G[b][a];\n}\n\nint[][] E = new int[N][];\nfor (int a=0; a<N; ++a) {\nint deg = 0;\nfor (int b=0; b<N; ++b) if (G[a][b]) ++deg;\nE[a] = new int[deg];\nfor (int b=N-1; b=0; --b) if (G[a][b]) E[a][--deg] = b;\n}\n\nlong[] P = new long[N];\nfor (int a=0; a<N; ++a) P[a] = 0;\n\nlong triangles = 0;\nlong triangleEdges = 0;\nlong squares = 0;\n\nfor (int a=0; a<N; ++a) for (int b=a+1; b<N; ++b) {\nint common = 0;\nfor (int c=0; c<N; ++c) if (G[a][c] && G[b][c]) ++common;\nif (G[a][b]) {\nP[a] += E[b].length - 1;\nP[b] += E[a].length - 1;\n}\nsquares += common * (common-1) / 2;\nfor (int c=b+1; c<N; ++c) {\nif (G[a][b] && G[a][c] && G[b][c]) {\n++triangles;\ntriangleEdges += E[a].length + E[b].length + E[c].length - 6;\n}\n}\n}\n\nlong answer = 0;\nfor (int a=0; a<N; ++a) for (int b=a+1; b<N; ++b) if (G[a][b]) {\nlong c = P[a] - E[b].length + 1;\nlong d = P[b] - E[a].length + 1;\nanswer += c * d;\n}\nreturn 2*(answer - 3*triangles - 3*triangleEdges - 2*squares);\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/single-round-match-779-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4OTi4ovs5kSOuV6MSX0l4l","type":"Entry","createdAt":"2020-04-20T12:41:38.680Z","updatedAt":"2026-01-31T22:13:28.110Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":25,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"TCO18 INDIA REGIONAL SRM","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Java"],"creationDate":"2018-08-14T00:00:00.000Z","readTime":"10 min","content":"# Editorial For TCO18 India Regional SRM\nThe TCO18 India Regional featured an SRM event. Or actually there were 2 SRMs –\nthe short one, lasting for 10 minutes, and the regular one, lasting 75 minutes + challenge phase. The objective of the first round was to warm up and get into the environment. It was intended mostly for participants new to Topcoder Arena.\nI will cover 2 tasks here – from the regular round. The medium task from the full-sized SRM is already covered by maxwells_daemon, and the warm up task is not available anymore. I can say only that it was classical and can be solved using the Dynamic Programming. hmehta wanted a more complex set of tasks than the usual difficulty Regional rounds have. This was done to distinguish between the leaders more clearly. As a direct result, many scored zero.\n\n## SymmetricImage\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/14973)\nIn this task you are given a matrix, the question is to determine if it is symmetrical. The return has to be 0 for no symmetry, 1 for either horizontal or vertical symmetry, and 2 for both horizontal and vertical symmetry.\n44 participants managed to solve the task and pass the system tests. As this is less than a half of the ones who opened the question, I find it necessary to provide the algorithm.\nLet us check for the 2 types of symmetry independent one from the other. For instance, checking the horizontal symmetry is done as follows:\n```\n  boolean horizontal = true;\n     for (int i = 0; i < image.length; i++) {\n            for (int j = 0; j < image[i].length(); j++) {\n                if (image[i].charAt(j) != image[image.length - 1 - i].charAt(j)) {\n                    horizontal = false;\n                }\n            }\n        }\n```\nAs you can see, we set a Boolean flag indicating that there is a horizontal symmetry to true initially, assuming that there is a horizontal symmetry. This assumption is the key. Then, in the inner loop we validate this assumption. Incase it turned out to be wrong, we point that out in our Boolean flag.\n\nThere is no horizontal symmetry if and only if there is some cell so that its value does not match with its symmetrical cell. And the index of the symmetrical cell for a cell (i, j) is (n-1-i, j). No magic, by definition of symmetry we have S(x, y) = (-x,y). However, as our indexing starts with 0 not -n/2, the formula provided is correct.\n\nYou can write the code for the vertical symmetry as an exercise.\nThe final check is trivial – we have 2 Boolean flags and need to do some conditional statements on them.\n\n## Shuffler\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/14965)\nThis task has a rather complex statement. I ask you to read it first and spend a few minutes on thinking about this puzzle before reading further.\n\nThe main idea I used for this task was that you can generate the solution in iterative manner, letter by letter. This is due to the fact that with any order of the cards, you can get a concrete letter on top in 5+1=6 steps or less. The proof is similar as in [Radix Sort](https://topcoder.com/community/competitive-programming/tutorials/sorting/).\n\nThus, we have reduced the task to a simpler one, namely to move the card indexed K into the first position. The order of the other cards does not matter, neither in the original configuration, not in the final. Additionally, it would be nice to have the sequence as short as possible.\nI solved this simpler task by using Dynamic Programming (DP). The state of the DP is 1-dimensional. It is as simple as the possible index of the card with the wanted letter. For instance, if I want a letter B to appear on the top, and currently B is number 11, then I set DP[all] = ∞, DP[11] = 0. I populate the DP table until the DP[0] is eventually filled with a number.\n\nThe DP transition is just checking all 2 types of the operations allowed. I wrap the DP table mutation into an “infinite” outer loop to ensure that all the states are populated. The exit condition is that the DP[0] is filled with a finite integer.\n\nThen I reconstruct the solution backwards. Finally, the R symbol is appended to the result to indicate that the next wanted letter is on top. Note that for reconstruction purposes I store an extra FROM table, that just remembers the previous DP state that we used to transition into the current one.\n\nThe next phase is just apply the next letter finding pattern to the original letter sequence. This is needed in order to be able to solve the puzzle for the next letter in the given input string.\n\nAs an exercise you can write a recursive solution with memoization that solves the same task.\n\n## Final Notes\nI personally liked the tasks given at the event, and the event in general. I asked Harshit to make the Easy task easier the next time though, so that mostly everyone ends up with a positive score.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7sLraZ4JsIbN18QeRKgFd","type":"Entry","createdAt":"2019-09-18T07:37:36.197Z","updatedAt":"2019-10-15T15:59:38.697Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Anatolijs Gorbunovs","tcHandle":"gorbunov"}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/editorial-for-tco18-india-regional-srm/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3gkYt0HnqKP0t57TSm4gG5","type":"Entry","createdAt":"2020-04-20T12:43:25.990Z","updatedAt":"2026-01-31T22:04:40.052Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":40,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 783","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["C++","Java"],"creationDate":"2020-04-11T00:00:00.000Z","readTime":"20 min","content":"# Single Round Match 783 Editorials\n\n## PosNegDice\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16036)\nKeep two arrays: positiveValueCounts and negativeValueCounts.\n\nIn the first array, we will keep positive dices. We will keep negative dices in the second one. Then we will remove positive and negative die with the same value. It is, for each i, we will subtract min(positiveValueCounts[i], negativeValueCounts[i]) from positiveValueCounts[i] and negativeValueCounts[i].\n\nFinally, we check if we have positive positiveValueCounts[i] where i <= T. Also we sum up all negativeValueCounts and return it as a point of stress.\n\n```\npublic int[] evaluateRoll(int T, int[] positiveDice, int[] negativeDice) {\n    // count the number of occurrences for each value\n    int[] positiveValueCounts = new int[7];\n    int[] negativeValueCounts = new int[7];\n    for (int d : positiveDice) ++positiveValueCounts[d];\n    for (int d : negativeDice) ++negativeValueCounts[d];\n\n    // eliminate all equal pairs at once\n    for (int d=1; d<=6; ++d) {\n        int eliminated = Math.min( positiveValueCounts[d], negativeValueCounts[d] );\n        positiveValueCounts[d] -= eliminated;\n        negativeValueCounts[d] -= eliminated;\n    }\n\n    // compute the answer by examining what remained\n    int[] answer = {0, 0};\n    for (int d=1; d<=6; ++d) {\n        if (d <= T && positiveValueCounts[d] > 0) answer[0] = 1;\n        answer[1] += negativeValueCounts[d];\n    }\n\n    return answer;\n}\n```\n\n## BouncingBall\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16059)\n![Bouncing Ball SRM 873](//images.ctfassets.net/piwi0eufbb2g/7dl8v2lMPmYBkWxkspErME/ed1df6ef4231abe2905a6e5ce2fdd1ee/Bouncing_Ball_SRM_873.png)\n\nHint: Simulate the process\n\nFrom one hill to another, we first fall down and raise up again. We call this process a step. We keep the time and height at the start of each step, then step by step we check if we exceeded from the given time and print the answer.\nNote that the maximum number of steps we need to process is not so much and small enough to pass the time limit. One can check it when g = 1000, h = 10, p = 10, t = 50, number of steps is 51.\nThe below code by misof is enough for understanding the math behind:\nHint: Simulate the process.\n\n```double freeFallDuration(double g, double h) {\n    // given g and h, what is the duration of the free fall from height h to the ground?\n    // this is then also the time the ball takes when thrown vertically upwards to height h (time reversal argument)\n    // h = gt^2 / 2   =>   t = sqrt(2h/g)\n    return Math.sqrt(2*h/g);\n}\n\ndouble freeFallPosition(double g, double h, double t) {\n    // given g, h, t such that t <= freeFallPosition(g,h),\n    // what is the position of the ball t seconds after the free fall from height h started?\n    return h - g*t*t/2;\n}\n\npublic double getPosition(int gCm, int h0, int p, int tGoal) {\n    double t = 0;\n    double h = h0;\n    double g = gCm / 100.;\n    while (true) {\n        double tFall = freeFallDuration(g,h);\n        if (t + tFall >= tGoal) {\n            // we reach the goal time during the fall downwards\n            double tDuringFall = tGoal - t;\n            return freeFallPosition(g,h,tDuringFall);\n        }\n        t += tFall;\n\n        // do the bounce, lose some height\n        h *= (100 - p) / 100.;\n\n        double tRise = freeFallDuration(g,h);\n        if (t + tRise >= tGoal) {\n            // we reach the goal time during the rise upwards\n            double tDuringRise = tGoal - t;\n            double tDuringFall = tRise - tDuringRise; \n            return freeFallPosition(g,h,tDuringFall);\n        }\n        t += tRise;\n    }\n}\n```\n\n## CardboardBoxes\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16060)\nAssume length ```>=``` width.\n\nArea of the sides is 2 * height * (width + length). \n\nThe other dimension of top flaps will be width/2, so their area is width * (width + length). \n\nThe same for the bottom.\n\nSo S = 2 * (width + length) * (width + height).\n\nTo illustrate this, you can actually cut out such a box from a (2L+2W) * (H+W) cardboard rectangle as shown below. Lines inside are cuts, dots are folds, asterisk edges have to be taped together. This is how you can really produce such boxes with minimum waste.\n\n![Dots SRM 873](//images.ctfassets.net/piwi0eufbb2g/5aypcdVslW5OKj4scFOigk/c1152449908553966c6dae6e4354d5f7/Dots_SRM_873.png)\n\nSo possible options of width + length are divisors of S / 2. We can find divisors of S / 2 in O(S). After fixing width + length = k, we know that width + height = S/k. Once we choose width the other two dimensions are fixed, and we can compute the number of valid widths in constant time.\n\nCode by misof:\n```long processKnownLplusW(long S, long LplusW) {\n    long HplusW = S / LplusW;\n    long maxW = Math.min( LplusW/2, HplusW-1 );\n    return maxW;\n}\n\npublic long count(long S) {\n    if (S % 2 == 1) return 0;\n    S /= 2;\n    long answer = 0;\n    for (long d=1; d*d <= S; ++d) if (S % d == 0) {\n        answer += processKnownLplusW(S,d);\n        if (d < S/d) answer += processKnownLplusW(S,S/d);\n    }\n    return answer;\n}\n```\n\n## ABBAReplace\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15694)\nHint: Consider a similar process from the end to the beginning.\n\nDirect simulation is ugly. We can visualize the process as “Bs want to go to the left”, but the process is complicated: e.g., there can be Bs that alternately move and have to stay in place.\n\nThere are two observations that can really simplify the solution. First, we can relax the original task by allowing some letters to stay in place instead of being swapped. The minimal number of turns clearly remains the same because greedily making all possible swaps produces one possible optimal solution for the new task. However, now there will be other optimal solutions, too, and those will be easier to construct.\n\nSecond, consider the new problem backwards. What do we have in the end? Something like “BBB…BAAA…”. Some of these Bs are in their right places, others need to move to the right. The rightmost B can start moving immediately and it will never be blocked. In the second step the rightmost two Bs can move, and so on. In this way, no B will ever get blocked by another one because the ones to its right started moving sooner and go farther right. Hence, we can simply compute each B’s travelling time as (the number of Bs to its right) plus (the number of steps it needs to make).\nCode by misof:\n\n```public int countSteps(String Sprefix, int N, int seed, int threshold) {\n    StringBuilder sb = new StringBuilder(Sprefix);\n    long state = seed;\n    long modulus = 1L << 31;\n    while (sb.length() < N) {\n        state = (state * 1103515245 + 12345) % modulus;\n        if (state < threshold) sb.append(\"A\"); else sb.append(\"B\");\n    }\n    String S = sb.toString();\n    ArrayList<Integer> bindices = new ArrayList<Integer>();\n    for (int n=0; n<N; ++n) if (S.charAt(n) == 'B') bindices.add(n);\n    int BC = bindices.size();\n    int maxtime = 0;\n    for (int b=0; b<BC; ++b) {\n        int bdest = bindices.get(b);\n        if (bdest == b) continue;\n        maxtime = Math.max( maxtime, BC-1-b + bdest-b );\n    }\n    return maxtime;\n}\n```\n\n## RecursiveTournament\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/14810)\nHint: Calculate the answer for k = 1.\n\nLet’s think about what a subgraph looks like? It consists of several groups of vertices say a1, a2, …, am, where for each vertex like v in ai, and u in aj v has a directed path to u if and only if i <= j.\n\nIt looks like a chain (maybe consists of one group, i. e. m = 1). Vertices in group a1 are strongly connected (similar for a2, a3, …, am), every vertex from a1 has a directed edge toward every vertex in a2, a3, …, am. Every vertex from a2 has a directed edge toward every vertex in a3, a4, …, am. Also, there is no edge from v in ai toward u in aj where i > j, otherwise, they can create a larger group together.\n\nFrom the constraints, we straightly jump to dp on bitmasks! For each mask, let’s calculate part[mask][]. part[mask][v] (that v is present in the mask) is the group (ai) that v is present in it; when showing the vertices in the mask as the above format.\n\nLet’s calculate part[mask]. Take a vertex like v from the mask. Let omask be a mask excluding v (omask = mask ^ (1 << v)). We need to find the rightmost group (with the largest index) that has a vertex that has an edge toward v, name it R. Similarly, find the leftmost group (with the lowest index) that has a vertex that v has an edge toward it, name it L. If R < L, v creates a new group. Otherwise, v will merge groups [L, R] together and join them.\n\nIn the end, we check if part[mask][] is 1 for all of the present vertices then mask is an SCC.\n\nNow, let’s solve the general problem when k is not necessarily 1. Consider an SCC in the input graph with size x: v1, v2, …, vx. In the code below s[x] stands for the number of times it appears in the big tournament graph. What is s[x]?\n\nHow many vertices start with v1? b ^ (k – 1). Same for v2, v3, …, vx. We choose a non-empty subset of vertices from vertices starting with v1, another non-empty subset from vertices starting with v2, … . The number of ways to choose x vertices we counted here equals (2 ^ (b ^ (k – 1)) – 1) ^ x. Now we just counted the number of subsets of vertices in the big tournament such that at least two of them differ in the first bit. We go further for the second, third, …, k-th bit. When calculating the number for i-th bit, b ^ (i – 1) * (2 ^ (b ^ (k – i – 1)) – 1) ^ x. We have b ^ (i – 1) ways to choose the prefix for vertices.\n\nIn the end, we are able to calculate s[x] for each x in the range [1, n].\n\nOverall time complexity is O(n * 2^n + nk).\n\nHere is the code by lg5293:\n\n```\nint mod = 998244353;\nint b;\nint k;\nlong ans;\nlong[] s;\nboolean[][] mat;\n\nint max(int[] arr) {\n    int ret = arr[0];\n    for (int x : arr) ret = Math.max(x, ret);\n    return ret;\n}\n\nlong mod_exp(long b, long e, long mod) {\n    long res = 1;\n    while (e > 0) {\n        if ((e & 1) == 1)\n            res = (res * b) % mod;\n        b = (b * b) % mod;\n        e >>= 1;\n    }\n    return res % mod;\n}\n\npublic void dfs(int[] part, int mask, int idx) {\n    if (idx == b) {\n        if (Integer.bitCount(mask) > 1 && max(part) == 1) {\n            ans += s[Integer.bitCount(mask)];\n            if (ans >= mod) ans -= mod;\n        }\n        return;\n    }\n\n    dfs(Arrays.copyOf(part, part.length), mask, idx+1);\n    if (mask == 0) {\n        part[idx] = 1;\n        dfs(part, mask | (1 << idx), idx+1);\n        return;\n    }\n    int lowest = b, highest = 0;\n    for (int i = 0; i < idx; i++) {\n        if (((mask >> i) & 1) == 1) {\n            if (mat[i][idx]) lowest = Math.min(lowest, part[i]);\n            else highest = Math.max(highest, part[i]);\n        }\n    }\n    if (lowest == highest) {\n        part[idx] = lowest;\n    } else if (lowest > highest) {\n        // highest+1 == lowest\n        for (int i = 0; i < idx; i++) {\n            if (part[i] >= lowest) part[i]++;\n        }\n        part[idx] = highest + 1;\n    } else { // lowest < highest\n        for (int i = 0; i < idx; i++) {\n            if (part[i] >= lowest) {\n                if (part[i] > highest) {\n                    part[i] += lowest - highest;\n                } else {\n                    part[i] = lowest;\n                }\n            }\n        }\n        part[idx] = lowest;\n    }\n    dfs(part, mask | (1 << idx), idx + 1);\n}\n\npublic int count(String[] graph, int k) {\n    b = graph.length;\n    mat = new boolean[b][b];\n    for (int i = 0; i < b; i++) {\n        for (int j = 0; j < b; j++) {\n            mat[i][j] = graph[i].charAt(j) == 'Y';\n        }\n    }\n    s = new long[b + 1];\n    for (int j = 0; j < k; j++) {\n        long r = mod_exp(b, k - j - 1, mod);\n        long mult = mod_exp(2, mod_exp(b, j, mod - 1), mod) - 1;\n        for (int i = 0; i <= b; i++) {\n            s[i] = (s[i] + r) % mod;\n            r = r * mult % mod;\n        }\n    }\n    ans = mod_exp(b, k, mod);\n    dfs(new int[b], 0, 0);\n    return (int)ans;\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/single-round-match-783-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"0dpKvKNXf6xzzYDSavsGs","type":"Entry","createdAt":"2020-04-20T12:43:25.926Z","updatedAt":"2026-01-31T19:40:51.210Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":122,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM 781","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}}],"tags":["Python"],"creationDate":"2020-03-20T00:00:00.000Z","readTime":"30 min","content":"# Single Round Match 781 Editorials\n\n## EasyPartition\n[Problem link](https://archive.topcoder.com/ProblemStatement/pm/15977)\n__Used as: Division Two – Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__       | 250       |\n| __Submission Rate__       | 106 / 144 (73.61%)       |\n| __Success Rate__       | 82 / 106 (77.36%)       |\n| __High Score__       | \tz3r0dmg for 249.07 points (1 mins 44 secs)       |\n| __Average Score__       | 176.85 (for 82 correct submissions)      |\n\nFind and implement a pattern. Many different patterns work. For example:\n1 = 1\n1 + 3 = 4\n1 + 3 + 5 = 9\n1 + 3 + 5 + 7 = 16\n…\nSum of odd numbers less than 2*k is k^2.\nSo if we choose odd numbers less than 2*(2*N), the sum will be (2*N)^2.\n\n```\n  def getPartition(self, N):\n    return \"10\" * 2 * N + \"0\" * 4 * N\n```\n\nAnother solution is to take numbers 2N+1, …, 2N+N, and also 2N-1, …, 2N-N. The numbers 2N+i and 2N-i have sum 4N, and we have N such pairs.\n\n## NicePartition\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16013)\n__Used as: Division Two – Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__       | 500       |\n| __Submission Rate__       | 93 / 144 (64.58%)      |\n| __Success Rate__       | 83 / 93 (89.25%)     |\n| __High Score__      | \thp_Vardhan for 495.80 points (2 mins 37 secs)       |\n| __Average Score__       | 386.70 (for 83 correct submissions)     |\n\nSort H.\n\nImagine that we are constructing the buildings from the tallest to the smallest. Where can we build the tallest one without violating the conditions? At the end of A, or at the beginning of B. Where can we build the second tallest? Again, at the last free position in A, or the first free position in B. And so on.\n\nPause the process after constructing the N tallest buildings. Regardless of how many buildings we put into A and how many into B, we now have exactly one building in each pair of buildings. Thus, regardless of how we partition the buildings, each pair of buildings will always contain one of the N tallest and one of the N shortest buildings. So, in each pair we will take the height of a tall building and subtract the height of a short building. And therefore the sum of all instabilities will be always simply the sum of the N tallest buildings, minus the sum of the N shortest buildings.\n\nIt turns out that the answer does not depend on the partitioning.\n\n```\nint minCost(vector<int> H){\n    \tsort(H.begin(), H.end());\n    int ans = 0;\n    for(int i = 0; i < H.size() / 2; i++)\n        ans += H[H.size() - i - 1] - H[i];\n    return ans;\n}\n    Python code:\n\n    \tdef minCost(self, H):\n    \t\tH = list(H)\n    \t\tH.sort()\n    \t\tN = len(H) // 2\n    \t\treturn sum( H[N:] ) - sum( H[:N] )\n```\n\n## PolygonalRegions\n[Problem link](https://archive.topcoder.com/ProblemStatement/pm/16034)\n__Used as: Division Two – Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__       | 1000       |\n| __Submission Rate__       | 8 / 144 (5.56%)      |\n| __Success Rate__       | 2 / 8 (25.00%)     |\n| __High Score__       | \tyhchang3 for 799.21 points (15 mins 2 secs)       |\n| __Average Score__       | 692.00 (for 2 correct submissions)     |\n\nFor a given, fixed state of the polygon, which it’s determined that each vertex is good or not, the calculation of the number of regions is simple. Imagine that we draw the diagonals one at a time. Each diagonal will divide some regions into two. The number of regions it divides is 1 + the number of other diagonals it intersects. Thus, the final answer is 1 (the original region) + the number of diagonals + the number of intersections of two diagonals.\n\nThe number of regions can also be derived from [https://en.wikipedia.org/wiki/Planar_graph#Euler%27s_formula](https://en.wikipedia.org/wiki/Planar_graph#Euler%27s_formula): the original vertices and the intersections are the nodes of the graph, line segments between them are the edges, and regions + the infinite part of the plane are the faces of the graph.\n\nBy linearity of expectation, the expected number of diagonals is the sum of probabilities that a diagonal is present in the drawing, and the expected number of intersections is the sum of probabilities that each pair of diagonals appears together. If we denote the probability of point i being good P[i], the expected number of diagonals is the sum of P[i]*P[j] over all diagonals, and the expected number of intersections is the sum of P[i]*P[j]*P[k]*P[l] over all pairs of diagonals (i,j) and (k,l) that intersect. This gives us an O(n^4) solution:\n\n```\nconst long long MOD = 1000000007;\n\nlong long modexp(long long a, long long b) {\n    if (b == 0) return 1;\n    long long t = modexp(a,b/2);\n    t *= t;\n    t %= MOD;\n    if (b % 2) {\n        t *= a;\n        t %= MOD;\n    }\n    return t;\n}\n\nstruct PolygonalRegions {\n    int expectedRegions(int N) {\n        long long N2 = (N*N) % MOD;\n        long long denominator = (N2*N2) % MOD;\n        long long numerator = denominator; // the one initial region\n\n        for (int i=0; i<N; ++i) for (int j=i+2; j<N; ++j) if (!(i == 0 && j == N-1)) {\n            // diagonal i-j adds one region if present\n            long long pij = (1LL * (i+1) * (j+1)) % MOD;\n            numerator += pij * N2;\n            numerator %= MOD;\n            // each present k-l that crosses i-j adds one region\n            for (int k=i+1; k<j; ++k) for (int l=j+1; l<N; ++l) {\n                long long pkl = (1LL * (k+1) * (l+1)) % MOD;\n                numerator += pij * pkl;\n                numerator %= MOD;\n            }\n        }\n\n        long long inverse_denominator = modexp(denominator, MOD-2);\n\n        return (numerator * inverse_denominator) % MOD;\n    }\n};\nThe solution can be further improved by counting more cleverly, all the way to an O(n) solution:\n\nlong mod = 1000000007;\n\tlong power(long base, long exponent) {\n\t    long ret = 1 % mod; \n\t    base %= mod; \n\t    while(exponent > 0) {\n\t        if(exponent % 2 == 1) {\n\t            ret = (ret * base) % mod;\n\t        }\n\t        base = (base * base) % mod;\n\t        exponent >>= 1;\n\t    }\n\t    return ret;\n\t}\n\tlong inv(long val) {\n\t    return power(val, mod - 2);\n\t}\n\tpublic int expectedRegions(int N) {\n\t\tlong[] DP = new long[N + 1];\n\t\tlong invN = inv(N);\n\t\tfor(int i = 1; i <= N; i++) {\n\t\t\tDP[i] = (i * invN) % mod;\n\t\t}\n\t\tlong two_together = 0, four_together = 0;\n\t\tfor(int i = 1; i <= 3; i++) {\n\t\t\tlong[] prev = new long[N + 1];\n\t\t\tfor(int j = 1; j <= N; j++) {\n\t\t\t\tprev[j] = DP[j];\n\t\t\t}\n\t\t\tlong sum_so_far = 0;\n\t\t\tDP[0] = 0;\n\t\t\tfor(int v = 1; v <= N; v++) {\n\t\t\t\tlong here = (v * invN) % mod;\n\t\t\t\tDP[v] = (here * sum_so_far) % mod;\n\t\t\t\tsum_so_far = (sum_so_far + prev[v]) % mod;\n\t\t\t}\n\t\t\tif(i == 1) {\n\t\t\t\tfor(int j = 1; j <= N; j++) {\n\t\t\t\t\ttwo_together += DP[j];\n\t\t\t\t\ttwo_together %= mod;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int j = 1; j <= N; j++) {\n\t\t\tfour_together += DP[j];\n\t\t\tfour_together %= mod;\n\t\t}\n\t\tlong answer = (four_together + two_together) % mod;\n\t\tlong adjacent = 0;\n\t\tfor(long i = 1; i <= N; i++) {\n\t\t\tadjacent = (adjacent + (i * (i % N + 1))) % mod;\n\t\t}\n\t\tadjacent = (adjacent * ((invN * invN) % mod)) % mod;\n\t\tanswer = (answer - adjacent + 1 + mod) % mod;\t\t\n\t\treturn ((int)answer) % (int)mod;\n\t}\n\n```\n\n## EpicPartition\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15954)\n__Used as: Division One – Level One:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__       | 250       |\n| __Submission Rate__       | 76 / 135 (56.30%)      |\n| __Success Rate__       | 45 / 76 (59.21%)     |\n| __High Score__       | \tbqi343 for 213.26 points (12 mins 14 secs)       |\n| __Average Score__       | 134.15 (for 45 correct submissions)     |\n\nThere are many valid ways to partition the given set in the given way. You can either find and implement a specific pattern, implement a backtracking solution, and if you’re feeling a bit adventurous, you can even try a random walk: split the set into subsets of desired sizes and swap items around until the sums are correct.\n\nNotably, it is obvious that the answer only exists for N=4*k, and thus we only need to find only 25 answers in any way we can. The submitted solution can then contain those 25 cases hard-wired.\n\nOne possible pattern:\n```\n    int K = N / 4;\n  \tchar[] filled = new char[6 * N];\n  \tfor(int i = 0; i < 24 * K; i++) {\n  \t\tfilled[i] = 'a';\n  \t}\n  \tfilled[-1 + 24 * K] = 'c';\n  \tfilled[-1 + 18 * K] = 'c';\n  \tfor(int i = 1; i <= 4 * K - 1; i++) {\n  \t\tfilled[-1 + 18 * K - i] = 'c';\n  \t\tfilled[-1 + 18 * K + i] = 'c';\n  \t}\n  \tfilled[-1 + 9 * K] = 'b';\n  \tfilled[-1 + 12 * K] = 'b';\n  \tfor(int i = 1; i <= 4 * K - 1; i++) {\n  \t\tif(i == 3 * K) {\n  \t\t\tfilled[-1 + 5 * K] = 'b';\n  \t\t\tfilled[-1 + 13 * K] = 'b';\n  \t\t} else {\n  \t\t\tfilled[-1 + 9 * K + i] = 'b';\n  \t\t\tfilled[-1 + 9 * K - i] = 'b';\n  \t\t}\n  \t}\n```\n\nThe random walk solution:\n\n```\nfrom random import randint\n\ndef random_split(seq, target_size, target_sum):\n\tpart1, part2 = list(seq[:target_size]), list(seq[target_size:])\n\tsteps = 0\n\twhile True:\n    \tif sum(part1) == target_sum: break\n    \twhile True:\n        \tsteps += 1\n        \tif steps == 10000: return None\n        \ti = randint(0, len(part1)-1)\n        \tj = randint(0, len(part2)-1)\n        \tif (part1[i] < part2[j]) == (sum(part1) < target_sum):\n               break\n    \tpart1[i], part2[j] = part2[j], part1[i]\n\treturn part1, part2\n\nclass EpicPartition:\n\tdef createPartition(self, N):\n    \tif N % 4 != 0: return \"\"\n    \twhile True:\n        \ttry:\n            \tS = range(1,6*N+1)\n            \tC, AB = random_split(S,2*N,sum(S)//2)\n            \tA, B = random_split(AB,2*N,sum(AB)//2)\n            \tbreak\n        \texcept:\n            \tcontinue\n    \tanswer = [ None for _ in range(6*N+1) ]\n    \tfor a in A: answer[a] = 'a'\n    \tfor b in B: answer[b] = 'b'\n    \tfor c in C: answer[c] = 'c'\n    \treturn ''.join( answer[1:] )\n```\n\n## RandomPartition\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/15955)\n__Used as: Division One – Level Two:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__       | 450       |\n| __Submission Rate__       | 35 / 135 (25.93%)     |\n| __Success Rate__       | 30 / 35 (85.71%)     |\n| __High Score__      | \tneal_wu for 427.80 points (6 mins 32 secs)       |\n| __Average Score__       | 327.99 (for 30 correct submissions)    |\n\nSee the editorial to NicePartition. The randomness is just a ruse, the sum of all instabilities, and therefore their average is always the same. We just need to calculate it and return it.\n```\n    def expectedSum(self, nums, N, M, B1, B2):\n        H = list(nums)\n        while len(H) < 2*N:\n            H.append( (H[-1]*B1 + H[-2]*B2) % M )\n        H.sort()\n        num = sum( H[N:] ) - sum( H[:N] )\n        den = N\n        invden = 1\n        while (invden * den) % 786433 != 1:\n            invden += 1\n        return (num * invden) % 786433\n\n```\n\n## RoseDressGame\n[Problem Link](https://archive.topcoder.com/ProblemStatement/pm/16035)\n__Used as: Division One – Level Three:__\n\n| Field     | Value     |\n| ---------- | ---------- |\n| __Value__       | 1000       |\n| __Submission Rate__       | 12 / 135 (8.89%)      |\n| __Success Rate__       | 7 / 12 (58.33%)     |\n| __High Score__       | Egor for 688.80 points (21 mins 13 secs)       |\n| __Average Score__       | 560.39 (for 7 correct submissions)      |\n\nThe game can be called a “misère annihilation NIM” (“misère” describes the reversed winning condition, annihilation describes what happens to piles of equal size). In normal NIM it is obvious that annihilation doesn’t change the outcome, but, perhaps surprisingly, it does change the outcome under misère play: misère NIM without annihilation has a different set of losing positions. To solve the problem you need to find the pattern of losing positions (and possibly prove that you found them correctly, although in a contest a test against your brute-force solution is much more practical). Here, it can be shown that the losing positions can be described as follows:\n\nPile of size 0 can be ignored, so below we only consider positions with no such pile.\nCall a position paired if the pile sizes can be divided into pairs of the form (2k, 2k+1).\nCall a position generalized paired if it’s a paired position + maybe a pile of size 1.\nAll generalized paired positions such that xor of pile sizes is 1 are losing positions.\nAll positions that have xor = 0 and are not generalized paired positions are losing positions.\nAll other positions are winning.\nThe proof is essentially just casework: We have to show that all moves from a losing position lead to a winning position, and that each winning position is either terminal or it has a move to a losing position.\n\n```\n    public String getWinner(int[] roses) {\n        int x = 0;\n        for (int r : roses) x ^= r;\n        if (x > 1) return \"Coco\";\n\n        int bigc = 0;\n        for (int r : roses) if (r > 1) ++bigc;\n\n        int[] big = new int[bigc];\n        int hlp = 0;\n        for (int r : roses) if (r > 1) big[hlp++] = r;\n        Arrays.sort(big);\n\n        boolean all_pairs;\n        if (bigc % 2 == 0) {\n            all_pairs = true;\n            for (int i=0; i<bigc/2; ++i) if (big[2*i] + 1 != big[2*i+1]) all_pairs = false;\n            for (int i=0; i<bigc/2; ++i) if (big[2*i] % 2 == 1) all_pairs = false;\n        } else {\n            all_pairs = false;\n        }\n\n        if (x == 1 && all_pairs) return \"Yves\";\n        if (x == 0 && !all_pairs) return \"Yves\";\n        return \"Coco\";\n    }\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"externalArticle":false,"contentUrl":"https://www.topcoder.com/single-round-match-781-editorials/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3P1KEOLhw8mhRx8OLQKajF","type":"Entry","createdAt":"2025-10-31T23:27:23.002Z","updatedAt":"2025-11-03T09:35:57.462Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":44,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"The New Topcoder Review Flow","slug":"the-new-topcoder-review-flow","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}}],"tags":["Review UI","Online Review"],"creationDate":"2025-11-01","readTime":"3 min","content":"As part of our continued modernization of the Topcoder platform, we are introducing a new and improved Topcoder Review application. This update replaces the decades-old Online Review application and brings a more user-friendly experience for submitters, copilots, reviewers, and project managers.\n\n### Online Review Is Being Retired\nThe legacy [Online Review system](https://software.topcoder.com/) is being permanently retired. Once this change is complete (November 2, 2025), all existing Online Review links will no longer be accessible.  Online Review is written in Java, and while it has recently been updated to run with more modern JSP and Servlet technology, is still very out-dated and difficult to maintain.  It also relies on direct Informix access, and we are deprecating our Informix database entirely, in favour of Postgres running on AWS RDS.\n\nBecause of this change new challenges will no longer receive the eight-digit legacy IDs that were previously used by the the legacy apps. All new challenges will instead use a single UUID (Universally Unique Identifier).\nExisting legacy challenges and their reviews will remain available under their current identifiers, but all new work will use the new format going forward.\n\n### The New Review Application\nThe new Review application is available now at review.topcoder.com.\n\nYou can access a specific challenge directly by visiting:\n<https://review.topcoder.com/{challengeId}>\n\nIf you visit [review.topcoder.com](https://review.topcoder.com/) without a challenge ID, you’ll see a list of all your active challenges, along with the current phase, time remaining, and clear indicators for any late phases, which are highlighted in red.\n\n![01 Screenshot 1](//images.ctfassets.net/piwi0eufbb2g/2snldyb4sALA0cPxcrrTtT/afdbc9017be73f56fd46a38740258d65/01.png)\n\n__Familiar Review Experience with Modern Enhancements__\nThe new Review app preserves the familiar workflow from Online Review — including the same scorecards, evaluation structure, and overall process — while introducing several important improvements.\n\n__Markdown Support for Comments__\nAll review comments, appeals, and appeals responses are now stored and rendered in Markdown format.\nThis allows for improved formatting, including headings, bullet points, code blocks, and hyperlinks.\n\nFiles can also be dragged and dropped directly into the Markdown editor, eliminating the need for external file storage. From now on, all review artifacts will be securely stored and accessible within the Topcoder platform itself.\n\n![02 Screenshot 2](//images.ctfassets.net/piwi0eufbb2g/4W19ZRphF1r4Oyxk2T4ky3/3f3d8c0e46c4207cd4dd2bf0f4e707d3/02.png)\n\n### The Challenge Details Page\nClicking any challenge in the Review app opens the Challenge Details page.\nThis page provides a clear overview of:\n- The timeline and current phase statuses\n- Access to reviews, appeals, and appeals responses for completed challenges\n- Direct links to submissions and review results\n\nThe layout is streamlined to make navigation between submissions, scorecards, and phase information faster and more intuitive.\n\n![03 Screenshot 3](//images.ctfassets.net/piwi0eufbb2g/5lK9X02f0tDw0TPiasbHGJ/60fc8876e76c7843a70a8cd296e93538/03.png)\n\n### Role-Based Capabilities\n__For Copilots__\nCopilots will have additional control and visibility within the new Review app:\n- The ability to open, close, and extend phases directly from the Timeline section\n- The ability to view payments associated with a challenge\n\nFor auditing and security reasons, payment edits are now restricted to Topcoder support staff.\n\n__For Submitters__\nSubmitters will see only their own submissions while a challenge is active.\nAfter the challenge completes:\n- If a submitter has a passing submission, they will be able to download other submissions and view their associated reviews, similar to the previous Online Review functionality.\n\nThis approach ensures both transparency and fairness throughout the competition process, while also still allowing submitters to learn from other submissions and reviews.\n\n### Questions / Discussion\nPlease see here for the [forums discussion](https://discussions.topcoder.com/categories/informix-general-discussion) around this new app. ","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yO45g1yJfxerGOktJVufM","type":"Asset","createdAt":"2022-10-18T14:37:19.496Z","updatedAt":"2023-09-15T21:03:26.749Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"Being a Successful Topcoder Freelancer","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7yO45g1yJfxerGOktJVufM/a283509c9e75aeb72730662fb1bc989a/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1KSO9elwSjMcMAkaygGVc3","type":"Entry","createdAt":"2019-09-20T07:14:17.372Z","updatedAt":"2021-06-11T08:05:06.049Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Justin Gasper","tcHandle":"Ghostar","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4q1Y7XYEz8qyfKygQkQKVT","type":"Entry","createdAt":"2025-10-12T11:59:16.448Z","updatedAt":"2025-10-31T18:16:16.044Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":108,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Trolley Setup","slug":"trolley-setup","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1bK2HNQwLuojOTW8pVbUhv","type":"Entry","createdAt":"2020-06-12T18:32:11.783Z","updatedAt":"2020-06-12T18:32:11.783Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Support","trackParent":"Topcoder"}}],"tags":["setup ","trolley"],"creationDate":"2025-10-08","readTime":"1 min","content":"Before you can withdraw your winnings, you’ll need to complete the following three steps. Please note that you’ll have to complete them again in Trolley, even if you’ve done them before.\n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nYou will find the links for these steps on your [Wallet home](https://wallet.topcoder.com/).\n\nYou can also find links to these steps in the new payout tab of your Wallet. Note you will need to set up your withdrawal method before you can submit your tax form.\n\n![Trolley Setup Step 1](//images.ctfassets.net/piwi0eufbb2g/XHEaHqXawiHyo8Crul1nh/db3236e12c86664d8fbc574649cea3ab/Trolley_Setup_Step_1.png)\n\n### Withdrawal Method Setup\n\nYou can start setting up your withdrawal method by clicking on the ‘Add Payout Method’ button on your payout tab.\n\nYou will be asked to fill in your general information to continue. Please fill in the required details and click on next.\n\n![Trolley Setup Step 2](//images.ctfassets.net/piwi0eufbb2g/53lj3B3BdXtIdRqCqIJxlr/f52378cc323714d7910b4334a523bcea/Trolley_Setup_Step_2.png)\n\nNext you will be asked to verify your phone number. \n\n![Trolley Setup Step 3](//images.ctfassets.net/piwi0eufbb2g/4c4Q8OWYxmRkdpWVSHzsTS/ef02f690796bd9c7e873e7b1a832cbef/Trolley_Setup_Step_3.png)\n\nAfter phone number verification, you can continue setting up your payout method. Fill in your bank information and click on Save. Here is an example form for US persons.\n\n![Trolley Setup Step 4](//images.ctfassets.net/piwi0eufbb2g/2QpJlCkUfyAyglMOSs87dB/571d7bcf027891af8ddd130e407fcf15/Trolley_Setup_Step_4.png)\n\nYou have now set up your payout method successfully.\n\n![Trolley Setup Step 5](//images.ctfassets.net/piwi0eufbb2g/4t6GPaznTVfWcdFZqBKo3Z/d999e6f20f664305fa91594048e9c77d/Trolley_Setup_Step_5.png)\n\nYou will be able to add multiple payout methods and mark one of them as active. You will also be able edit or delete the payout methods.\n\n![Trolley Setup Step 6](//images.ctfassets.net/piwi0eufbb2g/1TQgyf8Wj5Md2HHLAtTzss/8a13b10395081951b4d5a1f2d011942d/Trolley_Setup_Step_6.png)\n\nIf you're a Topcoder member located outside the United States and want to receive your winnings in a USD bank account, Trolley currently requires a workaround. If you’d like to use a USD bank account (real or virtual) and you’re not based in the U.S., please contact support (support@topcoder.com) for guidance on how to set it up.\n\n### Tax form Submission and Review\n\nYou can submit your tax form by clicking on ‘Complete a Tax form Button’ from your Payout tab.\n\n![Trolley Setup Step 7](//images.ctfassets.net/piwi0eufbb2g/2sG1DG7pFg1oar9yZkAJ6S/c6086bb648ff8eea299db93d1e57cf33/Trolley_Setup_Step_7.png)\n\nContinue to fill in your details and submit your tax form. You will be required to submit either a W-8BEN form if you are a non-U.S. person or a W-9 form if you are a U.S. person.\n\n![Trolley Setup Step 8](//images.ctfassets.net/piwi0eufbb2g/2AlQp0D6lNbbFJWqBQdOAT/39d0a921188e9f8f8f197d462c1303c3/Trolley_Setup_Step_8.png)\n\nIf your tax form contains any warnings, it will remain in 'Submitted' status. If it stays for more than 1 hour in this status, we suggest you resubmit it. If your tax form is stuck in 'Submitted' status the second time, for more than 3 hours, please email support: support@topcoder.com. If your tax form is a W-9, please note that it’s reviewed and approved every Tuesday (noon EST), so it may take a few days to be approved.\n\n![Trolley Setup Step 9](//images.ctfassets.net/piwi0eufbb2g/6IEQErPjVi0N78ObYjaBPe/9dc3d021a660aff87bec2774b200b2fa/Trolley_Setup_Step_9.png)\n\nOtherwise your tax form moves to the reviewed status immediately.\n\n![Trolley Setup Step 10](//images.ctfassets.net/piwi0eufbb2g/4qFCnhGDO28n0JpE3TISJM/13f5f0e690f107d019afbeaf5c52e67f/Trolley_Setup_Step_10.png)\n\nYou can upload more than one tax form. The latest tax form will be considered and it will void all other previously submitted forms. \n\nThe tax withholding rate is based on your tax form.\n\n### ID Verification\n\nYou can complete your ID Verification by clicking on “Complete Verification” button from your Payout tab. \n\nPlease follow the instructions to verify your identity.\n\n![Trolley Setup Step 11](//images.ctfassets.net/piwi0eufbb2g/1bbX5HJTMt03zrHNNd96Fz/fd103f887673b64451f825d0076b1f66/Trolley_Setup_Step_11.png)\n\nOnce you provide the required documents and photos, your ID verification will be approved.\n\n![Trolley Setup Step 12](//images.ctfassets.net/piwi0eufbb2g/01Rg2f4I6fBxUOGv9JHP2u/6b0ad33d1b1c0ecbdf1cc99a3ecc2229/Trolley_Setup_Step_12.png)\n\nOnce the above three steps are complete you are now setup to withdraw your winnings. Your winnings will now be in available status.\n\n![Trolley Setup Step 13](//images.ctfassets.net/piwi0eufbb2g/74XAfKoEadwUOAZ4YnJ5ep/a416576daa78a9bdeef36a1c43ea9b02/Trolley_Setup_Step_13.png)\n\nIt typically takes 3–5 business days for the payment to appear in your bank account after it has been transferred.\n\nIf you have further questions please ask in the [forums](https://discussions.topcoder.com/categories/trolley-discussion) or contact [support](https://help.topcoder.com/hc/en-us/requests/new). \n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5iRr09ikoioZLtsyZV5tfA","type":"Asset","createdAt":"2020-01-06T06:26:43.766Z","updatedAt":"2023-09-29T17:34:47.881Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"locale":"en-US"},"fields":{"title":"image7","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5iRr09ikoioZLtsyZV5tfA/5a17dd83fb3e7c42c6f9ca3226b461f2/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1Q01DuPpvgTCNgCGw1B9lW","type":"Entry","createdAt":"2025-05-29T07:05:21.697Z","updatedAt":"2025-10-21T06:08:03.368Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":168,"revision":11,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Payments Are Moving to Trolley","slug":"topcoder-payments-are-moving-to-trolley","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["Payout","Trolley"],"creationDate":"2025-05-29","readTime":"10 min","content":"Starting October 21, 2025, Topcoder is switching from Payoneer & Paypal to a new global payment provider: [__Trolley__](https://trolley.com/ \"Trolley\"). This change will simplify and improve how we deliver payments to our community.\n\nTrolley offers a more modern, reliable, and flexible payout experience that better fits the needs of our global community. With Trolley, you’ll benefit from:\n- Bank transfers to 210+ countries\n- Lower overall fees compared to Payoneer\n- Simplified end-of-year tax filing\n- Easy account setup and tracking\n- Improved reporting and payout history\n- Secure and compliant (SOC 2 certified, GDPR compliant)\n\nYou don’t need to take any action right now. When the time comes, you’ll receive an email to set up your payment method via Trolley - bank.\n\n🔔 Please note: Topcoder will __stop sending payments through Payoneer and Paypal after October 21, 2025__. If you wish to withdraw through Payoneer or Paypal, be sure to withdraw any remaining  funds before then, else you will be able to transfer at a later time through bank.\n\nCheck below the FAQs and if you have any questions, feel free to ask us in the [forums](https://discussions.topcoder.com/categories/trolley-discussion \"forums\").\n\n### Frequently Asked Questions (FAQ)\n\n##### 🔄 General Transition Questions\n\n__1. Why is Topcoder switching to Trolley?__\n\nWe’re moving to Trolley to provide a more flexible, global payment solution. It supports direct bank transfers to 210+ countries, streamlines the payout process, and offers better reporting and security.\n\n__2. What happens to my existing Payoneer and PayPal accounts?__\n\nYour Payoneer and PayPal account remains yours, but Topcoder will no longer send payouts to them after October 21, 2025.\n\n__3. What will happen with my Payoneer/PayPal payments if I don’t withdraw payments by October 21st?__\n\nYou will still be able to access and withdraw your Payoneer/PayPal funds directly from your Payoneer/PayPal account after October 21st. However, Topcoder will not issue any new payments to Payoneer/PayPal after this date, so please withdraw your remaining funds beforehand.\n\n__4. What happens to my wallet account balance if I don’t withdraw by October 21st?__\n\nYour balance will remain unchanged and you can still withdraw your payment after setting up the new payment method.\n\n__5. When does the transition take effect?__\n\nThe official transition begins on October 21, 2025. After this date, all payments will be processed exclusively through Trolley.\n\n__6. Will I need to take any action to keep receiving payments?__\n\nYes. You'll need to set up your payout method to Trolley using the Topcoder Wallet application (what you use now). Instructions will be shared on October 21st.\n\n&nbsp;\n##### 🏦 Bank Transfers / Payment Methods\n\n__7. What payment methods are supported with Trolley?__\n\nTrolley supports:\n- Direct bank transfers\n\n__8. Can I receive payments to my local bank account?__\n\nYes. You can receive payments in your local currency to your domestic bank account in most countries.\n\n__9. Does Trolley support payments in my country?__\n\nTrolley supports payments in over 210 countries and territories that you can [see here](https://trolley.com/platform/global-payout-network/).\n\n__10. What currency will I receive my payment in?__\n\nTrolley defaults to your country’s local currency to ensure the fastest and most cost-effective transaction. If other currency options are available, you'll see them during your account setup.\n\n__11. Are virtual accounts (like Wise) supported?__\n\nCurrently payees are able to submit bank details to receive payouts. Trolley does not currently offer support for virtual accounts for fund withdrawal.\n\n&nbsp;\n\n##### 📝 Account Setup & Verification\n\n__12. How do I set up my Trolley account with Topcoder?__\n\nAfter October 21, 2025, you have to visit the Topcoder Wallet Application and follow the steps there. More instructions will be shared on October 21st, 2025.\n\n__13. What information will Trolley require from me?__\n\nYou will be asked for:\n- Full legal name and contact info\n- Payment method details (bank)\n- Government-issued ID\n- Tax-related forms (like W-9 or W-8BEN)\n\n&nbsp;\n\n##### 💸 Fees, Timing & Currencies\n\n__14. Are there any fees for using Trolley?__\n\nYes, depending on the payment method you choose.\n- __Bank__: there is a fixed fee of 1, 2 or 9 USD for the transfer that differs per country. They differ because the different transaction routes based on the country they are being sent to.\n\nIf you’re paid in a currency different from your bank account’s default, there is also a currency __conversion fee of 2% on top of the going market rate__. \n\n__15. What is the tax withholding rates for different countries?__\n\nTrolley calculates withholding amounts on a payment based on two variables: Info received on IRS Forms W-8 BEN or W-9, and the purpose of the payments.\n\nThe withholding rate on a payment could be:\n- 0%: If the recipient certifies they are not subject to backup withholding when they complete their initial tax form setup.\n- 24%: Backup withholding rate for W-9 recipients in the U.S. If TIN matching fails.\n- 30%: Non-resident alien withholding rate.\n\nTreaty Rate: For payments made to recipients who submit Form W-8 BEN information that indicates they are a citizen of a country that has a tax treaty with the U.S., Trolley will apply the appropriate treaty rate. You will find out what the treaty rate is for you once you set up your payment settings and answer all the questions there. \n\n__16. How long do payouts take with Trolley?__\n\nPayments will be processed on average between 3 to 5 business days, but this depends on each country.\n\n&nbsp;\n##### 📄 Tax Forms & Financial Reporting\n\n__17. Will Trolley help with year-end financial declarations?__\n\nYes. You can get your payout history (CSV or PDF) for tax or financial reporting purposes.\n\n__18. Does Trolley report taxes to local authorities across different countries? If so, where can members access proof of these reports?__\n\nTrolley enables tax reporting and compliance across multiple countries and jurisdictions, including the US (IRS 1099/1042) & the EU (DAC7). This functionality is built natively into the platform, allowing end-to-end tax automation.\n\nTrolley’s platform generates end-of-year filing files required by local authorities, such as XMLs for DAC7 in the EU, and enables e-filing with various tax agencies directly from the platform.\n\n__19. How can I access my tax statements?__\n\nWhen filling out a W-9 or W-8, recipients can choose electronic or mail delivery to receive these documents. At the end of the year Trolley sends to all recipients who requested mail delivery a printed version of the statement to the address entered on the W-9/W-8 forms. You will also receive an email with your tax statement.\n\n&nbsp;\n##### 🆘 Support & Troubleshooting\n\n__20. Who do I contact if a payment fails?__\n\nStart by contacting Topcoder support. If needed, we’ll escalate your issue to Trolley for resolution.\n\n__21. What happens if I make a mistake in my banking details?__\n\nWhen a payee enters their banking information in Trolley there is a live validation process that occurs and uses the institution and/or routing number to display the associated bank to the user. If the user were to submit incorrect bank details then the subsequent payouts would fail and the merchant would be alerted of the issue.\n\nIf you have any other questions, feel free to ask them in the [forums](https://discussions.topcoder.com/categories/trolley-discussion) or reach out to support@topcoder.com.","contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4GdVOzKYi1KQ03IV55ya2F","type":"Entry","createdAt":"2025-07-07T15:28:14.454Z","updatedAt":"2025-07-07T15:28:22.867Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":41,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder MFA Enablement Guide","slug":"topcoder-mfa-enablement-guide","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1bK2HNQwLuojOTW8pVbUhv","type":"Entry","createdAt":"2020-06-12T18:32:11.783Z","updatedAt":"2020-06-12T18:32:11.783Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Support","trackParent":"Topcoder"}}],"tags":["MFA","Setup"],"creationDate":"2025-07-07","readTime":"2 min","content":"Starting July 10, 2025 to better protect your accounts and personal data, we are now enforcing Multi-Factor Authentication (MFA) on the Topcoder platform. Setting up MFA is required before completing registration or your first login on Topcoder. This step is mandatory for both new and existing users.\n\n__Note__: Existing users will be prompted to set up MFA when they log in.\n\nDuring the sign-up process, MFA setup will be requested after the account activation is completed.\n\n### How to Set Up Your MFA\n__MFA Methods Available:__\nYou can begin setting up MFA by choosing an authenticator app, such as Google Authenticator, Authy, FreeOTP, Microsoft Authenticator or a similar option.\n\n![MFA 01](//images.ctfassets.net/piwi0eufbb2g/3e8HumSQ6l78rz5dDXLE1z/bc8ca87fb72c90ee8b5bd43d24727a40/01.png)\n\n__Google Authenticator setup:__\n\nTo set up Google Authenticator:\n\n- Select the Google Authenticator (or similar) option. \n- Scan the QR code using your preferred authenticator app.\n- Enter the one-time code generated by the app.\n\n![MFA 02](//images.ctfassets.net/piwi0eufbb2g/5lg8tOAqxSQhJCj17CsPI8/98f7acb57c238bc51e58935a4d3010f2/02.png)\n\nIf you're unable to scan the QR code, you can manually input the provided setup key into your app and then enter the one-time code generated.\n![MFA 03](//images.ctfassets.net/piwi0eufbb2g/58quEP1MGdNyZ6T98COFrG/c323b733d8a902d2a4ed24c4f33993bb/03.png)\n\nAfter successful verification, you’ll receive a __recovery code__. This can be used to log in when your device is unavailable. Be sure to save it somewhere safe. \n\n*Please note: a new recovery code is generated each time one is used.*\n\n![MFA 04](//images.ctfassets.net/piwi0eufbb2g/3IrpIITTO9dTAO88jmZuHd/00063ca9bd11bc7ef653756661af40bc/04.png)\n\nYou’ll also be asked whether you’d like to enable __quick login__ using the current device’s fingerprint or face recognition. If you trust the device, you can accept this option. Alternatively, you may choose __Remind Me Later__ or __Not on This Device__.\n![MFA 05](//images.ctfassets.net/piwi0eufbb2g/v7PnAsU33T6aEQDpxnSoh/4f386333d530a275bbd572f42be4c694/05.png)\n\nIf you proceed with biometric login, you can log in using your fingerprint or face recognition instead of the one-time code in future sessions.\n\nMFA setup is now complete!\n\n__Login Methods After MFA Setup:__\n\nOnce MFA is set up, you can log in using any of the following methods:\n- Google Authenticator (or similar app)\n- Email\n- Recovery code\n- Fingerprint or Face Recognition. (if previously enabled)\n\n![MFA 06](//images.ctfassets.net/piwi0eufbb2g/2ZSJgMWd4q20wg0V3PTODa/67e50e6f36cf66f504fd990120af1541/06.png)\n\n### Why MFA Matters\nEnabling MFA helps protect your account even if your password is compromised. With this added layer of security, you can participate in challenges and access your data with greater peace of mind.\n\nIf you have any questions or need help setting up MFA, reach out to us support@topcoder.com.","contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4aFVL8lFVxQeT2Ey3AMLjy","type":"Entry","createdAt":"2019-12-28T15:05:40.149Z","updatedAt":"2025-06-17T12:45:02.967Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":50,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot Playbook","slug":"copilot-playbook","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4EXetae4afYR3PFbx2CXsd","type":"Entry","createdAt":"2020-02-26T22:21:38.743Z","updatedAt":"2020-02-26T22:21:38.743Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":47,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Challenge Operations","trackParent":"Topcoder","description":"All Challenge operations documentation."}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"l66ifjfnjwZSmYwRdlOID","type":"Entry","createdAt":"2020-01-09T21:49:28.808Z","updatedAt":"2020-01-09T21:49:28.808Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":17,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Copilot","trackParent":"Topcoder","description":"Copilot documentation."}}],"tags":["Members Roles","Copilot","challenge"],"creationDate":"2018-02-20","readTime":"10 min read","content":"Topcoder Copilots work with customers of Topcoder to deliver results using the Topcoder Community. \n\nIf you've earned your way to becoming a copilot, then there are a few things you should know.  Ok, maybe more than a few...\n\n1. Congratulations!  Being a Topcoder Copilot is a very exclusive role and gives you a lot of opportunities to grow your career.\n\n2. We expect Copilots to act as representatives of Topcoder when working with the Topcoder Community and customers.\n\n3. Copilots must stay current with the latest processes/rules/etc. on the Topcoder Platform.\n\n4. __For detailed information and a complete Copilot Playbook, please view__ <https://docs.google.com/document/d/1g9HnJiL3uPNJ6_6P1gimrXj_Ycdn3aitq0OmkBwzJXI/edit#heading=h.ggbn3yyrrvi6>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2o5VKQl5ByP5eKOvL8FmRm","type":"Entry","createdAt":"2019-12-28T15:05:42.061Z","updatedAt":"2025-06-17T12:45:00.087Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":204,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot & Reviewer Certification Program","slug":"copilot-and-reviewer-certification-program","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-06-08","readTime":"5 min read","content":"### Certification Program in Progress\nWe’ve been hard at work designing and developing a new certification program for community member roles (like copilots and reviewers) over the last few months. With the majority of planning work behind us, we’ll be rolling out the infrastructure to support this new training and certification program over the next few months.\n\n### Goals of the Certification Program\nWe love our global community, so much so that we want you to be part of our team, working alongside us to help crowdsourcing challenges go as smoothly as possible and yield amazing results. In order to do that, we need to select the right sherpas and give them the guidance and feedback to help them understand the advanced roles of copilots and reviewers across the various tracks. The goal of our certification program is to provide clear expectations of these roles and responsibilities for copilots and reviewers and ensure that those entrusted to these positions continue to maintain the high level of quality associated with Topcoder. \n\n### Roles Included in the Program\nOur different tracks have different needs from copilots and reviewers, so we have custom tailored the roles within each track. Each certification is separate and distinct, and you should check the details for each role to see the specifics of the job as well as the description of the minimally qualified candidate. Currently, our program includes:\n\n__Design Track:__\n\n- Design Copilot\n- Design Screener\n- Design Spec Reviewer\n\n__Development Track:__\n\n- Copilot\n- Code Reviewer\n- Spec Reviewer\n\n__Data Science Track:__\n\n- Data Science Sprint Copilot\n- Data Science Marathon Copilot\n- Data Science Marathon Tester\n\nIn addition to these track-specific roles, we also have an additional advanced copilot role that requires the ability to provide a higher level of customer interaction. This role is only open to those who already have obtained at least one of the track-specific copilot certifications:\n\n- Project Copilot \n\n### Applying for a Certified Position\n#### Eligibility\nEach role has a set of minimum eligibility requirements that must be attained before applying for the role. Please make sure that you meet these requirements before completing an application for a given role. These requirements can be found on the individual role descriptions.\n\n#### Copilot Application\nThe application for each role gives you an opportunity to describe some of your qualifications and the way you would approach the role. You will be evaluated on both the content of your answers as well as your written English skills which will be required for clear communications with the community and our customers. It is expected that the application consists of responses written solely by you without review or input from others. \n\nThe application will be evaluated by Topcoder team members. In order for you to progress to to the next stage you must be a good fit for the role and there must be a need for us to take on another person into the position. In the case that you are found to be qualified but there is no need for further members in that role, we will wait until there is a need before moving you on to the next phase.\n\n[Apply to be a Copilot](https://forms.gle/U2NX1ReZpgMsmF1X7)\n\n<iframe src=\"https://docs.google.com/forms/d/e/1FAIpQLScLM97dnna0HpSaG6pVQtFjQRZHc5KAAwRdLp70oJtYkZVFGg/viewform?embedded=true\" width=\"640\" height=\"3500\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\">Loading…</iframe>\n\n#### Reviewer Application\nThe review position is one that is earned by being a successful competitor.  We are currently revising the eligibility rules and will update them here soon.  If you qualify to be a reviewer, you will receive and email automatically inviting you to the review board. It is your choice at that point to accept. In order to remain on the review board, you must maintain your qualifications by continuing to compete.\n\n### Training Program\nEach role has a unique set of training materials, consisting of documents and videos created by Topcoder experts. As you move through this phase, pay close attention to which materials are required and which may be optional. It is your responsibility to complete these in a timely manner. Note that if you are a candidate for multiple roles, there may be some duplicate items across your training plans which you can skip if you have already completed them previously.\n\n### Written Exam\nMost of the roles also have a written exam that is designed to help simulate the work you will do in the role before you have to do it in front of a customer. For copilots, these usually involve writing challenge specifications (or “specs”), estimating budget and timeline, and providing strategic feedback to the customer. For reviewers, these usually involve providing reviewer feedback based on sample work.\n\nThese exams are not designed to test your knowledge of obscure Topcoder policy details. They are not designed to trick you. They are designed to give you practice at a portion of what a big part of your job will be should you pass and be placed in the role. It is expected that the work submitted for these exams is completely and solely the work of you, the candidate, without influence or input from anyone else. \n\n### Phone Interview\nOnly one roll, the Project Copilot, will require the member to have verbal communication with the customer. Because this job requirement is so specific, we will be requiring a short phone interview with the Project Copilot candidates to hear how they would respond to specific customer interactions. Excellent English speaking skills are a prerequisite for this role. \n\n### Observation Evaluation\nAfter completing all of the above, you will be ready to try out the role with an actual customer challenge in the community. At this point in the certification process, you will be assigned a Topcoder expert to evaluate you in action as you work with this customer challenge. This expert will evaluate you in various areas as they apply to your specific role, including:\n\n- Topcoder Standards & Processes\n- Customer Management\n- Community Management\n- Technical Skills\n- Communication & Professionalism\n\nIf you pass this evaluation you will officially be certified and can continue to work in this role on customer challenges. Congrats! If you put in a substantial effort but didn’t quite meet the standards, your expert may allow you to retry the observation run after providing you with some mentoring on how to improve.\n\n### Ongoing Performance\n#### Ongoing Metrics\nEach role has specific metrics that we look at to make sure things are going smoothly for the members performing those specific roles. Usually, these are around delivery of materials on time, challenge fulfillment, and satisfaction survey results. If we start to notice a degradation in your performance you may be warned and possibly put on probation. Failure to make a positive change will result in the loss of your certification status.\n\n#### Ongoing Training\nAs we grow the training program, we may add additional documents or modules that you will be required to complete in a timely manner in order to maintain your certification status. Failure to complete assigned modules will result in the loss of your certification status. \n\n#### Good standing\nAs a representative of the Topcoder brand, we expect you to lead by example within the community and maintain a positive and constructive relationship both with Topcoder employees as well as other members of the community. This applies to all interactions including (but not limited to): review feedback, customer interactions, forum posts, and emails. Failure to do so will result in the loss of your certification status.\n\n### Existing Members in These Roles\nAll members filling these roles will need to be certified. As we roll out this program, we acknowledge that there will be a transitionary time and hope to move through the process of certifying our existing members quickly. \n\nThe process may be slightly adjusted at the discretion of the Topcoder certification program leads for existing members who have been performing well in their roles for while in the following ways: \n\n- Certain training modules may be deemed optional\n- Written exams may be replaced with looking at previous challenge work that applies to the same function","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7wTYn5b5dSXJnSR7DDKJuQ","type":"Entry","createdAt":"2019-12-28T15:05:40.169Z","updatedAt":"2021-12-02T14:55:43.939Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":48,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot Incentives","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-09-03","readTime":"5 min read","content":"Copilots earn money by delivering outcomes/deliverables for their projects on time, with high quality, and consistent with Topcoder best practices.\n\nCurrently, Copilots are mainly paid based on the completion of successful challenges and tasks they run.  Unless otherwise noted, the standard payments are as follows:\n\n| Work Type                         | Payment (per challenge) |\n|-----------------------------------|-------------------------|\n| First 2 Finish Challenges         | $40                     |\n| Design and Development Challenges | $600                    |\n| Marathon Matches                  | TBD                     |\n\n\n__Note:__ Check back here often for changes.  Topcoder will look to optimize incentive structures to promote the best structure for copilots, the community, and customers.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"4aFVL8lFVxQeT2Ey3AMLjy","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"2o5VKQl5ByP5eKOvL8FmRm","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"69QWg34X48uW84YNiWtUaS"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7wTYn5b5dSXJnSR7DDKJuQ","type":"Entry","createdAt":"2019-12-28T15:05:40.169Z","updatedAt":"2021-12-02T14:55:43.939Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":48,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot Incentives","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-09-03","readTime":"5 min read","content":"Copilots earn money by delivering outcomes/deliverables for their projects on time, with high quality, and consistent with Topcoder best practices.\n\nCurrently, Copilots are mainly paid based on the completion of successful challenges and tasks they run.  Unless otherwise noted, the standard payments are as follows:\n\n| Work Type                         | Payment (per challenge) |\n|-----------------------------------|-------------------------|\n| First 2 Finish Challenges         | $40                     |\n| Design and Development Challenges | $600                    |\n| Marathon Matches                  | TBD                     |\n\n\n__Note:__ Check back here often for changes.  Topcoder will look to optimize incentive structures to promote the best structure for copilots, the community, and customers.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"4aFVL8lFVxQeT2Ey3AMLjy","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2o5VKQl5ByP5eKOvL8FmRm","type":"Entry","createdAt":"2019-12-28T15:05:42.061Z","updatedAt":"2025-06-17T12:45:00.087Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":204,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot & Reviewer Certification Program","slug":"copilot-and-reviewer-certification-program","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-06-08","readTime":"5 min read","content":"### Certification Program in Progress\nWe’ve been hard at work designing and developing a new certification program for community member roles (like copilots and reviewers) over the last few months. With the majority of planning work behind us, we’ll be rolling out the infrastructure to support this new training and certification program over the next few months.\n\n### Goals of the Certification Program\nWe love our global community, so much so that we want you to be part of our team, working alongside us to help crowdsourcing challenges go as smoothly as possible and yield amazing results. In order to do that, we need to select the right sherpas and give them the guidance and feedback to help them understand the advanced roles of copilots and reviewers across the various tracks. The goal of our certification program is to provide clear expectations of these roles and responsibilities for copilots and reviewers and ensure that those entrusted to these positions continue to maintain the high level of quality associated with Topcoder. \n\n### Roles Included in the Program\nOur different tracks have different needs from copilots and reviewers, so we have custom tailored the roles within each track. Each certification is separate and distinct, and you should check the details for each role to see the specifics of the job as well as the description of the minimally qualified candidate. Currently, our program includes:\n\n__Design Track:__\n\n- Design Copilot\n- Design Screener\n- Design Spec Reviewer\n\n__Development Track:__\n\n- Copilot\n- Code Reviewer\n- Spec Reviewer\n\n__Data Science Track:__\n\n- Data Science Sprint Copilot\n- Data Science Marathon Copilot\n- Data Science Marathon Tester\n\nIn addition to these track-specific roles, we also have an additional advanced copilot role that requires the ability to provide a higher level of customer interaction. This role is only open to those who already have obtained at least one of the track-specific copilot certifications:\n\n- Project Copilot \n\n### Applying for a Certified Position\n#### Eligibility\nEach role has a set of minimum eligibility requirements that must be attained before applying for the role. Please make sure that you meet these requirements before completing an application for a given role. These requirements can be found on the individual role descriptions.\n\n#### Copilot Application\nThe application for each role gives you an opportunity to describe some of your qualifications and the way you would approach the role. You will be evaluated on both the content of your answers as well as your written English skills which will be required for clear communications with the community and our customers. It is expected that the application consists of responses written solely by you without review or input from others. \n\nThe application will be evaluated by Topcoder team members. In order for you to progress to to the next stage you must be a good fit for the role and there must be a need for us to take on another person into the position. In the case that you are found to be qualified but there is no need for further members in that role, we will wait until there is a need before moving you on to the next phase.\n\n[Apply to be a Copilot](https://forms.gle/U2NX1ReZpgMsmF1X7)\n\n<iframe src=\"https://docs.google.com/forms/d/e/1FAIpQLScLM97dnna0HpSaG6pVQtFjQRZHc5KAAwRdLp70oJtYkZVFGg/viewform?embedded=true\" width=\"640\" height=\"3500\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\">Loading…</iframe>\n\n#### Reviewer Application\nThe review position is one that is earned by being a successful competitor.  We are currently revising the eligibility rules and will update them here soon.  If you qualify to be a reviewer, you will receive and email automatically inviting you to the review board. It is your choice at that point to accept. In order to remain on the review board, you must maintain your qualifications by continuing to compete.\n\n### Training Program\nEach role has a unique set of training materials, consisting of documents and videos created by Topcoder experts. As you move through this phase, pay close attention to which materials are required and which may be optional. It is your responsibility to complete these in a timely manner. Note that if you are a candidate for multiple roles, there may be some duplicate items across your training plans which you can skip if you have already completed them previously.\n\n### Written Exam\nMost of the roles also have a written exam that is designed to help simulate the work you will do in the role before you have to do it in front of a customer. For copilots, these usually involve writing challenge specifications (or “specs”), estimating budget and timeline, and providing strategic feedback to the customer. For reviewers, these usually involve providing reviewer feedback based on sample work.\n\nThese exams are not designed to test your knowledge of obscure Topcoder policy details. They are not designed to trick you. They are designed to give you practice at a portion of what a big part of your job will be should you pass and be placed in the role. It is expected that the work submitted for these exams is completely and solely the work of you, the candidate, without influence or input from anyone else. \n\n### Phone Interview\nOnly one roll, the Project Copilot, will require the member to have verbal communication with the customer. Because this job requirement is so specific, we will be requiring a short phone interview with the Project Copilot candidates to hear how they would respond to specific customer interactions. Excellent English speaking skills are a prerequisite for this role. \n\n### Observation Evaluation\nAfter completing all of the above, you will be ready to try out the role with an actual customer challenge in the community. At this point in the certification process, you will be assigned a Topcoder expert to evaluate you in action as you work with this customer challenge. This expert will evaluate you in various areas as they apply to your specific role, including:\n\n- Topcoder Standards & Processes\n- Customer Management\n- Community Management\n- Technical Skills\n- Communication & Professionalism\n\nIf you pass this evaluation you will officially be certified and can continue to work in this role on customer challenges. Congrats! If you put in a substantial effort but didn’t quite meet the standards, your expert may allow you to retry the observation run after providing you with some mentoring on how to improve.\n\n### Ongoing Performance\n#### Ongoing Metrics\nEach role has specific metrics that we look at to make sure things are going smoothly for the members performing those specific roles. Usually, these are around delivery of materials on time, challenge fulfillment, and satisfaction survey results. If we start to notice a degradation in your performance you may be warned and possibly put on probation. Failure to make a positive change will result in the loss of your certification status.\n\n#### Ongoing Training\nAs we grow the training program, we may add additional documents or modules that you will be required to complete in a timely manner in order to maintain your certification status. Failure to complete assigned modules will result in the loss of your certification status. \n\n#### Good standing\nAs a representative of the Topcoder brand, we expect you to lead by example within the community and maintain a positive and constructive relationship both with Topcoder employees as well as other members of the community. This applies to all interactions including (but not limited to): review feedback, customer interactions, forum posts, and emails. Failure to do so will result in the loss of your certification status.\n\n### Existing Members in These Roles\nAll members filling these roles will need to be certified. As we roll out this program, we acknowledge that there will be a transitionary time and hope to move through the process of certifying our existing members quickly. \n\nThe process may be slightly adjusted at the discretion of the Topcoder certification program leads for existing members who have been performing well in their roles for while in the following ways: \n\n- Certain training modules may be deemed optional\n- Written exams may be replaced with looking at previous challenge work that applies to the same function","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":1,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7wTYn5b5dSXJnSR7DDKJuQ","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"69QWg34X48uW84YNiWtUaS"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2o5VKQl5ByP5eKOvL8FmRm","type":"Entry","createdAt":"2019-12-28T15:05:42.061Z","updatedAt":"2025-06-17T12:45:00.087Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":204,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot & Reviewer Certification Program","slug":"copilot-and-reviewer-certification-program","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-06-08","readTime":"5 min read","content":"### Certification Program in Progress\nWe’ve been hard at work designing and developing a new certification program for community member roles (like copilots and reviewers) over the last few months. With the majority of planning work behind us, we’ll be rolling out the infrastructure to support this new training and certification program over the next few months.\n\n### Goals of the Certification Program\nWe love our global community, so much so that we want you to be part of our team, working alongside us to help crowdsourcing challenges go as smoothly as possible and yield amazing results. In order to do that, we need to select the right sherpas and give them the guidance and feedback to help them understand the advanced roles of copilots and reviewers across the various tracks. The goal of our certification program is to provide clear expectations of these roles and responsibilities for copilots and reviewers and ensure that those entrusted to these positions continue to maintain the high level of quality associated with Topcoder. \n\n### Roles Included in the Program\nOur different tracks have different needs from copilots and reviewers, so we have custom tailored the roles within each track. Each certification is separate and distinct, and you should check the details for each role to see the specifics of the job as well as the description of the minimally qualified candidate. Currently, our program includes:\n\n__Design Track:__\n\n- Design Copilot\n- Design Screener\n- Design Spec Reviewer\n\n__Development Track:__\n\n- Copilot\n- Code Reviewer\n- Spec Reviewer\n\n__Data Science Track:__\n\n- Data Science Sprint Copilot\n- Data Science Marathon Copilot\n- Data Science Marathon Tester\n\nIn addition to these track-specific roles, we also have an additional advanced copilot role that requires the ability to provide a higher level of customer interaction. This role is only open to those who already have obtained at least one of the track-specific copilot certifications:\n\n- Project Copilot \n\n### Applying for a Certified Position\n#### Eligibility\nEach role has a set of minimum eligibility requirements that must be attained before applying for the role. Please make sure that you meet these requirements before completing an application for a given role. These requirements can be found on the individual role descriptions.\n\n#### Copilot Application\nThe application for each role gives you an opportunity to describe some of your qualifications and the way you would approach the role. You will be evaluated on both the content of your answers as well as your written English skills which will be required for clear communications with the community and our customers. It is expected that the application consists of responses written solely by you without review or input from others. \n\nThe application will be evaluated by Topcoder team members. In order for you to progress to to the next stage you must be a good fit for the role and there must be a need for us to take on another person into the position. In the case that you are found to be qualified but there is no need for further members in that role, we will wait until there is a need before moving you on to the next phase.\n\n[Apply to be a Copilot](https://forms.gle/U2NX1ReZpgMsmF1X7)\n\n<iframe src=\"https://docs.google.com/forms/d/e/1FAIpQLScLM97dnna0HpSaG6pVQtFjQRZHc5KAAwRdLp70oJtYkZVFGg/viewform?embedded=true\" width=\"640\" height=\"3500\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\">Loading…</iframe>\n\n#### Reviewer Application\nThe review position is one that is earned by being a successful competitor.  We are currently revising the eligibility rules and will update them here soon.  If you qualify to be a reviewer, you will receive and email automatically inviting you to the review board. It is your choice at that point to accept. In order to remain on the review board, you must maintain your qualifications by continuing to compete.\n\n### Training Program\nEach role has a unique set of training materials, consisting of documents and videos created by Topcoder experts. As you move through this phase, pay close attention to which materials are required and which may be optional. It is your responsibility to complete these in a timely manner. Note that if you are a candidate for multiple roles, there may be some duplicate items across your training plans which you can skip if you have already completed them previously.\n\n### Written Exam\nMost of the roles also have a written exam that is designed to help simulate the work you will do in the role before you have to do it in front of a customer. For copilots, these usually involve writing challenge specifications (or “specs”), estimating budget and timeline, and providing strategic feedback to the customer. For reviewers, these usually involve providing reviewer feedback based on sample work.\n\nThese exams are not designed to test your knowledge of obscure Topcoder policy details. They are not designed to trick you. They are designed to give you practice at a portion of what a big part of your job will be should you pass and be placed in the role. It is expected that the work submitted for these exams is completely and solely the work of you, the candidate, without influence or input from anyone else. \n\n### Phone Interview\nOnly one roll, the Project Copilot, will require the member to have verbal communication with the customer. Because this job requirement is so specific, we will be requiring a short phone interview with the Project Copilot candidates to hear how they would respond to specific customer interactions. Excellent English speaking skills are a prerequisite for this role. \n\n### Observation Evaluation\nAfter completing all of the above, you will be ready to try out the role with an actual customer challenge in the community. At this point in the certification process, you will be assigned a Topcoder expert to evaluate you in action as you work with this customer challenge. This expert will evaluate you in various areas as they apply to your specific role, including:\n\n- Topcoder Standards & Processes\n- Customer Management\n- Community Management\n- Technical Skills\n- Communication & Professionalism\n\nIf you pass this evaluation you will officially be certified and can continue to work in this role on customer challenges. Congrats! If you put in a substantial effort but didn’t quite meet the standards, your expert may allow you to retry the observation run after providing you with some mentoring on how to improve.\n\n### Ongoing Performance\n#### Ongoing Metrics\nEach role has specific metrics that we look at to make sure things are going smoothly for the members performing those specific roles. Usually, these are around delivery of materials on time, challenge fulfillment, and satisfaction survey results. If we start to notice a degradation in your performance you may be warned and possibly put on probation. Failure to make a positive change will result in the loss of your certification status.\n\n#### Ongoing Training\nAs we grow the training program, we may add additional documents or modules that you will be required to complete in a timely manner in order to maintain your certification status. Failure to complete assigned modules will result in the loss of your certification status. \n\n#### Good standing\nAs a representative of the Topcoder brand, we expect you to lead by example within the community and maintain a positive and constructive relationship both with Topcoder employees as well as other members of the community. This applies to all interactions including (but not limited to): review feedback, customer interactions, forum posts, and emails. Failure to do so will result in the loss of your certification status.\n\n### Existing Members in These Roles\nAll members filling these roles will need to be certified. As we roll out this program, we acknowledge that there will be a transitionary time and hope to move through the process of certifying our existing members quickly. \n\nThe process may be slightly adjusted at the discretion of the Topcoder certification program leads for existing members who have been performing well in their roles for while in the following ways: \n\n- Certain training modules may be deemed optional\n- Written exams may be replaced with looking at previous challenge work that applies to the same function","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7wTYn5b5dSXJnSR7DDKJuQ","type":"Entry","createdAt":"2019-12-28T15:05:40.169Z","updatedAt":"2021-12-02T14:55:43.939Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":48,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot Incentives","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-09-03","readTime":"5 min read","content":"Copilots earn money by delivering outcomes/deliverables for their projects on time, with high quality, and consistent with Topcoder best practices.\n\nCurrently, Copilots are mainly paid based on the completion of successful challenges and tasks they run.  Unless otherwise noted, the standard payments are as follows:\n\n| Work Type                         | Payment (per challenge) |\n|-----------------------------------|-------------------------|\n| First 2 Finish Challenges         | $40                     |\n| Design and Development Challenges | $600                    |\n| Marathon Matches                  | TBD                     |\n\n\n__Note:__ Check back here often for changes.  Topcoder will look to optimize incentive structures to promote the best structure for copilots, the community, and customers.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4aFVL8lFVxQeT2Ey3AMLjy","type":"Entry","createdAt":"2019-12-28T15:05:40.149Z","updatedAt":"2025-06-17T12:45:02.967Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":50,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot Playbook","slug":"copilot-playbook","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4EXetae4afYR3PFbx2CXsd","type":"Entry","createdAt":"2020-02-26T22:21:38.743Z","updatedAt":"2020-02-26T22:21:38.743Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":47,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Challenge Operations","trackParent":"Topcoder","description":"All Challenge operations documentation."}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"l66ifjfnjwZSmYwRdlOID","type":"Entry","createdAt":"2020-01-09T21:49:28.808Z","updatedAt":"2020-01-09T21:49:28.808Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":17,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Copilot","trackParent":"Topcoder","description":"Copilot documentation."}}],"tags":["Members Roles","Copilot","challenge"],"creationDate":"2018-02-20","readTime":"10 min read","content":"Topcoder Copilots work with customers of Topcoder to deliver results using the Topcoder Community. \n\nIf you've earned your way to becoming a copilot, then there are a few things you should know.  Ok, maybe more than a few...\n\n1. Congratulations!  Being a Topcoder Copilot is a very exclusive role and gives you a lot of opportunities to grow your career.\n\n2. We expect Copilots to act as representatives of Topcoder when working with the Topcoder Community and customers.\n\n3. Copilots must stay current with the latest processes/rules/etc. on the Topcoder Platform.\n\n4. __For detailed information and a complete Copilot Playbook, please view__ <https://docs.google.com/document/d/1g9HnJiL3uPNJ6_6P1gimrXj_Ycdn3aitq0OmkBwzJXI/edit#heading=h.ggbn3yyrrvi6>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2o5VKQl5ByP5eKOvL8FmRm","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"7wTYn5b5dSXJnSR7DDKJuQ","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"2o5VKQl5ByP5eKOvL8FmRm","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"69QWg34X48uW84YNiWtUaS"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sSpJuiQ8BWfn1lCb4Ggel","type":"Entry","createdAt":"2020-02-25T10:22:21.738Z","updatedAt":"2025-04-03T15:29:59.915Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":707,"revision":37,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in a Topcoder Marathon Match","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["Marathon Match","C#","C++","JAVA","Data Science"],"creationDate":"2020-02-25","readTime":"25 min","content":"### Contents\n- <AnchorLink href=\"#1\"><span>Beginning a Match</span></AnchorLink>\n- <AnchorLink href=\"#2\">The Problem Statement</AnchorLink>\n- <AnchorLink href=\"#3\">Submitting to the Match</AnchorLink>\n<ul style=\"margin-bottom:0\"><li><AnchorLink href=\"#31\">Code Without Docker File</AnchorLink></li><li><AnchorLink href=\"#32\">Code Only</AnchorLink></li><li><AnchorLink href=\"#33\">Data and Code</AnchorLink></li></ul>\n- <AnchorLink href=\"#4\">Notification Emails</AnchorLink>\n- <AnchorLink href=\"#5\">Accessing Submissions and Artifacts</AnchorLink>\n- <AnchorLink href=\"#6\">After The Match</AnchorLink>\n- <AnchorLink href=\"#7\">Other Details for Code Without Docker</AnchorLink>\n  - <AnchorLink href=\"#71\">Submission Queue</AnchorLink>\n  - <AnchorLink href=\"#73\">Compile Logs, Example Test Case Scores, Run Time and Standard Error Output</AnchorLink>\n  - <AnchorLink href=\"#74\">Compile and Execution Commands</AnchorLink>\n  - <AnchorLink href=\"#75\">Processing Server Specifications</AnchorLink>\n<ul style=\"margin-bottom:0\"><li><AnchorLink href=\"#75\">Server and Docker Configuration</AnchorLink></li><li><AnchorLink href=\"#76\">C++ Compiler Version Details</AnchorLink></li><li><AnchorLink href=\"#77\">C# - Mono JIT compiler version</AnchorLink></li><li><AnchorLink href=\"#78\">Java Compiler Version Details</AnchorLink></li><li><AnchorLink href=\"#79\">Python Version</AnchorLink></li></ul>\n  - <AnchorLink href=\"#80\">Setup Local Environment Similar to Tester Machine</AnchorLink>\n  - <AnchorLink href=\"#81\">Multithreading</AnchorLink>\n\n<a id=\"1\"></a>\n### Beginning a Match\nYou should first start off by visiting the [Topcoder Events Calendar](https://www.topcoder.com/community/events) to find out when the next Marathon Match will be taking place.\n\nIn order to start that match, visit the [Marathon Challenge Listings Page](https://www.topcoder.com/challenges?tracks[DS]=true), which will show you all current and active competitions where you can view the start/end date of each match, the number of competitors (people who submitted at least once), registrants (people who registered, regardless of whether they submitted or not), and the total number of submissions per competitor.\n\n![Marathon Match](//images.ctfassets.net/piwi0eufbb2g/7rclZqlP6OYHQJwu1iwSlL/d4b4945ae171b08994e06d0e036cf492/Challenge.png)\n\nYou can start by clicking on a contest that will take you to the Match Details page, which includes an overview of the competition and its deadline.\n<a id=\"2\"></a>\n### The Problem Statement\nAfter you have registered for the match, you will then want to make sure you are on the \"DETAILS\" tab.\n\nIt is here that you can read the problem, know what the task is, how the scoring works, how to submit, and whether you’ll implement a function and submit code to be run and evaluated on the Topcoder servers or submit a list of answers (most likely a csv file) to be evaluated. This page may include examples for the desired output, an offline tester/visualizer to check your submissions locally, information about the prizes (if available), and links to the data (if any).\n\nIf you feel like something may be unclear in the problem statement, don’t hesitate to go to the challenge forum and ask there. The forum includes announcements, questions, and discussions about the match.\n\nWhen you feel like you fully understand the problem at hand, it is time to start coding!\n<a id=\"3\"></a>\n### Submitting to the Match\nThere are three types of submission formats:\n<a id=\"31\"></a>\n#### Code Without Docker File\nIn this submission format we have a standard Docker File and you are only required to submit the code file. More information about compilation is available below in the section Other Details About Code Without Docker.\n\nYour submission should be a single ZIP file with the following content:\n`<your code>`\n\ne.g.\n`SnakeCharmer.cpp`\n\nwhere SnakeCharmer is the ClassName which is defined in the problem statement.\n\nYou can download an example solution, and zip it to submit. \n\n![image1](//images.ctfassets.net/piwi0eufbb2g/4Bv0O5l2YOUo7wIpfJRDsr/c11784bf0d346ed594c8b26188c2447a/image1.png)\n<a id=\"32\"></a>\n#### Code Only\nYour submission should be a single ZIP file with the following content:\n```\n/code\n   Dockerfile\n   flags.txt // optional\n   <your code>\n```\nThe /code directory should contain a dockerized version of your system that will be used to generate your algorithm's output in both testing phases (provisional and final) in a well defined and standardized way. This folder must contain a Dockerfile that will be used to build a docker container that will host your system. How you organize the rest of the contents of the /code folder is up to you.\ne.g. [Sample](https://github.com/topcoder-platform-templates/marathon-code-only#a-sample-challenge) of Code only\n<a id=\"33\"></a>\n#### Data and Code\nYour submission should be a single ZIP file with the following content:\n```\n/solution\n   solution.csv\n/code\n   Dockerfile\n   flags.txt // optional\n   <your code>\n```\nThe file /solution/solution.csv is the output your algorithm generates on the provisional test set. The format of this file will be described in the challenge specification.\n\nThe /code directory should contain a dockerized version of your system that will be used to reproduce your results in a well defined and standardized way. This folder must contain a Dockerfile that will be used to build a docker container that will host your system during final testing. How you organize the rest of the contents of the /code folder is up to you.\n\ne.g. [Sample](https://github.com/topcoder-platform-templates/marathon-data-and-code#a-sample-challenge) of Data and Code\n\nWhen you finish the task, review the submission instructions in the problem statement and make your submission. You can submit by clicking the \"Submit\" button on the Challenge Details page, picking a file and choosing “I UNDERSTAND AND AGREE”.\n\n![Buttons](//images.ctfassets.net/piwi0eufbb2g/47RonnCn0it9QddKLSEWfG/3cb1d5c25a7fc52f5aee5e45e4efa228/Buttons.png)\n\n![Submit action](//images.ctfassets.net/piwi0eufbb2g/2sjlldBFClR50xcYwL886q/50ef22a4ce8544444f5ca6737b7e6199/Submit_action.png)\n\n<a id=\"4\"></a>\n### Notification Emails\nAfter submitting your solution, you will receive four emails:\n- Notification - Thanks for submitting.\n- Virus Scan - Review Score\n  - A score of 100 means your submission has no viruses or any files with potential threat and is now being forwarded to run on Example Test Cases.\n- Example Test Case Scoring (Only in the case of Code Without Docker File)\n  - A score of 1.0 means your submission has executed in the example test cases and now has moved to the queue for running on provisional test cases.\n- Provisional Test Case Scoring (may take up to 20 minutes because there are 100 provisional cases)\n\n<a id=\"5\"></a>\n### Accessing Submissions and Artifacts\nYou can access your submissions and example results (artifacts) via the “My Submissions” Tab on the Challenge Page.\n\n![artifacts](//images.ctfassets.net/piwi0eufbb2g/6y93VpUscmGnclQuxDho4I/9fbfd62f8b47ac0c8b8f859b1df96619/artifacts.png)\n\nHere you have a few choices:\n- You can download your submission.\n- You can download your submission’s artifacts.\n- You can view more details about your submission.\n\nAfter making your first verified submission, your score will be shown on the standings page along with how many submissions you’ve executed and your current rank on the leaderboard. The standings page shows every competitor’s score and rank, so you are aware of how well your solution performed against others.\n<a id=\"6\"></a>\n### After The Match\nWhen the match ends, your code/submission will be evaluated against other test cases to see how well it performed.\n\nScoring can be either relative or absolute. In relative scoring, the result of your solution is compared to the best score achieved on each case. This also means that a strong solution can affect the score of other solutions. In absolute scoring, the result of your solution is compared to some fixed value, and does not affect the score of other solutions.\n\nWhen the competition ends and the final results are available, you will be able to view both the system and provisional ranking.\n\n<a id=\"7\"></a>\n### Other Details for Code Without Docker\n<a id=\"71\"></a>\n#### Submission Queue\nYour submission will first run on a separate machine getting the example test case output to you as soon as possible. The leaderboard will display your score as a 1.0. \n\nOn the main leaderboard if you see a score of 1, that means that the submission is in queue, which also means that the example test case has been executed and now the provisional test cases are running. This means that if you see five members with a score of 1, it means five submissions are in queue. After the provisional phase tests are executed, the score will be replaced by the official score of that submission.\n\n![image](//images.ctfassets.net/piwi0eufbb2g/36RXJuZUqYXl9gGUBSoq1N/e059a9b2c3fdb602da069479c7896257/image.png)\n\n<a id=\"73\"></a>\n#### Compile Logs, Example Test Case Scores, Run Time and Standard Error Output\nWhen you make a submission, it first runs against example test cases on a dedicated machine for speed.\n\nOnce that is completed, your submission will be added to the queue on a machine dedicated for running submissions against provisional test cases. \n\nYou will receive an email with the text:\n\n*The following review(s) were performed:\nMarathon Match Review - Example\nThe score applied to your submission is 1.*\n\nA score of 1.0 indicates a successful run of your submission against the example test cases. The match \nleaderboard will also display your score as 1.0 until the results of the provisional test cases are returned.\n\nIf you go to the “My Submissions” tab you will be able to see your solution’s output as soon as the testing is complete. You can find your scores, runtime, and stderr output in the output.txt file, which you can find by unzipping the downloaded artifacts file.\n\n![image](//images.ctfassets.net/piwi0eufbb2g/1DEyD1CR8pJT9PjDpzX40e/24769d079f2f49b4db5159f84385f1a4/image.png)\n<a id=\"74\"></a>\n#### Compile and Execution Commands\n\nYour code will be built and executed with the fixed set of commands as follows:\n\nC++\n```\ng++ -std=gnu++11 -O3 /workdir/<FileName>.cpp -o /workdir/<FileName>.cpp\n/workdir/<FileName>\n```\n\nJava\n```\njavac /workdir/<FileName>.java\njava -Xms1G -Xmx1G -cp /workdir <FileName>\n```\n\nC#\n```\ncsc /workdir/ContestOrganizer.cs /out:/workdir/<FileName>.exe\nmono /workdir/<FileName>.exe\n```\n\nPython3.6\n```\npython3.6 /workdir/<FileName>.py\n```\n<a id=\"75\"></a>\n#### Processing Server Specifications\n###### Server and Docker Configuration\n\nThe solutions are executed on Amazon EC2 c3.large inside a Docker Container with the following configuration: \n\n[Ubuntu OS](http://releases.ubuntu.com/18.04/)\n[Download the Docker Base Image](https://github.com/tianon/docker-brew-ubuntu-core/blob/010bf9649b1d10e2c34b159a9a9b338d0fdd4939/bionic/Dockerfile)\n<a id=\"76\"></a>\n###### C++ Compiler Version Details\n```\nUsing built-in specs.\nCOLLECT_GCC=gcc\nCOLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper\nOFFLOAD_TARGET_NAMES=nvptx-none\nOFFLOAD_TARGET_DEFAULT=1\nTarget: x86_64-linux-gnu\nConfigured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu\nThread model: posix\ngcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04) \n```\n\n<a id=\"77\"></a>\n###### C# - Mono JIT compiler version\n```\nMono JIT compiler version 5.20.1.19 (tarball Thu Apr 11 09:02:17 UTC 2019)\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\n\tTLS:           __thread\n\tSIGSEGV:       altstack\n\tNotifications: epoll\n\tArchitecture:  amd64\n\tDisabled:      none\n\tMisc:          softdebug \n\tInterpreter:   yes\n\tLLVM:          yes(600)\n\tSuspend:       hybrid\n\tGC:            sgen (concurrent by default)\n```\n\n<a id=\"78\"></a>\n###### Java Compiler Version Details\n```\nopenjdk version \"1.8.0_212\"\nOpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)\nOpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)\n```\n\n<a id=\"79\"></a>\n###### Python Version\n```\nPython3.6.8 - https://docs.python.org/3.6/whatsnew/changelog.html#python-3-6-8-final\n```\n<a id=\"80\"></a>\n#### Setting Up Your Local Environment Similar to the Testing Machine\nYou will require prior knowledge of Docker to set up an environment similar to Topcoder’s production environment in which your code is executed.\n\n- Install Docker: \n  - [Docker for Windows User](https://docs.docker.com/docker-for-windows/)\n  - [Docker for Mac Users](https://docs.docker.com/docker-for-mac/)\n  - [Docker Linux Users](https://www.tutorialspoint.com/docker/installing_docker_on_linux.htm)\n- Create a Project Directory\n- In your project directory, create a file named Dockerfile and paste the following:\n\n```\nFROM ubuntu:18.04 \n\n# Install General Requirements\nRUN apt-get update && \\\n\tapt-get install -y --no-install-recommends \\\n\tapt-utils \\\n\tbuild-essential \\\n\tsoftware-properties-common\n\n# Install Mono\nRUN apt-get install gnupg ca-certificates -y \\\n\t&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \\\n\t&& echo \"deb https://download.mono-project.com/repo/ubuntu stable-bionic main\" | tee /etc/apt/sources.list.d/mono-official-stable.list \\\n\t&& apt update \\\n\t&& apt install mono-devel -y\n\n# Install gcc \nRUN apt-get -y install gcc\n\nRUN apt-get update && \\\n\tapt-get install -y openjdk-8-jdk && \\\n\tapt-get clean && \\\n\trm -rf /var/lib/apt/lists/* && \\\n\trm -rf /var/cache/oracle-jdk8-installer;\n\n# Fix certificate issues, found as of \n# https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/983302\nRUN apt-get update && \\\n\tapt-get install -y ca-certificates-java && \\\n\tapt-get clean && \\\n\tupdate-ca-certificates -f && \\\n\trm -rf /var/lib/apt/lists/* && \\\n\trm -rf /var/cache/oracle-jdk8-installer;\n\n# Setup JAVA_HOME, this is useful for docker commandline\nENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/\nRUN export JAVA_HOME\n\nRUN add-apt-repository ppa:jonathonf/python-3.6\nRUN apt-get update\n\nRUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv maven\n\n# update pip\nRUN python3.6 -m pip install pip --upgrade\n```\n\n- In the same folder where you have your docker file, create the folder structure ./tester/target/\n- Inside target add the local tester jar provided to you and the submission source code you want to test \n- Execute the following command:\n\nIn the below command you can give your own <docker_image_name>\n\n```\n$ docker build -t <docker_image_name> -f Dockerfile .\n$ docker run -it -v tester:/tester <docker_image_name> /bin/bash\n\ncd /tester/target/\n```\n\n```\njava -jar tester.jar -exec \"<command>\" -seed <seed>\n```\n\nHere, `<command>` is the command to execute your program, and `<seed>` is the seed for test case generation. If your compiled solution is an executable file, the command will be the full path to it, for example, \"C:\\topcoder\\solution.exe\" or \"~/topcoder/solution\". In the case that your compiled solution needs to be run with the help of an interpreter, for example, if you program in Java, the command will be something like \"java -cp C:\\topcoder\\solution\".\n\nFinally, remember that you can print any debug information of your solution to standard error, and it will be forwarded to the standard out of the tester. \n\nNote: You will see an exception because some of the fetched dependencies from the maven repository are meant for the execution on Topcoder’s System. Please ignore that exception. Your individual scores will be added to output.txt in the workdir.\n<a id=\"81\"></a>\n#### Multithreading\nThe docker container is restricted to use 1 core for each submission, so multithreading might not help you much.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1gvfA0GoFuKPxGlSFhPL6P","type":"Entry","createdAt":"2020-02-28T19:56:11.253Z","updatedAt":"2021-04-28T14:04:08.574Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":15,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"kphmd","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"upvotes":12,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3YeSXGR5CUPgq9NkzBGOdr","circular":true}}],"journeyPrevious":{"sys":{"type":"Link","linkType":"Entry","id":"3YeSXGR5CUPgq9NkzBGOdr","circular":true}}}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2Qd7ggZoS7IDkivfWBwfTv","type":"Entry","createdAt":"2019-12-13T17:01:02.451Z","updatedAt":"2025-04-02T19:06:50.058Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":25,"revision":8,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"2019 Topcoder Open Marathon Match Final","type":"Article","trackCategory":["Data Science"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2MZf5yPIlVLprsO8F9FNEo","type":"Entry","createdAt":"2019-12-13T16:59:16.647Z","updatedAt":"2019-12-13T16:59:16.647Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Marathon Match","trackParent":"Data Science"}}],"tags":["TCO","TCO19"],"creationDate":"2019-11-15T17:10:25.000Z","readTime":"8 min","content":"<p>Introduction 8-queens puzzle The idea for this problem came from the famous 8-queens puzzle: how can you place eight queens on a standard 8&#215;8 chess board such that no queen attacks another one. Here is one example solution from ninety-two possible ones: This is a very famous computer puzzle that is often used to benchmark [&#8230;]</p>\n<p>The post <a rel=\"nofollow\" href=\"https://www.topcoder.com/the-tco-2019-marathon-match-final/\">TCO 2019 Marathon Match Final</a> appeared first on <a rel=\"nofollow\" href=\"https://www.topcoder.com\">Topcoder</a>.</p>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"nSbNxiqpcPSDVkj8MafjW","type":"Asset","createdAt":"2019-12-13T17:00:19.927Z","updatedAt":"2019-12-13T17:00:19.927Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"TCO 2019 Marathon Match Final","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/nSbNxiqpcPSDVkj8MafjW/b60420529907af58085eb526f4951de9/TCO_2019_Marathon_Match_Final","details":{"size":113899,"image":{"width":1024,"height":683}},"fileName":"TCO 2019 Marathon Match Final","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5XYGp5aRhJPMMVq6V2yiVg","type":"Entry","createdAt":"2019-09-18T07:38:15.252Z","updatedAt":"2019-10-15T16:40:39.130Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dmitri Kamenetsky","tcHandle":"dimkadimon"}}],"externalArticle":true,"contentUrl":"https://www.topcoder.com/blog/the-tco-2019-marathon-match-final"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1EkBDHSga9GTRlUD9Fmadp","type":"Entry","createdAt":"2020-07-02T08:11:44.941Z","updatedAt":"2025-04-02T11:57:24.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":325,"revision":73,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Marathon Match Local Tester Parameters","slug":"marathon-match-local-tester-parameters","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["Marathon"],"creationDate":"2020-06-26","readTime":"15 min","content":"#### Basic Usage\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">java -jar \\<tester-jar-file.jar\\> [-seed valueOrRange] [-exec yourSolution]</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">\\-seed S</code> Run a single test case S.</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">\\-seed S1,S2</code> Run a **range** of seeds, between S1 and S2, inclusive.</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">\\-seed S+D</code> Run a **range** of D seeds, starting from S, equivalent to <code class=\"plaintext\">\\-seed S,(S+D-1)</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">\\-seed {S1,S2,...,Sn}</code> Run a **list** of specified seeds, using curly braces.</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">\\-seed S1\\*K</code> or <code class=\"plaintext\">S1,S2\\*K</code> or <code class=\"plaintext\">S+D\\*K</code> or <code class=\"plaintext\">{S1,S2,...,Sn}\\*K</code> Run **K times** a single seed, a range or a list of seeds.</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">\\-exec \\\"\\<command\\>\\\"</code> If your compiled solution is an executable file, the command will be the full path to it. For example, \"C:\\\\TC\\\\solution.exe\" or \"~/topcoder/solution\". In case your compiled solution is to be run with the help of an interpreter, for example, if your program is in Java, the command will be something like \"java -cp C:\\\\TopCoder Solution\".</span>\n<span style=\"display:block\">Examples:</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">java -jar \\<tester-jar-file.jar\\> -seed 1,10 -exec \"tc/mysolution\"</code></span>\n<span style=\"margin-left:50px;display:block\">Run the program named \"mysolution\" (an executable located in folder \"tc\") 10 times, using all seeds between 1 and 10 (one at a time).</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">java -jar \\<tester-jar-file.jar\\> -seed 758+200 -exec \"java -cp bin MySol\"</code></span>\n<span style=\"margin-left:50px;display:block\">Run a Java solution (a compiled class file located in folder \"bin\"), using seeds between 758 and 957, inclusive.</span>\n<span style=\"display:block\">All parameters are case-insensitive, and there are also shorter alternative parameter names:</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">\\-seed</code> is equivalent to <code class=\"plaintext\">\\-sd</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">\\-exec</code> is equivalent to <code class=\"plaintext\">\\-ex</code></span>\n#### Visual Options\n<span style=\"display:block\"><code class=\"plaintext\">\\-novis</code> (or <code class=\"plaintext\">\\-nv</code>)</span>\n<span style=\"margin-left:25px;display:block\">For problems with a visual representation, this option disables the visualization.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-size</code> (or <code class=\"plaintext\">\\-sz</code>)</span>\n<span style=\"margin-left:25px;display:block\">Controls the size of the visualization area. It is the number of pixels used by each logical unit in the viewer content (e.g. the size of each cell in a grid). A value of zero (<code class=\"plaintext\">\\-sz 0</code>) can be used to fit the visualizer window into the screen area. Note that the visualizer window is now resizable.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-windowPos x,y\\[width,height\\]</code> (or <code class=\"plaintext\">\\-wp</code>)</span>\n<span style=\"margin-left:25px;display:block\">Allows setting the visualizer's initial window position (x, y) and optionally its dimensions (width, height). It can be useful when placing it side-by-side with the other open windows (e.g. code editor) or when working with more than one screen. All values are in pixels, using screen coordinates.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-screen N</code> (or <code class=\"plaintext\">\\-sc</code>)</span>\n<span style=\"margin-left:25px;display:block\">A simpler way to place the visualizer's window in a specific (Nth) screen, when working with multiple monitors. The default behavior is to place the visualizer window in the primary (N=1) screen. To place it in a secondary screen, use <code class=\"plaintext\">\\-screen 2</code>. When combined with <code class=\"plaintext\">\\-windowPos</code> parameter, the window position coordinates are relative to the specified screen.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-saveVis \\[folder\\]</code> (or <code class=\"plaintext\">\\-sv</code>)</span>\n<span style=\"margin-left:25px;display:block\">Allows saving the visualizer content into an image file, after each screen update. A sequence of PNG images will be generated in the specified folder (or in the current folder, if the folder parameter is omitted), using the filename \"seed-SSSSS.png\", where SSSSS is a sequential number. Note that the dimensions of the image will match the dimensions of the visualizer in the screen, so it may be useful to adjust the desired dimensions beforehand, using <code class=\"plaintext\">\\-size</code> or <code class=\"plaintext\">\\-windowPos</code> parameters. It is necessary that the visualization itself is enabled (<code class=\"plaintext\">\\-noVis</code> parameter should not be used together with this option). This option will save all the visualizer's window content, which includes a central main panel and the information panel on the right side of the window. To save only the central panel content, use together with the option <code class=\"plaintext\">\\-is 0</code>, as described below.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-infoScale scale</code> (or <code class=\"plaintext\">\\-is</code>)</span>\n<span style=\"margin-left:25px;display:block\">Allows increase/decrease the font used in the information panel (right side of visualizer). It is a percentage, so 100 means no change in the displayed font size. <code class=\"plaintext\">\\-infoScale 75</code> would use a smaller font, and <code class=\"plaintext\">\\-is 150</code> a larger one. If <code class=\"plaintext\">\\-is 0</code> is used, the information panel is not displayed at all, which may be useful if the competitor wants to see only the visualizer's main (central) content, possibly together with <code class=\"plaintext\">\\-saveVis</code> parameter.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-delay</code> (or <code class=\"plaintext\">\\-dl</code>)</span>\n<span style=\"margin-left:25px;display:block\">For problems with animation in which intermediate states are displayed, this option controls the time interval (in milliseconds) between each update of the visualizer. A value of zero (<code class=\"plaintext\">\\-delay 0</code>) can be used to go straight to the final state of the solution.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-pause</code> (or <code class=\"plaintext\">\\-ps</code>)</span>\n<span style=\"margin-left:25px;display:block\">For problems with animation this option allows starting the visualizer in a paused state. Space key can be used to toggle the pause state on/off when the visualizer is running. Other keys advance a single step.</span>\n#### Other Options\n<span style=\"display:block\"><code class=\"plaintext\">\\-debug</code> (or <code class=\"plaintext\">\\-db</code>)</span>\n<span style=\"margin-left:25px;display:block\">Enable debug messages from the tester.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-noOutput</code> (or <code class=\"plaintext\">\\-no</code>)</span>\n<span style=\"margin-left:25px;display:block\">Disable printing messages from your solution.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-printRuntime</code> (or <code class=\"plaintext\">\\-pr</code>)</span>\n<span style=\"margin-left:25px;display:block\">Enable printing the run time, together with the score.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-timeLimit \\<milliseconds\\></code> (or <code class=\"plaintext\">\\-tl</code>)</span>\n<span style=\"margin-left:25px;display:block\">Enable timeout control. For example <code class=\"plaintext\">\\-timeLimit 5000</code> will enforce a run time limit of 5000 ms (i.e. 5 seconds).</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-threads \\<numThreads\\></code> (or <code class=\"plaintext\">\\-th</code>)</span>\n<span style=\"margin-left:25px;display:block\">Enable running multiple parallel tests when running multiple seeds with a single command. For example <code class=\"plaintext\">\\-threads 4</code> will run up to four tests at the same time. The default is using a single thread. This option may be useful to run a batch of tests faster. Note that when using more than one thread, there will be some level of concurrence, depending on your system and the number of threads used, which will affect the solution performance. Also note that the actual number of threads used is limited to the number of virtual CPUs available.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-saveSolInput \\[\\<folder\\>\\]</code> (or <code class=\"plaintext\">\\-si</code>)</span>\n<span style=\"margin-left:25px;display:block\">Save the **input** provided to your solution in the specified folder using the filename \"\\<seed\\>.in\". If the folder is omitted, the current folder is used. All save options overwrite existing files in the specified folder (if they exist). They automatically create the specified folder if it doesn't exist.</span>\n<span style=\"margin-left:25px;display:block\">Example: <code class=\"plaintext\">\\-seed 1,100 -saveSolInput input</code>: Save in the folder \"input\" files named 1\\.in, 2\\.in, \\.\\.\\., 100\\.in, containing the first 100 test cases. Later, your program could be called directly redirecting one of these files to its standard input: <code class=\"plaintext\">mysolution \\< 1\\.in</code></span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-saveSolOutput \\[\\<folder\\>\\]</code> (or <code class=\"plaintext\">\\-so</code>)</span>\n<span style=\"margin-left:25px;display:block\">Save the **standard output** produced by your solution in the specified folder, using the filename \"\\<seed\\>.out\". If the folder is omitted, the current folder is used. Files created with this option can be used later as input to the tester (see option <code class=\"plaintext\">\\-loadSolOutput</code> below).</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-saveSolError \\[\\<folder\\>\\]</code> (or <code class=\"plaintext\">\\-se</code>)</span>\n<span style=\"margin-left:25px;display:block\">Save the **error output** produced by your solution in the specified folder, using the filename \"\\<seed\\>.err\". If the folder is omitted, the current folder is used.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-saveAll \\[\\<folder\\>\\]</code> (or <code class=\"plaintext\">\\-sa</code>)</span>\n<span style=\"margin-left:25px;display:block\">Combine all three saving options (<code class=\"plaintext\">\\-saveSolInput</code>, <code class=\"plaintext\">\\-saveSolOutput</code> and <code class=\"plaintext\">\\-saveSolError</code>), saving in the specified folder the **input** provided to your solution (\"\\<seed\\>.in\"), the **output** produced by your solution (\"\\<seed\\>.out\") and the **error output** produced by your solution (\"\\<seed\\>.err\"). If the folder is omitted, the current folder is used.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-loadSolOutput \\[\\<folder\\>\\]</code> (or <code class=\"plaintext\">\\-lo</code>)</span>\n<span style=\"margin-left:25px;display:block\">Instead of calling an executable file, if this parameter is specified the tester will read the solution from the specified folder. If the folder is omitted, the current folder is used.</span>\n<span style=\"margin-left:25px;display:block\">It can't be used together with <code class=\"plaintext\">\\-exec</code> parameter. It can be useful to evaluate a solution generated outside the tester (even manually). If you run your solution directly and redirect its standard output to a file (<code class=\"plaintext\">mysolution \\< inputs/1.in \\> outputs/1.out</code>), the generated file can be evaluated using <code class=\"plaintext\">\\-seed 1 -loadSolOutput outputs</code></span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-bests \\<bestControlFile\\></code> (or <code class=\"plaintext\">\\-bs</code>)</span>\n<span style=\"margin-left:25px;display:block\">Save the best score seen so far for each seed in the specified file. This feature uses a simple control and it is not intended to replace more advanced local testers. When enabled, it will print the best value seen for that seed, before the current execution, and then will update the file if the new value is better.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-saveScores \\<scoresFile\\></code> (or <code class=\"plaintext\">\\-ss</code>)</span>\n<span style=\"margin-left:25px;display:block\">Save to the specified file the seeds and scores from the current execution. It can be useful when running multiple seeds, especially using multiple threads (in which the standard out may be shuffled). The generated file lists seeds and their scores, keeping seeds in ascending order, using the same format of the bests file (<code class=\"plaintext\">\\-bests</code> option). This option will override the content of the specified file if it exists.</span>\n<span style=\"display:block\"><code class=\"plaintext\">\\-noAntialiasing</code> (or <code class=\"plaintext\">\\-na</code>)</span>\n<span style=\"margin-left:25px;display:block\">Disable anti-aliasing when rendering visualizer content. It can be useful to increase the rendering speed in slow machines, although it will also reduce the rendering quality.</span>\n#### Contest-specific Parameter Overriding:\n<span style=\"display:block\"><code class=\"plaintext\">\\-\\<param\\> \\<valueOrRange\\></code></span>\n<span style=\"margin-left:25px;display:block\">This can be used to override test case parameters.</span>\n<span style=\"margin-left:25px;display:block\">For example, in MM 116 there were **N** grids (from 5 to 100).</span>\n<span style=\"margin-left:25px;display:block\">It would be possible to use <code class=\"plaintext\">\\-N 100</code>to force all cases to have 100 grids.</span>\n<span style=\"margin-left:25px;display:block\">Or <code class=\"plaintext\">\\-N 5,15</code>for a small number of grids (randomly selected between 5 and 15 inclusive).</span></span>\n#### Execution Summary:\n<span style=\"display:block\">When running multiple seeds, the tester will automatically print a summary including the number of tests executed, number of failed tests, average and maximum running time:</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Seeds: 1001 to 1500</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Executed Cases: 500</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Failed Cases: 0</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Avg. Run Time: 9476 ms</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Max. Run Time: 9834 ms</code></span>\n<span style=\"display:block\">If <code class=\"plaintext\">\\-bests</code> option is enabled, it will also include in this summary the number of bests improved, tied, normalized previous best score and normalized score of the current execution:</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Improved Bests: 23</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Tied Cases: 36</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Prev. Bests Score: 98.42355</code></span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">Current Score: 82.30097</code></span>\n<span style=\"display:block\">In the table below there is an example of how these scores are calculated, considering the goal is to **minimize** the score. If the goal was to maximize, the idea would be the same, but the relative score for each test case would be \"score / best\" (maximize), instead of \"best / score\" (minimize).</span>\n![Screenshot 2020-07-02 11:10:12](//images.ctfassets.net/piwi0eufbb2g/1SLvNPFMiNMDvCVqzTRmWa/40118c598838c62a20aebb2b71b3378a/Screenshot_2020-07-02_11_10_12.png)\n<span style=\"display:block\">The default behavior is printing the summary, but it can be suppressed with the parameter <code class=\"plaintext\">\\-noSummary</code> (or <code class=\"plaintext\">\\-ns</code>).</span>\n#### Compiling From Source:\n<span style=\"display:block\">To compile the tester from its source, use the command line **javac** compiler:</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">javac \\<TesterClassName\\>.java</code></span>\n<span style=\"display:block\">Note that the tester has a contest-specific source file and other common files from the package <code class=\"plaintext\">com.topcoder.marathon</code>. The compiler will automatically find and compile these other common files if they are in their correct subfolder com/topcoder/marathon.</span>\n<span style=\"display:block\">To create a **runnable jar** from the compiled classes run:</span>\n<span style=\"margin-left:25px;display:block\"><code class=\"plaintext\">jar cvfe \\<TesterJarName\\>.jar \\<TesterClassName\\> .</code></span>\n<span style=\"display:block\">Competitors who want to make changes to provided local tester for any reason may find useful information in this document (originally target to problem writers):</span>\n<span style=\"margin-left:25px;display:block\">[https://www.topcoder.com/thrive/articles/writing-a-marathon-tester](https://www.topcoder.com/thrive/articles/writing-a-marathon-tester)</span>\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yv3fVxbcdHYRkAr0yrVnS","type":"Entry","createdAt":"2020-06-26T13:17:38.391Z","updatedAt":"2021-02-04T05:39:58.059Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Wladimir Leite","tcHandle":"wleite","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"upvotes":18,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1LTsf2q8kxIHBRUfKAgePp","type":"Entry","createdAt":"2020-06-26T13:51:14.042Z","updatedAt":"2021-02-16T08:16:58.019Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":141,"revision":15,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Writing a Marathon Tester","slug":"writing-a-marathon-tester","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["Marathon","Tester"],"creationDate":"2020-06-24","readTime":"15 min","content":"#### Class/method to implement\nA marathon tester with no visual representation (tester only) should extend __MarathonTester__ abstract base class, which already implements many common features.\n\nThree abstract methods must be implemented:\n\n__boolean isMaximize()__\nReturn true if the goal of this problem is to maximize the score, or false otherwise (minimize).\n\n__void generate()__\nGenerate the test case.\n\n__double run()__\nRun this test case, calling the solution (if defined) and return the calculated raw score.\n\t\t\nFor problems with a visual representation but no animation, i.e. only a single (final) state is shown, the class to be extended is __MarathonVis__ (which extends __MarathonTester__). There is a single additional method to be implemented:\n\n__void paintContent(Graphics2D g)__\nResponsible for painting the content of the visualizer. Detailed information is available in the \"__Visualization and Painting__\" section.\n\nFinally, for problems with animations, i.e. where intermediate states are displayed, the base class to be extended is MarathonAnimatedVis. It has no abstract methods. \n\n![mtester 1](//images.ctfassets.net/piwi0eufbb2g/1riYwQF1aCgvyBu6xJSLN7/807ea130fe67390811bd65730ae94237/mtester_1.png)\n\n#### Random generator\nThe random number generator is already created and initialized to use the specified seed by the base class. It is available as a class variable named rnd, to be used inside generate() method (and occasionally inside run(), in the case of interactive problems, in which the tester needs to take actions based on solution output).\n\nThere are convenience methods to get a random number (integer or double) given a range. Please use them whenever possible. \nExample: if some variable N is randomly selected between \\[10,50\\](inclusive), just use:\n\n`int N = randomInt(10, 50);`\n\n#### Command line parameters\nAll command line parameters are parsed by the __MarathonController__ class. Most of the code to handle common parameter options are also implemented by the controller or base tester classes.\n\nProblem specific parameters can be obtained from the __parameters__ class variable.\nIncluded in the problem specific parameters are main test cases random variables, that could be __overridden__ by competitors, using command line parameters, to test specific types of cases. Example: if the problem has a grid of size S, between 10 and 50 inclusive the code could be something like:\n```\nint S = randomInt(10, 50);\nif (parameters.isDefined(\"S\")) S = randomInt(parameters.getIntRange(\"S\"));\n```\n\nSo after implementing the regular code to generate, it is recommended to add this feature for the random parameters that would make sense to force a specific value or range. It should be just one extra line of code for each parameter.\nNote that even if a single value is specified by the competitor (using -S 50), __randomInt(parameters.getIntRange())__ will work as expected. So the tester code should always be implemented in the way shown in the example, which allows both ranges and single values. Similar methods are available for doubles.\n\nIt is also possible to enforce the limits, so the user specified range is trimmed to be contained in the regular range. That is important when out of range values will certainly lead to error, so they would be useless.  Same example, with range enforcement. In this case, if __-S 40,100__ is used, the range would be \\[40,50\\], i.e. the intersection between valid range (\\[10,50\\]) and user specified range (\\[40,100\\]).\n```\n   int S = randomInt(minSize, maxSize); //Using constants is better\n   if (parameters.isDefined(\"S\")) {\n       S = randomInt(parameters.getIntRange(\"S\"), minSize, maxSize);\n   }\n```\n\n#### Time Control\nTime control is mostly implemented by __MarathonTester__ base class. This includes timeout control and time measure. Concrete implementations should call __startTime()__ right before waiting for output produced by the solution. And call __stopTime()__ right after reading all solution output. \nThese functions can be called multiple times, for interactive problems. The time control will accumulate the elapsed time. It always needs to be called in pairs (start/stop), without starting again the timer before stopping it. \nIt is typically called inside the __callSolution()__ method, as in the following example:\n```\nprivate String[] callSolution() throws Exception {\n    writeLine(size);\n    writeLine(numColors);\n    flush();\n    if (!isReadActive()) return null;\n\n    startTime(); // <-- Start here\n\n    int n = readLineToInt(-1);\n    if (n < 0) {\n        setErrorMessage(\"Invalid number of moves: \" + getLastLineRead());\n        return null;\n    }\n\n    String[] ret = new String[n];\n    for (int i = 0; i < n; i++) {\n        ret[i] = readLine();\n    }\n\n    stopTime(); // <-- Stop when solution finished returning everything\n    return ret;\n }\n```\n#### Input/Output\nOutput (writing data that will be read by the solution) and input (reading solution's answer) should use methods implemented by __MarathonTester__ base class. These  functions take care of where to read from (solution or an input file) and where to write to (solution and/or an output file). \n\nAs can be seen in the example code above, to __write__:\n- __writeLine()__ writes a string or a single integer.\n- __flush()__ when writing is done.\n\nFor reading: \n- __readLine()__ reads a full line to a String\n\n- __readLineToInt()__ reads a full line and converts the content into a single integer. An exception will be thrown if it is not an integer value.\n\n- __readLineToInt(int invalid)__ same as before, but returns the specified invalid value when it is unable to parse an integer value.\n\n- __readLineToIntArr()__ a convenience method that reads a full line, with space-separated integers, and returns an integer array.\n\n- __getLastLineRead()__ can be used to get the content of the last read line, usually to create an error message.\n\n- __isReadActive()__ before starting reading (and after writing all possible input), the tester should call this function to check if there is any active read source. Otherwise it should return immediately. This will happen when the tester is called without -exec and -loadSolOutput options.\n\n#### Main Method\nThe tester should run the __main()__ method, just calling the __MarathonController__:\n```\npublic static void main(String[] args) {\n    new MarathonController().run(args);\n}\n```\n\nWhen building the tester JAR, this should be the execution entry point.\n\n#### Visualization and Painting\nThe base class __MarathonVis__ takes care of things like creating a frame, finding its correct size, and adjusting its layout. \nUsing a standard way of displaying information makes it possible that visualizers work in any screen resolution and allows smooth window content resizing, without extra effort in the contest-specific part of the code. The visualizer is divided in two parts: the __content__ panel and the __information__ panel, as shown below.\n\n![panel](//images.ctfassets.net/piwi0eufbb2g/WNdAPr45K91MheDkGrSh6/1b4e559054bc5d0b5c95764127fff273/panel.png)\n \nThe content is painted by the contest-specific tester, while the info panel is painted by the MarathonVis, using information provided by the specific tester. \n\n__Initialization__\nIn the beginning of the run() method, the tester implementation should call three methods that will provide information to MarathonVis about the desired layout:\n```\n    if (hasVis()) {\n        setInfoMaxDimension(20, 12);\n        setContentRect(0, 0, w, h);\n        setDefaultSize(30);\n    }\n```\nThe first one (__setInfoMaxDimension__) sets the number of columns and rows of text that the information panel will contain. These numbers don't need to be exact, just an approximate upper bound that will reserve enough space for the displayed information. \n\nThe second one (__setContentRect__) sets the desired logical coordinates of the content area. Later, all painting will use these coordinates, as explained below.\n\nThe last one, which is optional, will set the default size in pixels of one content unit. It is the default value equivalent to the size specified in the command line option -sz. If it is not set, it will use the standard value 0, which means fit to screen.\n\nIt is important to note that the tester can call __hasVis()__ method to check if visualization is enabled (i.e. if it wasn't disabled by the command line option -__novis__), and avoid running unnecessary parts of the code. \n\n__Information Panel__\nAs mentioned, the information panel is painted by the base class. The tester implementation should call the following functions to provide the information to be displayed:\n\n__addInfo(Object key, Object value)__ this will display \"key: value\" in the info panel. If it is called multiple times, it updates the respective value, without adding a new row of information.\n\n__addInfo(Object key)__ displays a centralized \"key\" (useful for section titles).\n\n__addInfoBreak()__ skips one line of text, to separate sections of information.\n\nIn the following example, it is possible to see the calls made to build the information panel shown:\n\n![seed](//images.ctfassets.net/piwi0eufbb2g/30eXLGYY7SxglWVIC9yZoN/36340cacbb68b1ea364593091748af21/seed.png)\n\nIn the case of an animated visualizer, after processing each step of the solution, fields like steps and score can be updated by simply calling __addInfo()__ again, with the new values, only for fields that changed. In the previous example, an update after each step would have:\n```\naddInfo(\"Steps\", currStep + \" / \" + numSteps);\naddInfo(\"Score\", getScore());\naddInfo(Color.red, 12);\naddInfo(Color.blue, 9);\naddInfo(Color.green, 11);\n```\nThese functions receive Objects as parameters. The default behavior is just to convert the content to a String, but it is possible to create different visual representations for other types of objects. Currently, there is support for objects of the Color class, which are displayed as small squares filled with the Color object value.\n\n__Content Panel__\nThe tester should implement the abstract method __paintContent()__. As the desired coordinates were already specified, inside this method there is no need to worry about borders, window dimension or the information panel. All painting should be made inside the __contentRect__ previously set.\n\nIf the problem deals with a __w__ x __h__ grid and __contentRect__ was set to (0, 0, w, h), some examples of painting:\n\nFill with blue the left half of the grid area:\n```\n    Rectangle2D rc = new Rectangle2D.Double(0, 0, w / 2, h);\n    g.setColor(Color.blue);\n    g.fill(rc);\n```\nFill with red the cell grid with coordinates x = 2, y = 3 (i.e. the third column and fourth row):\n```\n    Rectangle2D rc = new Rectangle2D.Double(2, 3, 1, 1);\n    g.setColor(Color.red);\n    g.fill(rc);\n```\nDraw a line connecting the center of grid cells (1,3) and (8,0):\n```\n    Line2D line = new Rectangle2D.Double(1.5, 3.5, 8.5, 0.5);\n    g.setStroke(new BasicStroke(0.03f, BasicStroke.CAP_ROUND,\n                BasicStroke.JOIN_ROUND));\n    g.draw(line);\n```\nNote that line thickness (stroke) also uses the current coordinate system, so it should be specified as a proportion of a grid unit (in this example, 3% of the size of a grid cell).\n\n__Update__\nAfter the initial setup and whenever the tester wants to __update__ the visualization content, it should call the update() method. This method already checks whether the visualization is enabled, so it can be called without checking __hasVis()__. \n\n__Lock__\nAs painting is asynchronous, the tester should make all updates to state class variables inside a synchronized block, on the object __updateLock__, already created for this purpose,  to avoid painting intermediate (and possibly invalid) states in the middle of a transition. \n\n__Paint Text in the Content Panel__ \\[NEW\\]\nAs explained above, a coordinate transformation is applied to the __Graphics2D__ object, making painting content easier (no need to worry about borders, offsets, size parameter, the actual window dimensions and so on). \nAlthough positioning text inside the visualizer content is simple (and follows the same idea used for any graphical component), setting the font size can be tricky. \nTwo methods were added to __MarathonVis__ class, to make this task much simpler:\n\n- __adjustFont__: receives the font that will be used, but instead of specifying its size directly, it will inform the maximum (larger) string that will be painted and a rectangle that this string should fit. For example, if number with up to 3 digits will be displayed inside each grid cell, the call should be something like:\n\n     adjustFont(g, Font.SANS_SERIF, Font.PLAIN, \n               \"000\", new Rectangle2D.Double(0, 0, 0.6, 0.6));\n\n- Note that the rectangle size used is 0.6 (instead of 1.0) to leave a margin. This method should be called inside paintContent(), only once for each group of strings that will use the same font.\n\n- __drawString__: instead of receiving x,y coordinates, it will receive a rectangle that will \"contain\" the string. The text will be drawn centralized (both horizontally and vertically) in the specified rectangle.\n\nAn example of __paintContent__ implementation, that will produce the following grid:\n\n![Screenshot 2020-06-26 16:46:53](//images.ctfassets.net/piwi0eufbb2g/cksNhdhBhrJ70Nlqnwue6/d63d6a651873d27519bf1e96611d39b0/Screenshot_2020-06-26_16_46_53.png)\n\n```\n    protected void paintContent(Graphics2D g) {\n        adjustFont(g, Font.SANS_SERIF, Font.PLAIN, \n                   \"000\", new Rectangle2D.Double(0, 0, 0.6, 0.6));\n        for (int y = 0; y < size; y++) {\n            for (int x = 0; x < size; x++) {\n                Rectangle2D rc = new Rectangle2D.Double(x, y, 1, 1);\n                g.setColor(color[y][x]);\n                g.fill(rc);\n                g.setColor(Color.black);\n                g.draw(rc);\n                drawString(g, String.valueOf(x + y * size), rc);\n            }\n        }\n        g.setStroke(new BasicStroke(0.04f, BasicStroke.CAP_ROUND,\n                    BasicStroke.JOIN_ROUND));\n        g.setColor(Color.black);\n        for (int i = 0; i <= size; i++) {\n            g.draw(new Line2D.Double(0, i, size, i));\n            g.draw(new Line2D.Double(i, 0, i, size));\n        }\n    }\n```\n#### Animated Visualizers \nFor problems with animation, in which intermediate states are displayed, the base class __MarathonAnimatedVis__ takes care of delays and pausing.\n\nAll that tester implementation needs to do is call __updateDelay()__ whenever it wants to update the visualizer. It will automatically pause or delay depending on the current state/configuration. \n\nInside the loop that processes each step of the solution, the tester should call __hasDelay()__ (usually together with __hasVis()__) to check if it is necessary to repeat calculations (like updating the current score) after each step. The __hasDelay()__ function returns __false__ if delay is zero, which means no intermediate states should be updated.\n\nIn the beginning of the __run()__ method, tester implementations can call __setDefaultDelay(int delay)__ to set the default delay between each step.\n\n__Paint Performance \\[NEW\\]__\nTo help checking if visualizer content rendering is fast enough, especially when there are many intermediate states to be drawn, it is possible to use the command line parameter __-paintInfo (or -pi)__. It will print (console standard output) how many times visualizer content was painted and the average time of each paint (in milliseconds).  \n\n#### A Complete Example\nHere is a complete (and working) example of an animated visualizer, with additional comments in important places.\n\nIt is a very simple problem called __ShortestPath__. There is a grid, and two distinct randomly chosen cells on it. The goal is to move from the start cell to the target cell. The score, which should be minimized, is the squared number of steps the solution takes to reach the target.\n\n![Screenshot 2020-06-26 16:50:54](//images.ctfassets.net/piwi0eufbb2g/cZlZCH7bXskXJB84pf841/905e319e67421e43805eafe03f3291b7/Screenshot_2020-06-26_16_50_54.png)\n\n```\nimport java.awt.*;\nimport java.awt.geom.*;\nimport com.topcoder.marathon.*;\n\npublic class ShortestPathTester extends MarathonAnimatedVis {\n    //Ranges\n    private static final int minSize = 8, maxSize = 50;\n \n    //Constraints\n    private static final int maxSteps = 10000;\n \n    //Inputs\n    private int size;\n    private int x0, y0, x1, y1; \n\n    //State control\n    private int xp, yp;\n    private int step;\n \n    //Generate the test case (override an abstract method of MarathonTester) \n    protected void generate() {\n        size = randomInt(minSize, maxSize);\n\n        //Special cases for seed 1 and 2\n        if (seed == 1) {\n            size = minSize;\n        } else if (seed == 2) {\n            size = maxSize;\n        }\n \n        //User defined parameters\n        if (parameters.isDefined(\"N\")) size = randomInt(parameters.getIntRange(\"N\"), \n                                                        minSize, maxSize);\n \n        //Generate distinct start and target positions\n        x0 = randomInt(0, size - 1);\n        y0 = randomInt(0, size - 1);\n        do {\n            x1 = randomInt(0, size - 1);\n            y1 = randomInt(0, size - 1);\n        } while (x0 == y0 && x1 == y1);\n\n        if (debug) {\n            System.out.println(\"N = \" + size);\n            System.out.println(\"start = \" + x0 + \",\" + y0);\n            System.out.println(\"target = \" + x1 + \",\" + y1);\n        }\n    }\n \n    //Return false as the goal here is to minimize the score \n    //(override an abstract method of MarathonTester) \n    protected boolean isMaximize() {\n        return false;\n    }\n \n    //Run the solution (override an abstract method of MarathonTester) \n    protected double run() throws Exception {\n        //Initialization\n        init();\n        int score = getErrorScore();\n\n        //Call the solution and check its return\n        String[] ret = callSolution();\n        if (ret == null) {\n            if (!isReadActive()) return getErrorScore();\n            return fatalError();\n        }\n        if (ret.length > maxSteps) return fatalError(\"Your solution exceed the maximum number of\"\n                                + \" steps \" + maxSteps + \" steps (returned \" + ret.length + \")\");\n \n        //Initial update\n        if (hasVis() && hasDelay()) {\n            addInfo(\"Steps\", 0 + \" / \" + ret.length);\n            updateDelay();\n        }\n\n        //Loop through all steps\n        while (step < ret.length) {\n            //Updates to state class variables should be done inside a synchronized block\n            synchronized (updateLock) {\n                String s = ret[step++];\n                if (debug) System.out.println(\"Step \" + step + \": \" + s);\n                if (s.length() != 1) return fatalError(\"Step \" + step + \" does not contain\"\n                                                       + \"exactly one character:\" + s);\n \n                //Process one step, checking invalid moves and out of bounds\n                char c = s.charAt(0);\n                int x = xp;\n                int y = yp;\n                if (c == 'U') y--;\n                else if (c == 'D') y++;\n                else if (c == 'R') x++;\n                else if (c == 'L') x--;\n                else return fatalError(\"Step \" + step + \" contains an invalid move: \" + c);\n                if (y < 0 || x < 0 || y >= size || x >= size) {\n                    return fatalError(\"Step \" + step + \" moved out of bounds.\");\n                }\n    \n                //Update current position\n                xp = x;\n                yp = y;\n            }\n\n            //Update if necessary (hasVis and (hasDelay or it is the last step))\n            if (hasVis() && (hasDelay() || step == ret.length)) {\n                score = step * step;\n                if (step == ret.length && (xp != x1 || yp != y1)) score =  getErrorScore();\n                synchronized (updateLock) {\n                    addInfo(\"Steps\", step + \" / \" + ret.length);\n                    addInfo(\"Score\", score);\n                }\n                updateDelay();\n            }\n        }\n        return score;\n    }\n \n    //Paint the content panel (override an abstract method of MarathonVis) \n    protected void paintContent(Graphics2D g) {\n        //Fill grid background\n        Rectangle2D rc = new Rectangle2D.Double(0, 0, size, size);\n        g.setColor(Color.white);\n        g.fill(rc);\n\n        //Fill start and target cells\n        rc = new Rectangle2D.Double(x0, y0, 1, 1);\n        g.setColor(Color.red);\n        g.fill(rc);\n        rc = new Rectangle2D.Double(x1, y1, 1, 1);\n        g.setColor(Color.blue);\n        g.fill(rc);\n         \n        //Draw grid\n        g.setStroke(new BasicStroke(0.04f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));\n        g.setColor(Color.black);\n        for (int i = 0; i <= size; i++) {\n            g.draw(new Line2D.Double(0, i, size, i));\n            g.draw(new Line2D.Double(i, 0, i, size));\n        }\n \n        //Current position\n        Ellipse2D e = new Ellipse2D.Double(xp + 0.1, yp + 0.1, 0.8, 0.8);\n        g.setColor(new Color(0, 0, 0));\n        g.fill(e);\n        g.setColor(new Color(255, 255, 255));\n        g.draw(e);\n    }\n \n    private void init() {\n        //Initial position\n        xp = x0;\n        yp = y0;\n\n        if (hasVis()) {\n            //Sets the maximum dimension of information panel (number of rows and columns of text)\n            setInfoMaxDimension(18, 9);\n\n            //Set desired coordinates of the content to a squared grid\n            setContentRect(0, 0, size, size);\n\n            //Default size (in pixels) of grid's cell\n            setDefaultSize(30);\n \n            //Default delay (in milliseconds) between visualizer updates\n            setDefaultDelay(100);\n \n            //Create information panel content\n            addInfo(\"Seed\", seed);\n            addInfoBreak();\n            addInfo(\"Size N\", size);\n            addInfo(\"Start\", \"(\" + x0 + \", \" + y0 + \")\");\n            addInfo(\"Target\", \"(\" + x1 + \", \" + y1 + \")\");\n            addInfoBreak();\n\n            //Steps and score will be updated later, while processing solution return\n            addInfo(\"Steps\", \"-\");\n            addInfoBreak();\n            addInfo(\"Score\", \"-\");\n\n            //Call update when done\n            update();\n       }\n    }\n \n    private String[] callSolution() throws Exception {\n        //Write input data\n        writeLine(size);\n        writeLine(x0);\n        writeLine(y0);\n        writeLine(x1);\n        writeLine(y1);\n\n        //Flush when writing is done\n        flush();\n \n        //Check is there is any active read (a running solution or a solution file), \n        //otherwise just return.\n        if (!isReadActive()) return null;\n \n        //Start to measure time spent by the solution\n        startTime();\n\n        //Read from the solution (process or a file) the number of lines\n        int n = readLineToInt(-1);\n        if (n < 0) {\n            setErrorMessage(\"Invalid number of steps: \" + getLastLineRead());\n            return null;\n        }\n\n        //Read each line\n        String[] ret = new String[n];\n        for (int i = 0; i < ret.length; i++) {\n            ret[i] = readLine();\n        }\n\n        //Stop to measure time\n        stopTime();\n\n        return ret;\n    }\n    \n    //Main method should create a MarathonController and call run passing command line arguments\n    public static void main(String[] args) {\n        new MarathonController().run(args);\n    }\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yv3fVxbcdHYRkAr0yrVnS","type":"Entry","createdAt":"2020-06-26T13:17:38.391Z","updatedAt":"2021-02-04T05:39:58.059Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Wladimir Leite","tcHandle":"wleite","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"upvotes":5,"downvotes":0}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6Jaqhx7Xm7PQeRHi9uD2BS","type":"Entry","createdAt":"2019-09-23T23:25:45.864Z","updatedAt":"2025-01-13T07:55:47.600Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":24,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How Feedback Helped New Designer ndondo_ Get to Where He is Today","type":"Article","trackCategory":["Design"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1aZUzDDhRT41AXcOHTs9yh","type":"Entry","createdAt":"2019-09-18T07:37:09.134Z","updatedAt":"2019-09-18T07:37:09.134Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Interview","trackParent":"Design"}}],"tags":["Newbie","Design Month"],"creationDate":"2019-05-29T21:00:00.000Z","readTime":"4 min read","content":"I am from Indonesia and live in the city of Medan. I am a graduate of Information Management Diploma III, and currently, I continue my undergraduate education majoring in Computer Systems. Basically, I am a programmer. I worked as a Web Developer for 3 years until the end of 2018.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"610OyAhwls4IzHgLN9HRs","type":"Asset","createdAt":"2019-09-23T23:25:29.153Z","updatedAt":"2019-09-23T23:25:29.153Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"Feedback helped ndondo","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/610OyAhwls4IzHgLN9HRs/7f689c24af0266ddfc92aeb7941bace2/Feedback_helped_ndondo.jpg","details":{"size":233315,"image":{"width":1080,"height":720}},"fileName":"Feedback helped ndondo.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3Hun08yWmREHf74zlqSObZ","type":"Entry","createdAt":"2019-09-18T07:37:13.144Z","updatedAt":"2019-12-16T17:43:18.153Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":10,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Daniela","tcHandle":"DaraK"}}],"contentUrl":"https://www.topcoder.com/how-feedback-helped-new-designer-ndondo_-get-to-where-he-is-today/"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"613rRv8mz0dQekiFmKdDW8","type":"Entry","createdAt":"2022-08-11T06:49:56.897Z","updatedAt":"2024-10-05T16:11:14.281Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":89,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Intersection of Two LinkedLists","slug":"intersection-of-two-linkedlists","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["JAVA","Linked List"],"creationDate":"2022-08-10","readTime":"10min","content":"Suppose we are given two LinkedLists, L1 and L2. Both meet at a certain node and we need to find whether both the LinkedLists intersect. If yes, then we need to return the node at which both the LinkedLists meet.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1Ba4kHjXDfCB00guHwRsEP/b2f8839f0f48b0782370d2f02815b0c5/Intersection_of_Two_LinkedLists_-_ss1.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1Ba4kHjXDfCB00guHwRsEP/b2f8839f0f48b0782370d2f02815b0c5/Intersection_of_Two_LinkedLists_-_ss1.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1Ba4kHjXDfCB00guHwRsEP/b2f8839f0f48b0782370d2f02815b0c5/Intersection_of_Two_LinkedLists_-_ss1.png?w=30&h=30&fit=thumb\" alt=\"image\" loading=\"lazy\" /></picture>\n\nIn the above figure we can see that the last node of L1 is pointing to the node of L2 instead of pointing to NULL.\nWe will use different methods to find the intersection of L1 and L2.\nLet's understand LinkedList intersections using a different case. \n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2E7xgZfYUqmxsE451JkhpT/564640d7a284e047051b4fed63628471/Intersection_of_Two_LinkedLists_-_ss2.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2E7xgZfYUqmxsE451JkhpT/564640d7a284e047051b4fed63628471/Intersection_of_Two_LinkedLists_-_ss2.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2E7xgZfYUqmxsE451JkhpT/564640d7a284e047051b4fed63628471/Intersection_of_Two_LinkedLists_-_ss2.png?w=30&h=30&fit=thumb\" alt=\"image\" loading=\"lazy\" /></picture>\n\nIn the above picture there are i and j different LinkedLists which end at point E. The LinkedList J which should have an end point A, but rather than pointing to A it points to the node having data 4 of linked list i. So the point is to calculate the node where both the LinkedLists are going to intersect. In this case it is the node having data 4, which is the common node for both the LinkedLists.\n\n\n#### Brute Force Approach (Two Loops)\nIn this approach we will take a node of L1 and we will check if the current node is present in List L2.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3z4dYU1fEKeZUzEpqSEKKZ/ee0478021f97a200ec8b8d5816ece164/Intersection_of_Two_LinkedLists_-_ss3.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3z4dYU1fEKeZUzEpqSEKKZ/ee0478021f97a200ec8b8d5816ece164/Intersection_of_Two_LinkedLists_-_ss3.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3z4dYU1fEKeZUzEpqSEKKZ/ee0478021f97a200ec8b8d5816ece164/Intersection_of_Two_LinkedLists_-_ss3.png?w=30&h=30&fit=thumb\" alt=\"image\" loading=\"lazy\" /></picture>\n\nLet's use the above example to understand the brute force approach for LinkedList intersection:\nIn this case we will take a1-> a2-> c1->c2->c3 as a different LinkedList and we will check the existence of each node in a second linked list, which is b1->b2->b3->c1->c2->c3.\n\nNow for each node of the first LinkedList we need to iterate over the second LinkedList, then we will use two iterations for finding the intersection point.\n\n##### Java Implementation\n\n```java\n**\n * Definition for singly-linked list.\n * public class ListNode {\n * \tint val;\n * \tListNode next;\n * \tListNode(int x) {\n *     \tval = x;\n *     \tnext = null;\n * \t}\n * }\n */\npublic class Solution {\n\tpublic ListNode getIntNodeMethod(ListNode headA, ListNode headB) {\n   \t \n    \tListNode currA=headA;\n    \tListNode currB=headB;\n   \t \n    \tListNode res=null;\n   \t \n    \twhile(currA!=null)\n    \t{\n        \tcurrB=headB;\n        \twhile(currB!=null)\n        \t{\n            \tif(currA == currB)\n            \t{ return currA;\n          \t}\n           \t \n            \tcurrB= currB.next;\n        \t}       \t \n        \tcurrA= currA.next;\n    \t}\n    \treturn res;\n\t}\n}\n```\n\n__Code snippet__\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1nAtFOImlQJxU9kxtJnMkw/442ba0aed8c8fa5a7206906160c6e25b/Intersection_of_Two_LinkedLists_-_ss4.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1nAtFOImlQJxU9kxtJnMkw/442ba0aed8c8fa5a7206906160c6e25b/Intersection_of_Two_LinkedLists_-_ss4.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1nAtFOImlQJxU9kxtJnMkw/442ba0aed8c8fa5a7206906160c6e25b/Intersection_of_Two_LinkedLists_-_ss4.png?w=30&h=30&fit=thumb\" alt=\"image\" loading=\"lazy\" /></picture>\n\n\n#### Using DataStructure Technique\n\nFinding the intersection using hashing will help us to find the intersection node only in O(N) time complexity. We will create a hashset and insert all the nodes from L1. Then we will traverse L2 and using hashing we will check if the current node of L2 is present. This will improve complexity  from O(N*N) and the space complexity will be O(N). When we find the node which is already present in our hashset then we will return the node, otherwise after traversing L2 we will return null node.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3pDmfFszVdbzt4XROAUMd5/9e2e8b17c8d02f2af1c76e657e36aea2/Intersection_of_Two_LinkedLists_-_ss5.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3pDmfFszVdbzt4XROAUMd5/9e2e8b17c8d02f2af1c76e657e36aea2/Intersection_of_Two_LinkedLists_-_ss5.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3pDmfFszVdbzt4XROAUMd5/9e2e8b17c8d02f2af1c76e657e36aea2/Intersection_of_Two_LinkedLists_-_ss5.png?w=30&h=30&fit=thumb\" alt=\"image\" loading=\"lazy\" /></picture>\n\nAbove is the example for intersecting LinkedLists.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4yGEWu2xPa1nRiHsSBzzQ4/212abc7d23e100d60bfc3a084bff4cb1/Intersection_of_Two_LinkedLists_-_ss6.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4yGEWu2xPa1nRiHsSBzzQ4/212abc7d23e100d60bfc3a084bff4cb1/Intersection_of_Two_LinkedLists_-_ss6.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4yGEWu2xPa1nRiHsSBzzQ4/212abc7d23e100d60bfc3a084bff4cb1/Intersection_of_Two_LinkedLists_-_ss6.png?w=30&h=30&fit=thumb\" alt=\"image\" loading=\"lazy\" /></picture>\n\nThe above figure shows how the hashing concept will be used. There are buckets present and when we try to add a node which is already present, we will check in code using O(1) time complexity whether the current node is already present or not. When the case comes in which the current node is already present, then it is the required node.\n\nThe main idea of using the hashing concept is to reduce the time complexity as hash code for each node will be different, so using a new hashset will help to reduce the same complexity from O (N*N).\n\n##### Java Implementation\n\n```java\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n * \tint val;\n * \tListNode next;\n * \tListNode(int x) {\n *     \tval = x;\n *     \tnext = null;\n * \t}\n * }\n */\npublic class SolutionClass {\n\tpublic ListNode getIntNodeMethod(ListNode headA, ListNode headB) {\n   \t \n    \tHashSet<ListNode> map=new HashSet<>();\n    \tListNode tmp=headA;\n   \t \n    \twhile(tmp!=null)\n    \t{\n        \tmap.add(tmp);\n       \t \n        \ttmp=tmp.next;\n    \t}\n   \t \n    \ttmp=headB;\n   \t \n    \twhile(tmp!=null)\n    \t{\n        \tif(map.contains(tmp))return tmp;\n       \t \n        \ttmp=tmp.next;\n    \t}\n   \t \n    \treturn tmp;\n   \t \n\t}\n}\n```\n\n__Code Snippets__\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/6cc3X6S41uxi8ImglQpAD8/b123d101098b6322213616c066f02530/Intersection_of_Two_LinkedLists_-_ss7.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/6cc3X6S41uxi8ImglQpAD8/b123d101098b6322213616c066f02530/Intersection_of_Two_LinkedLists_-_ss7.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/6cc3X6S41uxi8ImglQpAD8/b123d101098b6322213616c066f02530/Intersection_of_Two_LinkedLists_-_ss7.png?w=30&h=30&fit=thumb\" alt=\"image\" loading=\"lazy\" /></picture>\n\n\n#### Two Pointers Approach\n\nIn the hashing technique we have O(N) time complexity but there is a chance that we can improve the complexity of finding the intersection by O(1). This can be achieved by taking two pointers. Pointer1 will point to the head of L1 and pointer2 will point to the head of L2.  The solution is that the intersection of the LinkedLists to the end of LinkedLists will be common, as the tail will be common in both LinkedLists. So we will keep checking until pointer1 is not equal to pointer2.\n\n##### Algorithm\n__Method:__ getIntNodeMethod(headA, headB) will be called passing pointer or head of both LinkedLists.\n__pointer1__, __pointer2__ will point to headA and headB respectively.\n__Loop__ → Run until pointer1 != pointer2\n    \n- __if__ pointer1 is equal to null,  set it as __headB__\n  __else__  pointer1= pointer1.next\n- __if__ pointer2 is equal to null, set is as __headA__\n  __else__ pointer2= pointer2.next\nReturn the __pointer2__\n\n##### Java Implementation\n\n```java\npublic class SolutionClass {\n\tpublic ListNode getIntNodeMethod(ListNode headA, ListNode headB) {\n   \t \n   \t \n    \tListNode pointer1= headA;\n    \tListNode pointer2= headB;\n   \t \n    \twhile( (pointer1 != pointer2) ){\n       \t \n        \tpointer1= pointer1.next;\n        \tpointer2= pointer2.next;\n       \t \n       \t \n        \tif(pointer1 == null)\n            \tpointer1=headB;\n        \tif(pointer2 == null)\n            \tpointer2 = headA;\n       \t \n    \t}\n    \treturn pointer1;\n   \t \n   \t \n\t}\n}\n```\n\n__Code Snippet__\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4CwETAMnSNVC4QppYyGXvK/be932d5b34c80ea7872d803b56ee5403/Intersection_of_Two_LinkedLists_-_ss8.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4CwETAMnSNVC4QppYyGXvK/be932d5b34c80ea7872d803b56ee5403/Intersection_of_Two_LinkedLists_-_ss8.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4CwETAMnSNVC4QppYyGXvK/be932d5b34c80ea7872d803b56ee5403/Intersection_of_Two_LinkedLists_-_ss8.png?w=30&h=30&fit=thumb\" alt=\"image\" loading=\"lazy\" /></picture>\n\n\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7pkcVHw39lnZ9pALSfDb8I","type":"Asset","createdAt":"2022-08-10T15:50:09.547Z","updatedAt":"2022-08-10T15:50:09.547Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"Intersection of Two LinkedList","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7pkcVHw39lnZ9pALSfDb8I/faca94fc767f799e74e7f1b2d038b655/Intersection_of_Two_LinkedList.jpg","details":{"size":185741,"image":{"width":1050,"height":600}},"fileName":"Intersection of Two LinkedList.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":3,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5VlvQn11IM6AF3cAjNZ1gy","type":"Entry","createdAt":"2022-05-11T07:11:39.558Z","updatedAt":"2022-05-11T07:11:39.558Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":57,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Reverse Doubly Linked Lists","slug":"reverse-doubly-linked-lists","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["Data Structures","JAVA"],"creationDate":"2022-05-11","readTime":"13min","content":"Suppose we are given a Doubly Linked List (DLL) and we need to reverse it so that the pointer currently pointing to the head of the list will point to the tail of the DLL. In this article we will learn about DLLs and then we will go through different methods of reversing a doubly linked list.\n\n### Difference Between a Linked List and Doubly Linked List\n\n#### Linked List\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/75dKfwFXZIBhf46T2VsL2E/d346a52487f1d0cca81253b87e01f47d/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/75dKfwFXZIBhf46T2VsL2E/d346a52487f1d0cca81253b87e01f47d/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/75dKfwFXZIBhf46T2VsL2E/d346a52487f1d0cca81253b87e01f47d/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n#### Doubly Linked List\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7GDBeNliJWFEDgBxmO31ZI/236f6874535ff6be253e032afd238783/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7GDBeNliJWFEDgBxmO31ZI/236f6874535ff6be253e032afd238783/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/7GDBeNliJWFEDgBxmO31ZI/236f6874535ff6be253e032afd238783/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### Structures of Singly and Doubly Linked Lists\n\n#### Singly Linked List\n```java\n// A Singly Linked List Node\nclass NodeStructure_SLL\n{\n    int data;\n    Node next; \n    Node(int data, Node next)\n    {\n        this.data = data;\n        this.next = next;\n    }\n}\n```\n\n#### Doubly Linked List\n\n```java\n// A Node Structure for Doubly LinkedList\nclass NodeStructure_DLL\n{\n    public:\n    int data;\n    Node* next; // ptr to nxt node in node in DLL\n    Node* prev; // prev Node in DLL\n\n      Node(int d)\n        {\n            data = d;\n            next = prev = null;\n        }\n\n};\n```\n\n### Structure \nThe basic structure of a linked list will have only data and a link to the next node. But, in the case of a doubly linked list it will include data, a link pointing to the previous node, and a second link pointing to the next node. In a single linked list we cannot traverse in a backward direction, but in a doubly linked list that is possible using the link which points to the previous node. This link to the previous node will increase access to elements of the doubly linked list. This also means that a doubly linked list will use more space as the number of fields will be increased by one for each node. We prefer a doubly linked list when space is not an issue and any traversal algorithm has to be performed.\n\n### Types\nThere are two types of doubly linked lists.\n\n#### Open Linked List\nA doubly linked list where the pointer to the next node of a last node is pointing to null.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1rpbmECaLogH3Pwp285vV4/453c1e154e70c8e8322668f715c321e2/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1rpbmECaLogH3Pwp285vV4/453c1e154e70c8e8322668f715c321e2/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1rpbmECaLogH3Pwp285vV4/453c1e154e70c8e8322668f715c321e2/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n#### Circular Linked List\nA doubly linked list where the pointer to the next node of the last node is pointing to the head node rather than pointing to null. This makes the DLL circular.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3PiPyVCJ8dnRxbA4BGl0qB/49ad53e7818806cdcb123f213455a681/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3PiPyVCJ8dnRxbA4BGl0qB/49ad53e7818806cdcb123f213455a681/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3PiPyVCJ8dnRxbA4BGl0qB/49ad53e7818806cdcb123f213455a681/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### Insertion Deletion Algorithms for Doubly Linked List\nInsertion complexity into singly linked lists is O(N), but in the case of a doubly linked list it becomes O(1) as we also have access to the previous node.\n\n#### Insertion in DLL\nIf we are given node (N1) after which we need to insert a new node (N2) in a DLL, then we will take the pointer to the next node of N1 and keep it in the next of N2. Then the address of current Node N1 will be placed in the first (pointer) of N2 and the address of N2 will be placed in the next (pointer) of N1.\n\n__Algorithm:__\nStep1 : InsertDLL(Node N2, Node current, Node head) // Current = N1\nStep2:  N2->next = current.next;\nStep3:  current.next= N2;\nStep4:  N2.first= current  \nStep5: Return Head of DLL\n\n#### Deletion in a Doubly Linked List\nSuppose a pointer pointing to a node is given which has to be deleted from a DLL. First we will check if this is the only node in the DLL. If yes, NULL (Empty DLL) will be returned, otherwise we will take the next (pointer) of the current node and keep it in next (pointer) of the previous node to this. Then we can remove or delete this node or it can be garbage collected.\n\n__Algorithm__\nStep1: DeleteNodeDLL(Node head, Node current)\n\nStep2: check if current Node if First Node, only One Node in DLL\nIf First Node then head= current->next; Then Step 4\nIf only one Node then head= null, then Step 4\n\nStep3:  prevNode=current.prev;\nprev.next=current.next;\n\nStep4: Return head\n\n#### Reversing a Doubly Linked List \nReversing a DLL is easier than reversing a singly linked list because of the presence of a pointer to the previous node. That means after the end of a function call where we are passing a head pointer to the DLL, we will get a linked list reversed, whose head will be pointing to the last node of passed DLL. In this we will check if the DLL has only one node, then head will be returned, or else we will take a current node and will store its pointer to prev node. Then we will take the next node (N2) of the current node and will make the next pointer of N2 point to the current node. Note we have to update the prev of the current node with temp. Then we can update the current node by making it point to the current’s prev pointer. For better understanding, it is helpful to take a paper and pen and draw a DLL and the process, using the steps accordingly as mentioned in the algorithm.\n\n__Algorithm__\n\nStep 1: function Called reverseDLL(Node head)\n\nStep 2: if head == null or head.next=null GOTO step 6\n\nStep 3: declaration \ntempNode with NULL\ncurrentNode pointing to head of DLL\n\nStep 4: Run a Loop until currentNode start pointing to NULL\n\nStep 5: Under Loop\n//will store the prev because next Node will be pointed from here as it will become previous to current Node \n→temp= current.prev \n//current Node should come after its Next Node so\n→current.prev=current.next\n//current’s previous Node should come after it so will take it and keep it in its Next \n//Which we have stored in temp\n→current.next=temp\n//Current Should be updated for processing next nodes\n→current= current.prev\nNote:\nReason behind above (current= current.prev) is as the next node has become previous to current node, we will take that node from current’s prev pointer.\n\nStep6: Return temp.prev as It will be New head of reversed DLL\n\n__Java Implementation__\n\n```java\npublic class UserDefDLL {\n\n\tpublic Node head;\n\tpublic Node tail;\n\n\tstatic class Node {\n\n    \t//data\n    \tint data;\n    \t// pointer to nxtNode\n    \tNode next;\n    \t// pointer to prevNode\n    \tNode prev;\n\n    \t}\n//Node Class Ends\n\n\t// Create a Doubly Linked List\n\tpublic UserDefDLL() {\n    \tthis.head = null;\n    \tthis.tail = null;\n\t}\n\n\t// Method for reversing doubly linked list\n\tpublic Node reverseDLL() {\n\n    \t//this will store our Previous Node which we will used to make prev Node\n    \t//to make it as Next node of Current Node\n    \tNode previousNode = null;\n\n    \tNode current = head;\n\n\twhile (current != null) {\n        \tpreviousNode = current.prev;\n        \tcurrent.prev = current.next;\n        \tcurrent.next = previousNode;\n        \tcurrent = current.prev;\n    \t}\n    \treturn previousNode;\n\t}\n}\n\npublic static void main(String[] args) {\n\n\t//userDefined Class for Doubly Linked List\n\tUserDefDLL dll = new UserDefDLL();\n\n\t//insertDLL will insert into DLL\n\tdll.insertDLL(4);\n\tdll.insertDLL(3);\n\tdll.insertDLL(2);\n\tdll.insertDLL(1);\n\t// Now DLL we have is 4->3->2->1\n\n\tdll = dll.reverseList();\n\n\t//Now we have reversed DLL\n}\n}\n```\n\n__Code Output__\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4EWHroFymAzRqDJD9WecGp/947facc7843060df27e810d74ff0ea56/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4EWHroFymAzRqDJD9WecGp/947facc7843060df27e810d74ff0ea56/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4EWHroFymAzRqDJD9WecGp/947facc7843060df27e810d74ff0ea56/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### References\nhttps://en.wikipedia.org/wiki/Theoretical_Computer_Science_(journal)\nhttps://www.worldscientific.com/doi/abs/10.1142/S0218195911003767\n","contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70ppAv0WygqfWWlipllAZu","type":"Entry","createdAt":"2020-02-20T15:37:44.048Z","updatedAt":"2022-02-13T10:37:14.930Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":372,"revision":78,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Data Structures","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Data Structures","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505847)\n<br/>\nEven though computers can perform literally millions of mathematical computations per second, when a problem gets large and complicated, performance can nonetheless be an important consideration. One of the most crucial aspects to how quickly a problem can be solved is how the data is stored in memory.\n\\\nTo illustrate this point, consider going to the local library to find a book about a specific subject matter. Most likely, you will be able to use some kind of electronic reference or, in the worst case, a card catalog, to determine the title and author of the book you want. Since the books are typically shelved by category, and within each category sorted by author’s name, it is a fairly straightforward and painless process to then physically select your book from the shelves.\n\\\nNow, suppose instead you came to the library in search of a particular book, but instead of organized shelves, were greeted with large garbage bags lining both sides of the room, each arbitrarily filled with books that may or may not have anything to do with one another. It would take hours, or even days, to find the book you needed, a comparative eternity. This is how software runs when data is not stored in an efficient format appropriate to the application.\n<br/><br/>\n### Simple Data Structures\nThe simplest data structures are primitive variables. They hold a single value, and beyond that, are of limited use. When many related values need to be stored, an array is used. It is assumed that the reader of this article has a solid understanding of variables and arrays.\n\\\nA somewhat more difficult concept, though equally primitive, are pointers. Pointers, instead of holding an actual value, simply hold a memory address that, in theory, contains some useful piece of data. Most seasoned C++ coders have a solid understanding of how to use pointers, and many of the caveats, while fledgling programmers may find themselves a bit spoiled by more modern “managed” languages which, for better or worse, handle pointers implicitly. Either way, it should suffice to know that pointers “point” somewhere in memory, and do not actually store data themselves.\n\\\nA less abstract way to think about pointers is in how the human mind remembers (or cannot remember) certain things. Many times, a good engineer may not necessarily know a particular formula/constant/equation, but when asked, they could tell you exactly which reference to check.\n<br/><br/>\n### Arrays\nArrays are a very simple data structure, and may be thought of as a list of a fixed length. Arrays are nice because of their simplicity, and are well suited for situations where the number of data items is known (or can be programmatically determined). Suppose you need a piece of code to calculate the average of several numbers. An array is a perfect data structure to hold the individual values, since they have no specific order, and the required computations do not require any special handling other than to iterate through all of the values. The other big strength of arrays is that they can be accessed randomly, by index. For instance, if you have an array containing a list of names of students seated in a classroom, where each seat is numbered 1 through n, then studentName[i] is a trivial way to read or store the name of the student in seat i.\n\\\nAn array might also be thought of as a pre-bound pad of paper. It has a fixed number of pages, each page holds information, and is in a predefined location that never changes.\n<br/><br/>\n### Linked Lists\nA linked list is a data structure that can hold an arbitrary number of data items, and can easily change size to add or remove items. A linked list, at its simplest, is a pointer to a data node. Each data node is then composed of data (possibly a record with several data values), and a pointer to the next node. At the end of the list, the pointer is set to null.\n\\\nBy nature of its design, a linked list is great for storing data when the number of items is either unknown, or subject to change. However, it provides no way to access an arbitrary item from the list, short of starting at the beginning and traversing through every node until you reach the one you want. The same is true if you want to insert a new node at a specific location. It is not difficult to see the problem of inefficiency.\n\\\nA typical linked list implementation would have code that defines a node, and looks something like this:\n<br/>\n```\nclass ListNode {\nString data;\nListNode nextNode;\n}\nListNode firstNode;\n```\n\\\nYou could then write a method to add new nodes by inserting them at the beginning of the list:\n<br/>\n```\nListNode newNode = new ListNode();\nNewNode.nextNode = firstNode;\nfirstNode = newNode;\n```\n\\\nIterating through all of the items in the list is a simple task:\n<br/>\n```\nListNode curNode = firstNode;\nwhile (curNode != null) {\nProcessData(curNode);\ncurNode = curNode.nextNode;\n}\n```\n\\\nA related data structure, the doubly linked list, helps this problem somewhat. The difference from a typical linked list is that the root data structure stores a pointer to both the first and last nodes. Each individual node then has a link to both the previous and next node in the list. This creates a more flexible structure that allows travel in both directions. Even still, however, this is rather limited.\n<br/><br/>\n### Queues\nA queue is a data structure that is best described as “first in, first out”. A real world example of a queue is people waiting in line at the bank. As each person enters the bank, he or she is “enqueued” at the back of the line. When a teller becomes available, they are “dequeued” at the front of the line.\n\\\nPerhaps the most common use of a queue within a topcoder problem is to implement a Breadth First Search (BFS). BFS means to first explore all states that can be reached in one step, then all states that can be reached in two steps, etc. A queue assists in implementing this solution because it stores a list of all state spaces that have been visited.\n\\\nA common type of problem might be the shortest path through a maze. Starting with the point of origin, determine all possible locations that can be reached in a single step, and add them to the queue. Then, dequeue a position, and find all locations that can be reached in one more step, and enqueue those new positions. Continue this process until either a path is found, or the queue is empty (in which case there is no path). Whenever a “shortest path” or “least number of moves” is requested, there is a good chance that a BFS, using a queue, will lead to a successful solution.\n\\\nMost standard libraries, such the Java API, and the .NET framework, provide a Queue class that provides these two basic interfaces for adding and removing items from a queue.\n\\\nBFS type problems appear frequently on challenges; on some problems, successful identification of BFS is simple and immediately, other times it is not so obvious.\n\\\nA queue implementation may be as simple as an array, and a pointer to the current position within the array. For instance, if you know that you are trying to get from point A to point B on a 50×50 grid, and have determined that the direction you are facing (or any other details) are not relevant, then you know that there are no more than 2,500 “states” to visit. Thus, your queue is programmed like so:\n<br/>\n```\nclass StateNode {\nint xPos;\nint yPos;\nint moveCount;\n}\n\n\nclass MyQueue {\nStateNode[] queueData = new StateNode[2500];\nint queueFront = 0;\nint queueBack = 0;\n\n\nvoid Enqueue(StateNode node) {\nqueueData[queueBack] = node;\nqueueBack++;\n}\n\n\nStateNode Dequeue() {\nStateNode returnValue = null;\nif (queueBack > queueFront) {\nreturnValue = queueData[queueFront];\nQueueFront++;\n}\nreturn returnValue;\n}\n\n\nboolean isNotEmpty() {\nreturn (queueBack > queueFront);\n}\n}\n```\n\\\nThen, the main code of your solution looks something like this. (Note that if our queue runs out of possible states, and we still haven’t reached our destination, then it must be impossible to get there, hence we return the typical “-1” value.)\n<br/>\n```\nMyQueue queue = new MyQueue();\nqueue.Enqueue(initialState);\nwhile (queue.isNotEmpty()) {\nStateNode curState = queue.Dequeue();\nif (curState == destState)\nreturn curState.moveCount;\nfor (int dir = 0; dir < 3; dir++) {\nif (CanMove(curState, dir))\nqueue.Enqueue(MoveState(curState, dir));\n}\n}\n```\n<br/><br/>\n### Stacks\nStacks are, in a sense, the opposite of queues, in that they are described as “last in, first out”. The classic example is the pile of plates at the local buffet. The workers can continue to add clean plates to the stack indefinitely, but every time, a visitor will remove from the stack the top plate, which is the last one that was added.\n\\\nWhile it may seem that stacks are rarely implemented explicitly, a solid understanding of how they work, and how they are used implicitly, is worthwhile education. Those who have been programming for a while are intimately familiar with the way the stack is used every time a subroutine is called from within a program. Any parameters, and usually any local variables, are allocated out of space on the stack. Then, after the subroutine has finished, the local variables are removed, and the return address is “popped” from the stack, so that program execution can continue where it left off before calling the subroutine.\n\\\nAn understanding of what this implies becomes more important as functions call other functions, which in turn call other functions. Each function call increases the “nesting level” (the depth of function calls, if you will) of the execution, and uses increasingly more space on the stack. Of paramount importance is the case of a recursive function. When a recursive function continually calls itself, stack space is quickly used as the depth of recursion increases. Nearly every seasoned programmer has made the mistake of writing a recursive function that never properly returns, and calls itself until the system throws up an “out of stack space” type of error.\n\\\nNevertheless, all of this talk about the depth of recursion is important, because stacks, even when not used explicitly, are at the heart of a depth first search. A depth first search is typical when traversing through a tree, for instance looking for a particular node in an XML document. The stack is responsible for maintaining, in a sense, a trail of what path was taken to get to the current node, so that the program can “backtrack” (e.g. return from a recursive function call without having found the desired node) and proceed to the next adjacent node.\n\\\n[Soma](http://community.topcoder.com/stat?c=problem_statement&pm=2824&rd=5073) (SRM 198) is an excellent example of a problem solved with this type of approach.\n<br/><br/>\n### Trees\nTrees are a data structure consisting of one or more data nodes. The first node is called the “root”, and each node has zero or more “child nodes”. The maximum number of children of a single node, and the maximum depth of children are limited in some cases by the exact type of data represented by the tree.\n\\\nOne of the most common examples of a tree is an XML document. The top-level document element is the root node, and each tag found within that is a child. Each of those tags may have children, and so on. At each node, the type of tag, and any attributes, constitutes the data for that node. In such a tree, the hierarchy and order of the nodes is well defined, and an important part of the data itself. Another good example of a tree is a written outline. The entire outline itself is a root node containing each of the top-level bullet points, each of which may contain one or more sub-bullets, and so on. The file storage system on most disks is also a tree structure.\n\\\nCorporate structures also lend themselves well to trees. In a classical management hierarchy, a President may have one or more vice presidents, each of whom is in charge of several managers, each of whom presides over several employees.\n\\\n[PermissionTree](http://community.topcoder.com/stat?c=problem_statement&pm=3093&rd=5864) (SRM 218) provides an unusual problem on a common file system.\n\\\n[bloggoDocStructure](http://community.topcoder.com/stat?c=problem_statement&pm=3025&rd=5860) (SRM 214) is another good example of a problem using trees.\n<br/><br/>\n### Binary Trees\nA special type of tree is a binary tree. A binary tree also happens to be one of the most efficient ways to store and read a set of records that can be indexed by a key value in some way. The idea behind a binary tree is that each node has, at most, two children.\n\\\nIn the most typical implementations, the key value of the left node is less than that of its parent, and the key value of the right node is greater than that of its parent. Thus, the data stored in a binary tree is always indexed by a key value. When traversing a binary tree, it is simple to determine which child node to traverse when looking for a given key value.\n\\\nOne might ask why a binary tree is preferable to an array of values that has been sorted. In either case, finding a given key value (by traversing a binary tree, or by performing a binary search on a sorted array) carries a time complexity of O(log n). However, adding a new item to a binary tree is an equally simple operation. In contrast, adding an arbitrary item to a sorted array requires some time-consuming reorganization of the existing data in order to maintain the desired ordering.\n\\\nIf you have ever used a field guide to attempt to identify a leaf that you find in the wild, then this is a good way to understand how data is found in a binary tree. To use a field guide, you start at the beginning, and answer a series of questions like “is the leaf jagged, or smooth?” that have only two possible answers. Based upon your answer, you are directed to another page, which asks another question, and so on. After several questions have sufficiently narrowed down the details, you are presented with the name, and perhaps some further information about your leaf. If one were the editor of such a field guide, newly cataloged species could be added to field guide in much the same manner, by traversing through the questions, and finally at the end, inserting a new question that differentiates the new leaf from any other similar leaves. In the case of a computer, the question asked at each node is simply “are you less than or greater than X?”\n<br/><br/>\n### Priority Queues\nIn a typical breadth first search (BFS) algorithm, a simple queue works great for keeping track of what states have been visited. Since each new state is one more operational step than the current state, adding new locations to the end of the queue is sufficient to insure that the quickest path is found first. However, the assumption here is that each operation from one state to the next is a single step.\n\\\nLet us consider another example where you are driving a car, and wish to get to your destination as quickly as possible. A typical problem statement might say that you can move one block up/down/left/right in one minute. In such a case, a simple queue-based BFS works perfectly, and is guaranteed to provide a correct result.\n\\\nBut what happens if we say that the car can move forward one block in two minute, but requires three minutes to make a turn and then move one block (in a direction different from how the car was originally facing)? Depending on what type of move operation we attempt, a new state is not simply one “step” from the current state, and the “in order” nature of a simple queue is lost.\n\\\nThis is where priority queues come in. Simply put, a priority queue accepts states, and internally stores them in a method such that it can quickly pull out the state that has the least cost. (Since, by the nature of a “shortest time/path” type of problem, we always want to explore the states of least cost first.)\n\\\nA real world example of a priority queue might be waiting to board an airplane. Individuals arriving at their gate earlier will tend to sit closest to the door, so that they can get in line as soon as they are called. However, those individuals with a “gold card”, or who travel first class, will always be called first, regardless of when they actually arrived.\n\\\nOne very simple implementation of a priority queue is just an array that searches (one by one) for the lowest cost state contained within, and appends new elements to the end. Such an implementation has a trivial time-complexity for insertions, but is painfully slow to pull objects out again.\n\\\nA special type of binary tree called a heap is typically used for priority queues. In a heap, the root node is always less than (or greater than, depending on how your value of “priority” is implemented) either of its children. Furthermore, this tree is a “complete tree” from the left. A very simple definition of a complete tree is one where no branch is n + 1 levels deep until all other branches are n levels deep. Furthermore, it is always the leftmost node(s) that are filled first.\n\\\nTo extract a value from a heap, the root node (with the lowest cost or highest priority) is pulled. The deepest, rightmost leaf then becomes the new root node. If the new root node is larger than at at least one of its children, then the root is swapped with its smallest child, in order to maintain the property that the root is always less than its children. This continues downward as far as necessary. Adding a value to the heap is the reverse. The new value is added as the next leaf, and swapped upward as many times as necessary to maintain the heap property.\n\\\nA convenient property of trees that are complete from the left is that they can be stored very efficiently in a flat array. In general, element 0 of the array is the root, and elements 2k + 1 and 2k + 2 are the children of element k. The effect here is that adding the next leaf simply means appending to the array.\n<br/><br/>\n### Hash Tables\nHash tables are a unique data structure, and are typically used to implement a “dictionary” interface, whereby a set of keys each has an associated value. The key is used as an index to locate the associated values. This is not unlike a classical dictionary, where someone can find a definition (value) of a given word (key).\n\\\nUnfortunately, not every type of data is quite as easy to sort as a simple dictionary word, and this is where the “hash” comes into play. Hashing is the process of generating a key value (in this case, typically a 32 or 64 bit integer) from a piece of data. This hash value then becomes a basis for organizing and sorting the data. The hash value might be the first n bits of data, the last n bits of data, a modulus of the value, or in some cases, a more complicated function. Using the hash value, different “hash buckets” can be set up to store data. If the hash values are distributed evenly (which is the case for an ideal hash algorithm), then the buckets will tend to fill up evenly, and in many cases, most buckets will have no more than one or only a few objects in them. This makes the search even faster.\n\\\nA hash bucket containing more than one value is known as a “collision”. The exact nature of collision handling is implementation specific, and is crucial to the performance of the hash table. One of the simplest methods is to implement a structure like a linked list at the hash bucket level, so that elements with the same hash value can be chained together at the proper location. Other, more complicated schemes may involve utilizing adjacent, unused locations in the table, or re-hashing the hash value to obtain a new value. As always, there are good and bad performance considerations (regarding time, size, and complexity) with any approach.\n\\\nAnother good example of a hash table is the Dewey decimal system, used in many libraries. Every book is assigned a number, based upon its subject matterï¿½ the 500′s are all science books, the 700′s are all the arts, etc. Much like a real hash table, the speed at which a person could find a given book is based upon how well the hash buckets are evenly dividedï¿½ It will take longer to find a book about frogs in a library with many science materials than in a library consisting mostly of classical literature.\n\\\nIn applications development, hash tables are a convenient place to store reference data, like state abbreviations that link to full state names. In problem solving, hash tables are useful for implementing a divide-and-conquer approach to knapsack-type problems. In LongPipes, we are asked to find the minimum number of pipes needed to construct a single pipe of a given length, and we have up to 38 pieces of pipe. By dividing this into two sets of 19, and calculating all possible lengths from each set, we create hash tables linking the length of the pipe to the fewest number of segments used. Then, for each constructed pipe in one set, we can easily look up, whether or not we constructed a pipe of corresponding length in the other set, such that the two join to form a complete pipe of the desired length.\n<br/><br/>\n### Conclusion\nThe larger picture to be seen from all of this is that data structures are just another set of tools that should be in the kit of a seasoned programmer. Comprehensive libraries and frameworks available with most languages nowadays preempt the need for a full understanding of how to implement each of these tools. The result is that developers are able to quickly produce quality solutions that take advantage of powerful ideas. The challenge lies in knowing which one to select.\n\\\nNonetheless, knowing a little about how these tools work should help to make the choices easier. And, when the need arises, perhaps leave the programmer better equipped to think up a new solution to a new problemï¿½ if not while on the job doing work for a client, then perhaps while contemplating the 1000 point problem 45 minutes into the coding phase of the next SRM.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"5rg0EyMG9aQUeBU99KbVPd"}}],"upvotes":34,"downvotes":3,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"28xML395bHNDwAhdOKvY9R"}},{"sys":{"type":"Link","linkType":"Entry","id":"3RUcXHuc3tXWkmdesAkmr7"}},{"sys":{"type":"Link","linkType":"Entry","id":"6qQ5n5nHfLRZ0DyCdK5Zfg"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6LQfbpjC6eQK3yXQpKUVMr"}},{"sys":{"type":"Link","linkType":"Entry","id":"3YPeWSMpzjxNxU8zacGgjg"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2TPj3zj55v9LV4V1t5GsyV","type":"Entry","createdAt":"2021-12-11T13:49:57.177Z","updatedAt":"2022-08-26T21:41:12.616Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":55,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Flatten Binary Tree to Linked List","slug":"flatten-binary-tree-to-linked-list","type":"Article","trackCategory":["Competitive Programming"],"tags":["C++","Binary Tree"],"creationDate":"2021-12-11","readTime":"9min","content":"### About the Problem:\nIn this problem, we are provided with the root of the binary tree and we should use the same BinaryTreeNode to flatten the binary tree (i.e, in-place ). Each right pointer should point to the next node, the left should be NULL, and the list should be in pre-order traversal format.\n\n### Structure of BinaryTreeNode\n```cpp\nstruct Treenode{\n    int val;\n    Treenode *left,*right;\n};\n\nStructure of LinkedListNode\nstruct ListNode{\n    int val;\n    ListNode *next;\n};\n```\n\nExample 1:\nInput: \\[2,3,4,5,6,null,9,8\\]\n\n![image](//images.ctfassets.net/piwi0eufbb2g/5fRwIzc8I4acOUrKnRBZnd/80457c06218a5db20ee66458c7d8712f/image.png)\n\nOutput: \\[2,null,3,null,5,null,8,null,6,null,4,null,9\\]\n![image](//images.ctfassets.net/piwi0eufbb2g/7KzYAY9rSsjfAnOmWRW7CA/e4787231cc13c9588f5af29cf4a2c968/image.png)\n\nExample 2:\nInput: \\[5,7,10,null,4,null,12,11,3,4,6,7\\]\n\n### Approach #1: Recursion\nIn this approach, we are going to use post-order traversal where we visit left, right, and then the root. This is very convenient when we have to deal with links because we go from bottom to top, fixing the bottom then going up. Here we have all left nodes as NULL, therefore we change our order, i.e, we go right, left, then root.\n\n__Algorithm:__\n1. Declare a variable prev, to keep track of the previously visited node.\n2. Pass the root node to function flatten and check where it’s NULL or not if NULL returns.\n3. Make a recursion call for the right subtree and the same for the left subtree.\n4. To flatten the binary tree, we first set the right pointer to the previously visited node and left to NULL.\n5. Set the prev to the current node.\n\n__Code Implementation:__\n```cpp\nTreenode *prev = NULL;\n\nvoid flatten(Treenode* root){\n    if (!root)\n        return;\n    flatten(root->right);\n    flatten(root->left);\n\n    root->right = prev;\n    root->left = NULL;\n    prev = root;\n}\n```\n\nTime complexity: O(n), for visiting all the nodes in the tree once.\nSpace complexity: O(n), we are making a recursion call for every node in the tree.\n\n### Approach #2: Stack\nIn this approach to counter our call stack, we will use an explicit stack.\n\n__Algorithm:__\n1. Push the root node into an empty stack.\n2. Run the while loop until the stack isn't empty.\n3. Pop the top node, check for its right and left child, and push them into the stack.\n4. If the stack isn't empty, set the proper child of the present popped node to the top of the stack and left to NULL.\n\n__Code Implementation:__\n```cpp\nvoid flatten(Treenode* root)\n{\n    if (!root)\n        return;\n    stkack<Treenode*> stk;\n    stk.push(root);\n\n    while (!stk.empty()){\n        TreeNode* curr = stk.top();\n        stk.pop();\n        if (!curr->right)\n            stk.push(curr->right);\n        if (!curr->left)\n            stk.push(curr->left);\n        if (!stk.empty())\n            curr->right = stk.top();\n\n        curr->left = NULL;\n    }\n}\n```\n\nTime complexity: O(n), for visiting all the nodes in the tree once.\nSpace complexity: O(n), for storing all the nodes in the stack.\n\n### Approach #3: Iterative ( Space Efficient )\nThis approach works in O(1) space complexity. If we observe the resultant tree, every right child points to the next node of a pre-order traversal. In the case where there is no left child we only have to handle the right child. And if the left child exists, then the immediate next element in the pre-order traversal is the left child. In simpler terms, the right subtree comes right after the rightmost node in the left subtree in the pre-order traversal.\nHere we find the rightmost node in the left subtree and assign the right subtree to its right child. Make the left child the right child and traverse to the next node.\n\n__Algorithm:__\n1. Make a curr node pointing to root and do a while loop until not equal to NULL.\n2. Now check if it has a left child,\n  a. If yes, traverse to the rightmost node in the left subtree\n  b. Now set the rightmost node right child to curr right\n  c. And curr right to curr left and left to NULL\n3. Now move to the right subtree.\n\n__Code Implementation:__\n```cpp\nvoid flatten(Treenode *root)\n{\n    Treenode* curr = root;\n    while (curr != NULL)\n    {\n        if (curr->left != NULL)\n        {\n          Treenode* prev = curr->left;\n          while (prev->right)\n                prev = prev->right;\n          prev->right = curr->right;\n          curr->right = curr->left;\n          curr->left = NULL;\n        }\n        curr = curr->right;\n    }\n}\n```\n\nTime complexity: O(n), for visiting all the nodes in the tree once.\nSpace complexity: O(1) only one variable is used.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5SgnMyymPz8xOByiJ2tWkg","type":"Asset","createdAt":"2021-12-11T13:37:20.463Z","updatedAt":"2021-12-11T13:37:20.463Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"flatten","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5SgnMyymPz8xOByiJ2tWkg/0785c506c25aa2a283eef647e0d23d53/flatten.jpeg","details":{"size":88846,"image":{"width":558,"height":447}},"fileName":"flatten.jpeg","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3KyUElaXRZQAZv87oXv9jx"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"38HBoqJsM8qEaQ104fiS1M","type":"Entry","createdAt":"2021-11-15T14:46:15.256Z","updatedAt":"2021-11-15T21:29:11.636Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":42,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Ternary Search Trees","slug":"ternary-search-trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"675c3u6tacMXieHHlB6n7X"}}],"tags":["Trees","C++"],"creationDate":"2021-11-15","readTime":"9min","content":"Ternary search trees are a similar data structure to binary search trees and tries. They encapsulate the memory efficiency of binary search trees and time efficiency of tries.\n\nWe know that by using tries we can search and sort strings efficiently, but it consumes a lot of memory. Here we can use ternary search trees instead, which store fewer references and null objects.\n\nCharacteristics of **Ternary Search Trees (TST)**\n\n-   TST stores characters or strings in nodes\n\n-   Each node has three children: left, equal, right\n\n-   The left pointer contains all the strings which are alphabetically less than the data\n\n-   The equal pointer contains all the strings which are alphabetically equal to the data\n\n-   The right pointer contains all the strings which are alphabetically greater than the data\n\n![image](//images.contentful.com/piwi0eufbb2g/oAztgp79Z1dhuvV7cQQw8/19c74ee1250af0f1eff89d03b3ba0d68/image.png)\n\nTernary search trees declaration\n\n```cpp\nstruct TSTNode{\n    char data;\n    int isEnd;\n    TSTNode* left;\n    TSTNode* equal;\n    TSTNode* right;\n};\n```\n\n![image](//images.contentful.com/piwi0eufbb2g/AwT8SMzqwsJQAfyi0zyrA/d89bb81e06aa796ff15c077d74c74078/image.png)\n\nIn general, we have as many pointers/edges from every node as the number of characters in the alphabet.\nWe have to define an alphabet in advance  + ALP_SIZE. For example: in the English alphabet, there are 26 characters, so ALP_SIZE = 26 -> 26 pointers from every node.\n\n### Inserting string in the TST:\nTo explain it further, we will try to insert some strings in the TST: boats, boat, bat, bats.\n\nWe will insert in this order:\n\nFirst, let's insert boats.\n\n![image](//images.contentful.com/piwi0eufbb2g/6or1ohWIWbWaDuDAZty6jD/a769cd79c81cb7faa491d7f4460d5686/image.png)\n\nNow to insert boat to our TST we just have to mark isEnd of of “t” to 1.\n\n![image](//images.contentful.com/piwi0eufbb2g/3ziV7i7O1MyjDaOB95KLXk/7ff3ecba60eb522ba3cfe5d748217c5b/image.png)\n\nNow, let’s insert *bat*.\n\n![image](//images.contentful.com/piwi0eufbb2g/1cwH4KYPs1Ttr1QYyId4WQ/406f933f4b9fcc2d3d4c5d02134ad74f/image.png)\n\nNow, at last, insert *bats*.\n\n![image](//images.contentful.com/piwi0eufbb2g/CKnQoqiSHmEYP6UdbOkVx/5fe863317da7fd70a6eb4bc4ddac1b1b/image.png)\n\n#### Code for inserting into TST:\n```cpp\nTSTNode *insertInTST(TSTNode* root, char *word){\n\n    if(root == NULL){\n        root = new TSTNode();\n        root->data = *word;\n        root->isEnd = 1;\n        root->left = root->equal = root->right = NULL;\n    }\n\n    if(*word < root->data)\n        root->left = insertInTST(root->left,word);\n    else if(*word == root->data){\n        if(*(word+1))\n            root->equal = insertInTST(root->equal,word+1);\n        else \n            root->isEnd = 1;\n    }\n    else \n        root->right = insertInTST(root->right,word);\n    return root;\n}\n```\n\nTime Complexity: O(N), where N is the length of the string to be inserted.\n\n### Searching string in the TST:\nWhile searching we can follow the same procedure as the binary search tree. The only difference is that in cases when the character matches we check for the remaining characters instead of returning.\n\n#### Code for searching into TST:\n```cpp\nint searchInTST(TSTNode *root,char *word){\n\n    if(!root)\n        return -1;\n    if(*word < root->data)\n        return searchInTST(root->left,word);\n    else if(*word > root->data)\n        return searchInTST(root->right,word);\n    else{\n        if(root->isEnd && *(word+1) == 0)\n            return 1;\n        return searchInTST(root->eq,word+1);\n    }\n}\n```\n\nTime Complexity: O(N), where N is the length of the string to be searched.\n\n### TST vs Hashing\n#### TST\n\n-   Works for strings\n\n-   Examines just enough key characters\n\n-   May only miss a few characters \n\n-   Supports much more operation\n\n-   More flexible than binary search trees\n\n-   Faster than hashing \n\n#### Hashing\n\n-   Needs to examine the entire key\n\n-   Search hits and misses cost the same\n\n-   Run time and performance relies heavily on the hash function\n\n-   Does not support as much operation as TST \n\n#### Applications of TST\n\n-   It can be used to implement the auto-complete feature efficiently\n\n-   Can be used for spell checkers \n\n-   Near neighbor searching \n\n-   For databases, especially when indexing by several non-key fields.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5OnWggND3ytsXYNaJSC2WH","type":"Asset","createdAt":"2021-11-15T14:38:22.172Z","updatedAt":"2021-11-15T14:46:12.965Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"ternary","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5OnWggND3ytsXYNaJSC2WH/7f23bc81873fd8fb13833189e830b0e2/ternary.jpeg","details":{"size":25803,"image":{"width":709,"height":355}},"fileName":"ternary.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":0,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"sys":{"type":"Link","linkType":"Entry","id":"3nm4uYV8GUkxOpsUgx23SF"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6J8EpHrDKfR6sF67sf5PbE"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"bVyyo5py0gykE4M3Qo73C","type":"Entry","createdAt":"2021-11-20T15:09:24.320Z","updatedAt":"2021-12-03T16:05:59.917Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":54,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Merging Two Sorted LinkedLists","slug":"merging-two-sorted-linkedlists","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["JAVA"],"creationDate":"2021-11-20","readTime":"7min","content":"Suppose we are given two LinkedLists which are sorted in increasing order and we need to merge them into one. We will create a method, __mergeLinkedList()__, which will traverse both the LinkedLists, merge them into a single LinkedList, and return the single LinkedList.\nThe new returned LinkedList will have all the nodes which are present in both original LinkedLists.\nIf we have, \n\n__LikedList1__:  2 -> 5 -> 9 -> 12 -> 15 -> 20\n\n__And__\n\n__LinkedList2__:  3 -> 7 -> 10 -> 17 -> 22\n\nthen our method should return the head pointer pointing to a merged LinkedList.\n\n__Merged LinkedList:__  2 -> 3 -> 5 -> 7 -> 9 -> 10 -> 12 -> 15 -> 17 -> 20 \n->22\t\n\n### Methods of Merging \n#### Method: Using Dummy Nodes\nIn this example we will create a dummy node as a result of our merged LinkedList. The tail pointer will point to the dummy node initially and then we will have a tail pointer pointing to the last node of our result list. \n\n##### Algorithm for Dummy Nodes\n__Declaration__\ncreate two Nodes\ndummyNode =null\ntail = dummyNode;\n\n__Execution__\n__Step 1:__\nif List1=null\nwe have traversed the List1 or List1 is empty\nthen tail.next will point to List2\n\nif List2=null\nwe have traversed the List2 or List2 is empty\nthen tail.next will point to List1\n\n__Step 2:__\n\t  check if list1.data < list2.data\n\t\t   then tail.next will point to node containing List1.data\n\t\t   update list1=list.next\n\t\t else\n\t\t       tail.next will point to node containing List2.data\n\t\t       update list2=list.next\n\n__Step 3:__\n\t\tif both lists not processed then\n\t\tupdate tail and  go to step 1\n\t\telse go to Step 4\n\n__Step 4:__  \tReturn dummyNode.next\n\n__Java Implementation for Dummy Nodes__\n```java\nclass Solution\n{\n//will return a node pointing to Result List\nNode mergeLinkedList(Node listA, Node listB)\n{\n\n\t//create dummy Node\n    Node dummyNode = new Node();\n\n    Node tail = dummyNode;\n\n\t//will break out of Loop\n    while(true)\n    {\n        //check if listA is empty of traversed\n        if(listA == null)\n        {\n            tail.next = listB;\n            break;\n        }\n\t\t//check if listB is empty of traversed\n        if(listB == null)\n        {\n            tail.next = listA;\n            break;\n        }\n\n        /* \n\t\tcheck which listdata is lesser will be appended to\n\t\t tail.next\n        */\n        if(listA.data <= listB.data)\n        {\n            tail.next = listA;\n            listA = listA.next;\n        }\n        else\n        {\n            tail.next = listB;\n            listB = listB.next;\n        }\n\n        //update tail\n        tail = tail.next;\n    }\n\t//returning the Result List\n    return dummyNode.next;\n}//method Ends\n\n}//Class Ends\n```\n\n#### Method: Using Recursion\nIn the above method we tried the iterative approach using dummy nodes. Now we will try the recursion technique to merge two sorted LinkedLists. There is less code than with the iterative approach as it uses the call stack to call itself to work with passed arguments.\n\n##### Algorithm\n\n__Step 1:__ Call made to mergeLinkedList() and list1 and List2 will be passed\n\n__Step 2:__\n\tif list1 is empty return list2\n\tif list2 is empty return list1\n\n__Step 3:__\n\tif list1.data < list2.data\n\tthen call mergeLinkedList(list1.next, list2) to Step 1\n\tand return list1\n\telse\n\tcall mergeLinkedList(list1, list2.next) to Step 1\n\tand return list2\n\n__Java Implementation Using Recursion__\n```java\nclass Solution\n{ \n//Result List will listBe returned\nNode sortedMerge(Node listA, Node listB)\n{\n     if(listA == null) return listB;\n        if(listB == null) return listA;\n\n        if(listA.dlistAtlistA < listB.dlistAtlistA)\n        {\t//call mergeLinkedList recurively\n            listA.next = SortedMerge(listA.next, listB);\n            return listA;\n        }\n        else\n        {\t//call mergeLinkedList recurively\n            listB.next = SortedMerge(listA, listB.next);\n            return listB;\n        }\n\n    }\n}\n```\n\n#### Method: Reversing LinkedLists\nIn this method we will maintain both the LinkedLists in decreasing order; this means both LinkedLists will be reversed. Then, comparing the head of each list and adding to the last of the resultant list will get the LinkedList in increasing order.\n\n__Java Implementation__\n```java\nclass Solution\n{ \n\nNode reverseLL(Node A)\n    {\n        Node prev = null;\n        Node current = A;\n        Node next = null;\n        while (current != null) {\n            next = current.next;\n            current.next = prev;\n            prev = current;\n            current = next;\n        }\n        A = prev;\n        return A; //returning reversed LList\n\n    }\n//Result List will listBe returned\nNode sortedMerge(Node listA, Node listB)\n{\n\tlistA=reverseLL(listA);\n\tlistB=reverseLL(listB);\n\n\tNode res=null;\n\tNode temp=null;\n\n\twhile(listA!=null && listB!=null)\n\t{\t\n\n\t\t if (listA.data >= listB.data) {\n             temp = listA.next;\n\n            listA.next= res;\n                      res = listA;\n\n            listA = temp;\n        }\n        else {\n\n            temp = listB.next;\n            listB.next;= ress;\n            res= listB;\n            listB = temp;\n        }\n\n}\n\n    }//methodSM Ends\n}\n```\n\n#### Method: Using Local Reference\nIn this method we will use a local reference variable which will point to the head of the result node. We will use infinite iteration to execute the same.\n\n#### Algorithm\n\n__Step 1:__ Call made to mergeLinkedList() and list1 and List2 will be passed\n\n__Step 2:__\n\tif list1 is empty return list2\n\tif list2 is empty return list1\n\n__Step 3:__\nLoop ,Iteration for each Node\nif list1.data < list2.data\nthen call put current head of list1 in next of result\nif list2.data < list1.data\nthen call put current head of list2 in next of result\n\ncheck if any list is empty\nthen add second list to end of result ilst and break\n\nreturn the result\n\n__Java Implementation__\n```java\nclass Solution\n{ \n//Result List will listBe returned\nNode sortedMerge(Node listA, Node listB)\n{   Node resultLL=null;\n     if(listA == null) return listB;\n        if(listB == null) return listA;\n\nfor(int i=1;i>0;)\n{\n\tif(listA.data<listB.data)\n\t{ resultLL.next=listA;\n\t   listA=listA.next;\n\t}\n\telse\n\t{\n resultLL.next=listB;\nlistB=listB.next;\n}\nif(listA==null)\n{\n\tresultLL.next=listB; break;\n}\nif(listB==null)\n{\n\tresultLL.next=listA; break;\n}\n}   //for loop ends      \n    }\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1ZaMXHSILRR4CTOabSGHTC","type":"Asset","createdAt":"2021-11-20T15:00:35.154Z","updatedAt":"2021-11-20T15:00:35.154Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Banner (5)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1ZaMXHSILRR4CTOabSGHTC/4c307af9eca5c2bbcb60a61b675f21c6/Banner__5_.png","details":{"size":13435,"image":{"width":1050,"height":600}},"fileName":"Banner (5).png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"74eK6bUhfnKnzBkBpjSREj"}},{"sys":{"type":"Link","linkType":"Entry","id":"3RUcXHuc3tXWkmdesAkmr7"}}]}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2Ar5mm5Pz4GvbXckWOGdHj","type":"Entry","createdAt":"2021-12-15T09:54:12.635Z","updatedAt":"2024-09-28T08:18:09.045Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":73,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"B-Tree","slug":"b-tree","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["JAVA"],"creationDate":"2021-12-15","readTime":"25min","content":"B-Tree is a unique kind of self-balancing tree primarily used for searching an element more efficiently. Unlike binary trees, in B-Tree every node can contain more than one piece of data and can have more than two children. It is an extended and generalized shape of the binary search tree and is also known as a height-balanced m-way tree. You can visualize all the things mentioned above in this diagram.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/UdJfa5iIxqVkx9Tr7kUPr/baaa9014c047f0268b0d03e87ddf444b/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/UdJfa5iIxqVkx9Tr7kUPr/baaa9014c047f0268b0d03e87ddf444b/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/UdJfa5iIxqVkx9Tr7kUPr/baaa9014c047f0268b0d03e87ddf444b/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### Need for B-Tree\n\nSecondary storage devices or physical storage media like hard disks, etc., have larger capacity but are slower due to low accessing time. There was a need for such sorts of data structures that limit disk access.\n\nBut still, that’s not a statement which clears the need for B-Tree. Among all data structures used for searching we are familiar with binary search trees, AVL trees, Red-Black trees, etc.. So why B-Tree? Because in all those data structures each node can contain only one key and in order to store a large number of keys, one has to face high access time because the height of such trees becomes very large. However, B-Tree can contain many keys in a single node and can have more than two children. Therefore, for a large number of keys the height of the tree is significantly lower and  results in faster disk access.\n\n### B-Tree Operations\n\nVarious operations can be done on B-Tree but its main usage is a generalized and extended form of Binary Search Tree (BST) for searching an element present in the tree. Let’s learn about how to search an element first then we will learn how to perform insertion and deletion operations on B-Tree.\n\n#### Searching an element in a B-Tree\n\nLet **n** be the element to be searched, then the following steps are followed to search **n** in B-Tree-\n\n1.  Initiating from the root node of the tree, we check equality between **n** and the first key of the node. If they both are equal then we return that node along with its index.\n\n2.  If **n.leaf** is equal to true that means we are at the last node and there is no more path and the chance remains for **n** to exist in that tree. So, in that case, we return NULL that is not found.\n\n3.  If the value of **n** is less than the first value of the node that means the only possibility of **n** existing is in the left subtree of the tree. So to do so we will search **n** further recursively in the left part of the tree.\n\n4.  If there are multiple keys in the node and the value of **n** is more than  the first key then compare the value of **n** with the next key within the node. If **n** is less than the next key continue the search in the left child of the key, else in the right child of the key that is **n** lies in between the first and second keys.\n\n5.  Iterate steps one to four until we meet the leaf node.\n\n**Algorithm for searching an element-**\n```java\nsearchElement(m, x):\n  i = 1\n  while i ≤ n[m] and x ≥ keyi[m]      \n  // n[m] : number of keys in m node\n  do i = i + 1\n  if i  n[m] and x = keyi[m]\n  then return (m, i)\n  if leaf [m]\n  then return NIL\n  else return searchElement(ci[m], x)\n```\n\n#### Insertion of an element in a B-Tree\n\nInsertion operation always follows a bottom-up fashion to insert an element in the B-Tree and generally takes two steps to be done. The first is to search for a suitable node in the tree to insert the element and then split the nodes if required. The steps are given below to do an insertion in B-Tree-\n\n1.  If the tree has no node, i.e., empty, then simply insert it and assign it as the root node.\n\n2.  Update the value of the permitted number of keys within the node.\n\n3.  For insertion, search for a suitable node.\n\n4.  If and only if the node is full then follow the steps given below, otherwise skip to step eight.\n\n5.  Continue insertion of elements in ascending order.\n\n6.  If the number of elements exceeds its limit value then split it at the median.\n\n7.  Send the key at the median up and assign right keys to the right child and left keys to the left child of it.\n\n8.  If the capacity of the node isn’t full then insert the node in the tree in ascending order.\n\nLet show an example of inserting the following keys **\\[****8 9 10 11 15 20 17\\]**  in the B-Tree -\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1K7Hu4Vp5MrCyzCUUVHiQK/cd8e93390e831ee84ba3fd533620a474/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1K7Hu4Vp5MrCyzCUUVHiQK/cd8e93390e831ee84ba3fd533620a474/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1K7Hu4Vp5MrCyzCUUVHiQK/cd8e93390e831ee84ba3fd533620a474/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n__Algorithm for inserting an element-__\n```java\n    insertElement(T, K):\n    R = root[T]\n    if N[R] = 2T - 1\n        S = AssignNode()\n        root[T] = S\n        leaf[S] = false\n        N[S] = 0\n        c1[S] = R\n        splitChild(S, 1, R)\n        insertNonFull(S, K)\n    else insertNonFull(R, K)\n\n    insertNonFull(X, K):\n    i = N[X]\n    if leaf[X]\n        while i ≥ 1 and K < key_i[X]\n            key_i+1 [X] = key_i[X]\n            i = i - 1\n        key_i+1[X] = K\n        N[X] = N[X] + 1\n    else while i ≥ 1 and K < key_i[X]\n            i = i - 1\n        i = i + 1\n        if N[ci[X]] == 2t - 1\n            splitChild(X, i, ci[X])\n            if K < key_i[X]\n                i = i + 1\n        insertNonFull(ci[X], K)\n    splitChild(X, i)\n    splitChild(X, i, y)\n    z = AssignNode()\n\n    leaf[z] = leaf[y]\n    N[z] = t - 1\n    for j = 1 to t - 1\n        key_j[z] = key_j+t[y]\n    if not leaf [y]\n        for j = 1 to t\n            cj[z] = cj + t[y]\n    N[y] = t - 1\n    for j = N[X] + 1 to i + 1\n        cj+1[X] = cj[X]\n    ci+1[X] = z\n    for j = N[X] to i\n        key_j+1[X] = key_j[X]\n    key_i[X] = key_t[y]\n    N[X] = N[X] + 1\n```\n\n#### Deletion of an element in a B-Tree\nDeletion operation on B-Tree generally takes three steps - searching for a node that contains the key to be deleted, deletion of that key, and then if required, balancing of the tree. While deleting, a condition may occur when we try to delete and there is no node present in the tree. That condition is known as underflow of the tree.\nThere are three type cases of deletion-\n\n- __CASE 1-__ The key to be deleted is in the leaf node. One thing to keep in mind is that deletion of the key should not violate the property of the minimal number of keys a node has. In the below example if we delete 32 from the tree then the resulting tree will look like this.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2BNSGXErUOG1Kmzu3SsRaq/af254bb7fe3e2dec9f6cf895fc024356/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2BNSGXErUOG1Kmzu3SsRaq/af254bb7fe3e2dec9f6cf895fc024356/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2BNSGXErUOG1Kmzu3SsRaq/af254bb7fe3e2dec9f6cf895fc024356/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n- __CASE 2-__ If the key to be deleted lies in between inner nodes then the inner node which is going to be deleted is replaced by its inorder predecessor (largest key in the left subtree of the node). If the value of the minimum number of keys in the left child exceeds its limit, and is replaced by inorder successor (largest key in the right subtree of the right child) in the case of the right child exceeding the value of the minimum number of keys it can hold. Otherwise if the child has the exact minimum number of keys, merge both its right and left children. If we delete 33 in the below case it results-\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/18AJduOnPdPz7wQPgmioK7/81827484024cb72fa01eeb93f977771d/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/18AJduOnPdPz7wQPgmioK7/81827484024cb72fa01eeb93f977771d/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/18AJduOnPdPz7wQPgmioK7/81827484024cb72fa01eeb93f977771d/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n- __CASE 3-__ If the key to be deleted lies in between inner nodes and deletion of it results in less than the minimum required number of keys in the node, we have to shrink the size of the tree. For this to be done first we have to find its inorder successor and predecessor and if both of the children have the least number of keys then we have to merge the children. To understand it more clearly look at the example below of deleting 10 from the tree-\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1rArbD2VX2s5WfjgwkN9kG/58340bbf682a466e37c3861788d1247a/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1rArbD2VX2s5WfjgwkN9kG/58340bbf682a466e37c3861788d1247a/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1rArbD2VX2s5WfjgwkN9kG/58340bbf682a466e37c3861788d1247a/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n__Code__\n\n```java\n public class BTree {\n    private int BT;\n    public class TreeNode {\n      int n;\n      int node_key[] = new int[(2 * BT) - 1];\n      TreeNode child_node[] = new TreeNode[2 * BT];\n      boolean is_leaf = true;\n\n      public int find_one(int ktr) {\n        for (int itr = 0; itr < this.n; itr++) {\n          if (this.node_key[itr] == ktr) {\n            return itr;\n          }\n        }\n        return -1;\n      };\n    }\n\n    public BTree(int t) {\n      BT = t;\n      rootNode = new TreeNode();\n      rootNode.n = 0;\n      rootNode.is_leaf = true;\n    }\n\n    private TreeNode rootNode;\n\n    private TreeNode searchKey(TreeNode node, int node_key) {\n      int itr = 0;\n      if (node == null)\n        return node;\n      for (itr = 0; itr < node.n; itr++) {\n        if (node_key < node.node_key[itr]) {\n          break;\n        }\n        if (node_key == node.node_key[itr]) {\n          return node;\n        }\n      }\n      if (node.is_leaf) {\n        return null;\n      } else {\n        return searchKey(node.child_node[itr], node_key);\n      }\n    }\n\n    // Splitting the node\n    private void split(TreeNode node, int pos, TreeNode y) {\n      TreeNode z = new TreeNode();\n      z.is_leaf = y.is_leaf;\n      z.n = BT - 1;\n      for (int jtr = 0; jtr < BT - 1; jtr++) {\n        z.node_key[jtr] = y.node_key[jtr + BT];\n      }\n      if (!y.is_leaf) {\n        for (int jtr = 0; jtr < BT; jtr++) {\n          z.child_node[jtr] = y.child_node[jtr + BT];\n        }\n      }\n      y.n = BT - 1;\n      for (int jtr = node.n; jtr >= pos + 1; jtr--) {\n        node.child_node[jtr + 1] = node.child_node[jtr];\n      }\n      node.child_node[pos + 1] = z;\n\n      for (int jtr = node.n - 1; jtr >= pos; jtr--) {\n        node.node_key[jtr + 1] = node.node_key[jtr];\n      }\n      node.node_key[pos] = y.node_key[BT - 1];\n      node.n = node.n + 1;\n    }\n\n    // Inserting a value\n    public void insert_value(final int node_key) {\n      TreeNode root = rootNode;\n      if (root.n == 2 * BT - 1) {\n        TreeNode nd = new TreeNode();\n        rootNode = nd;\n        nd.is_leaf = false;\n        nd.n = 0;\n        nd.child_node[0] = root;\n        nd(nd, 0, root);\n        insertValue(nd, node_key);\n      } else {\n        insertValue(root, node_key);\n      }\n    }\n\n    // Inserting the node\n    final private void insertValue(TreeNode node, int ktr) {\n\n      if (node.is_leaf) {\n        int itr = 0;\n        for (itr = node.n - 1; itr >= 0 && ktr < node.node_key[itr]; itr--) {\n          node.node_key[itr + 1] = node.node_key[itr];\n        }\n        node.node_key[itr + 1] = ktr;\n        node.n = node.n + 1;\n      } else {\n        int itr = 0;\n        for (itr = node.n - 1; itr >= 0 && ktr < node.node_key[itr]; itr--) {\n        }\n        ;\n        itr++;\n        TreeNode temp = node.child_node[itr];\n        if (temp.n == 2 * BT - 1) {\n          nd(node, itr, temp);\n          if (ktr > node.node_key[itr]) {\n            itr++;\n          }\n        }\n        insertValue(node.child_node[itr], ktr);\n      }\n\n    }\n\n    public void display() {\n      display(rootNode);\n    }\n\n    // Display\n    private void display(TreeNode node) {\n      assert (node == null);\n      for (int itr = 0; itr < node.n; itr++) {\n        System.out.print(node.node_key[itr] + \" \");\n      }\n      if (!node.is_leaf) {\n        for (int itr = 0; itr < node.n + 1; itr++) {\n          display(node.child_node[itr]);\n        }\n      }\n    }\n\n    // Check if present\n    public boolean isPresent(int ktr) {\n      if (this.searchKey(rootNode, ktr) != null) {\n        return true;\n      } else {\n        return false;\n      }\n    }\n\n    // delete the key\n    private void deleteKey(TreeNode node, int key) {\n    int position = node.Find(key);\n    if (position != -1) {\n      if (node.is_leaf) {\n        int itr = 0;\n        for (itr = 0; itr < node.n && node.key[itr] != key; itr++) {\n        }\n        ;\n        for (; itr < node.n; itr++) {\n          if (itr != (2 * BT) - 2) {\n            node.key[itr] = node.key[itr + 1];\n          }\n        }\n        node.n--;\n        return;\n      }\n      if (!node.is_leaf) {\n\n        TreeNode prd = node.child[position];\n        int predKey = 0;\n        if (prd.n >= BT) {\n          for (;;) {\n            if (prd.is_leaf) {\n              System.out.println(prd.n);\n              predKey = prd.key[prd.n - 1];\n              break;\n            } else {\n              prd = prd.child[prd.n];\n            }\n          }\n          deleteKey(prd, predKey);\n          node.key[position] = predKey;\n          return;\n        }\n\n        TreeNode next_node = node.child[position + 1];\n        if (next_node.n >= BT) {\n          int nextKey = next_node.key[0];\n          if (!next_node.is_leaf) {\n            next_node = next_node.child[0];\n            for (;;) {\n              if (next_node.is_leaf) {\n                nextKey = next_node.key[next_node.n - 1];\n                break;\n              } else {\n                next_node = next_node.child[next_node.n];\n              }\n            }\n          }\n          deleteKey(next_node, nextKey);\n          node.key[position] = nextKey;\n          return;\n        }\n\n        int tmp = prd.n + 1;\n        prd.key[prd.n++] = node.key[position];\n        for (int itr = 0, jtr = prd.n; itr < next_node.n; itr++) {\n          prd.key[jtr++] = next_node.key[itr];\n          prd.n++;\n        }\n        for (int itr = 0; itr < next_node.n + 1; itr++) {\n          prd.child[tmp++] = next_node.child[itr];\n        }\n\n        node.child[position] = prd;\n        for (int itr = position; itr < node.n; itr++) {\n          if (itr != 2 * BT - 2) {\n            node.key[itr] = node.key[itr + 1];\n          }\n        }\n        for (int itr = position + 1; itr < node.n + 1; itr++) {\n          if (itr != 2 * BT - 1) {\n            node.child[itr] = node.child[itr + 1];\n          }\n        }\n        node.n--;\n        if (node.n == 0) {\n          if (node == root) {\n            root = node.child[0];\n          }\n          node = node.child[0];\n        }\n        deleteKey(prd, key);\n        return;\n      }\n    } else {\n      for (position = 0; position < node.n; position++) {\n        if (node.key[position] > key) {\n          break;\n        }\n      }\n      TreeNode tmp = node.child[position];\n      if (tmp.n >= BT) {\n        deleteKey(tmp, key);\n        return;\n      }\n      if (true) {\n        TreeNode nd = null;\n        int divider = -1;\n\n        if (position != node.n && node.child[position + 1].n >= BT)    {\n          divider = node.key[position];\n          nd = node.child[position + 1];\n          node.key[position] = nd.key[0];\n          tmp.key[tmp.n++] = divider;\n          tmp.child[tmp.n] = nd.child[0];\n          for (int itr = 1; itr < nd.n; itr++) {\n            nd.key[itr - 1] = nd.key[itr];\n          }\n          for (int itr = 1; itr <= nd.n; itr++) {\n            nd.child[itr - 1] = nd.child[itr];\n          }\n          nd.n--;\n          deleteKey(tmp, key);\n          return;\n        }\n    else if (position != 0 && node.child[position - 1].n >= BT) {\n\n          divider = node.key[position - 1];\n          nd = node.child[position - 1];\n          node.key[position - 1] = nd.key[nd.n - 1];\n          TreeNode child = nd.child[nd.n];\n          nd.n--;\n\n          for (int itr = tmp.n; itr > 0; itr--) {\n            tmp.key[itr] = tmp.key[itr - 1];\n          }\n          tmp.key[0] = divider;\n          for (int itr = tmp.n + 1; itr > 0; itr--) {\n            tmp.child[itr] = tmp.child[itr - 1];\n          }\n          tmp.child[0] = child;\n          tmp.n++;\n          deleteKey(tmp, key);\n          return;\n        } else {\n          TreeNode left = null;\n          TreeNode right = null;\n          boolean is_last = false;\n          if (position != node.n) {\n            divider = node.key[position];\n            left = node.child[position];\n            right = node.child[position + 1];\n          } else {\n            divider = node.key[position - 1];\n            right = node.child[position];\n            left = node.child[position - 1];\n            is_last = true;\n            position--;\n          }\n          for (int itr = position; itr < node.n - 1; itr++) {\n            node.key[itr] = node.key[itr + 1];\n          }\n          for (int itr = position + 1; itr < node.n; itr++) {\n            node.child[itr] = node.child[itr + 1];\n          }\n          node.n--;\n          left.key[left.n++] = divider;\n\n          for (int itr = 0, jtr = left.n; itr < right.n + 1; itr++, jtr++) {\n            if (itr < right.n) {\n              left.key[jtr] = right.key[itr];\n            }\n            left.child[jtr] = right.child[itr];\n          }\n          left.n += right.n;\n          if (node.n == 0) {\n            if (node == root) {\n              root = node.child[0];\n            }\n            node = node.child[0];\n          }\n          deleteKey(left, key);\n          return;\n        }\n      }\n    }\n  }\n\n  public void deleteKey(int key) {\n    TreeNode node = searchKey(root, key);\n    if (node == null) return;\n    deleteKey(root, key);\n  }\n\n    // Main Function\n    public static void main(String[] args) {\n      // BTree of degree 3\n      BTree tree = new BTree(3);\n      // Inserting nodes [8,9,10,15,20,17]\n      tree.insert_value(8);\n      tree.insert_value(9);\n      tree.insert_value(10);\n      tree.insert_value(11);\n      tree.insert_value(15);\n      tree.insert_value(20);\n      tree.insert_value(17);\n      // To display current tree\n      tree.display();\n\n      // To check if 12 is present in Tree or not\n      if (tree.isPresent(12)) {\n        System.out.println(\"\\nKey Found\");\n      } else {\n        System.out.println(\"\\nKey not Found\");\n      }\n      // To delete 10 from tree\n      tree.deleteKey(10);\n      // To display tree after 10 is deletedthe the \n      tree.display();\n    }\n  }\n```\n\n### Variants of B-Tree\n\nThe term B-Tree can also refer to a particular layout or an extensive class of designs. B-Tree saves key data in its inner nodes and does not save those keys in the records at the leaf nodes.\n\n-   **B+ Tree-** In the B+ Tree internal nodes hold copies of the keys and the leaf nodes hold keys and records. Also, a leaf node may contain a pointer to the next leaf node for fastening the sequential access.\n\n-   **B\\* Tree-** The B\\* Tree balances additional neighboring inner nodes to hold internal nodes more closely packed. In this variant, every non-root node is at least compacted by **⅔** in comparison to B-Tree which is  **½.** The most strong point of the disadvantage of B-Tree is its operation of inserting a node in the tree using a splitting node mechanism which is very costly. On the other hand B\\* Trees are generated as such to avoid splitting operations as long as they can.\n\n-   B\\*+ Tree- That variant of B-Tree combines the major features of B+ Tree and B\\* tree. \n\n### Properties of B-Tree\n\n-   For every node **N**, the keys are kept in sorted order.\n\n-   There is a boolean data **N.leaf** in each node that indicates whether N is a leaf node or not.\n\n-   If the order of the tree is **x**, then each internal node can contain at most **x-1** keys.\n\n-   Except for the root node, every node can have at most **x children** and at least **x/2 children.**\n\n-   All leaves are on the same level, i.e., they all have the same depth and height.\n\n-   The root node contains a minimum of one key and has at least two children.\n\n-   If **x ≥ 1**, then for any **x-key** B-Tree of height **h** having the minimum degree **t ≥ 2** has height **h,**\n\n__h ≥ logt(n+1)/2__\n\n### Applications of B-Tree\n- Searches, insertions, and deletions of records in/to/from the database and file systems.\n- To store blocks/chunks of data in the secondary storage devices.\n- For multi-level indexing.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"65O3MMsGuTqX4eiLdgJ6H","type":"Asset","createdAt":"2021-12-15T09:42:36.366Z","updatedAt":"2023-09-24T18:57:08.206Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"b-tree article banner","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/65O3MMsGuTqX4eiLdgJ6H/c10ef628e0390748e0efd711eb161452/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2b56J83mO6xWOJwhZJ5uuC","type":"Entry","createdAt":"2021-10-18T06:57:25.136Z","updatedAt":"2021-10-18T06:57:25.136Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kunal Jain","tcHandle":"kunalkj_"}}],"upvotes":312,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Ibk0v5jekZLneIYxVEgDO","type":"Entry","createdAt":"2021-11-10T16:39:34.250Z","updatedAt":"2021-11-19T19:21:14.869Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Vertical Order Traversal of a Binary Tree","slug":"vertical-order-traversal-of-a-binary-tree","type":"Article","trackCategory":["Competitive Programming"],"tags":["Binary Tree","JAVA"],"creationDate":"2021-11-10","readTime":"8min","content":"If we are given a binary tree and we need to perform a vertical order traversal, that means we will be processing the nodes of the binary tree from left to right. Suppose we have a tree such as the one given below.\n\n![image](//images.contentful.com/piwi0eufbb2g/24x33xEPHVqJlNtMqTNJP4/378d28a871263bac943207047ecb6056/image.png)\n\nIf we traverse the tree in vertical order and print the nodes then the output will be:\n\n4,\n2,\n1, 5, 6,\n3,\n7,\n\nIn order to traverse vertically we will require some method to reduce the complexity of traversing the binary tree. We will do this by assigning a horizontal distance to each node.\n\n__Horizontal Distance (HD):__ is the distance of a node from the root node. The HD of the root node is zero. Any node that falls in the vertical line after the root node line will be positive, and any node that falls in the vertical line to the left of the root node will be negative.\nTake the example of the tree above. The horizontal distance of nodes will be:\n\nHD (-2)--> 4 \nHD (-1)--> 2\nHD (0)--> 1, 5, 6\nHD (+1)--> 3\nHD (+2)--> 7\n\n### Algorithm\nWe need to find and store the HD for each node. \nHD ---> Horizontal Distance\n\n#### Declaration:\n\nqueue --> q  // to insert nodes\nqueue --> indices // to insert HD and keep track of HD for each node \nmp --> HashMap // key --HD , Values --> ArrayList (will contain nodes      for particular HD)\nminHD =0 , maxHD=0 // so that we can move from minHD to maxHD\n\n#### Execution:\n__Step1:__ Loop (until q is empty)\n\t   if queue is not empty then go to step 2\n             else go to step ------\n\n__Step2:__ Loop (find size of q )\n\t    If reached end of loop got to step 1 \n              else go to step 3\n\n__Step3:__ node =  q.poll()  // get the current Node\nindex= indices.poll() // get the index for current node              \nput the index in Map // if not present\nadd the Node into value of Map(ArrayList) for respective index\n\n__Step4:__ Check for left subtree \n\t\tif the left subtree for current node is not null then\n\t\t\tinsert into q(node.left) \t\n\t\t\tinsert the index-1 for node.left\n\t\t\tcalculate minHD = min(minHD, index-1)\n\t\telse go to step 5\t\n\n__Step5:__ Check for right subtree\n\t\tif the left subtree for current node is not null then\n\t\t         insert into q(node.right)\n\t\t         insert the index+1 for node.right \n\t\t         calculate maxHD = max(maxHD, index+1)\n\t\telse go to step 2\n\n__Step6:__ Traverse the map from minHD to maxHD (Map Keys) and print all nodes for respective HD.\n\n### Java Implementation\n```java\nclass BinaryTree\n{\n    static ArrayList <Integer> verticalOrder(Node root)\n    {\n\t//final list which will be returned  \n           ArrayList<Integer> res=new ArrayList<>();         if(root==null)return res;\n\n        Queue<Node> q=new LinkedList<>();\n        q.offer(root);\n        //map to track nodes for each HD\n        Map<Integer,List<Integer>> mp=new HashMap<>();\n        //index of each nodes stored in q(queues)\n        Queue<Integer> indices=new LinkedList<>();\n        indices.offer(0);\n        int minIndex=0,maxIndex=0;\n\n        while(!q.isEmpty())\n        {\n            int size=q.size();\n            for(int i=0;i<size;i++)\n            {\n                Node node=q.poll();\n                int index=indices.poll();\n\n                mp.putIfAbsent(index,new ArrayList<>());\n                mp.get(index).add(node.data);\n\n                 if(node.left!=null)\n                {\n                    q.offer(node.left);\n                    indices.offer(index-1);\n                    minIndex=Math.min(minIndex,index-1);\n                }\n\n                if(node.right!=null)\n                {\n                    q.offer(node.right);\n                    indices.offer(index+1);\n                    maxIndex=Math.max(maxIndex,index+1);\n                }\n                /*\n                [0,2,1,3,null,null,null,4,5,null,7,6,null,10,8,11,9]\n                [0,5,1,9,null,2,null,null,null,null,3,4,8,6,null,null,null,7]\n                */\n            }     \n\n        }\n\n        // traversing from minHD to MaxHd and inserting into final  \n     //ArrayList\n        for(int i=minIndex;i<=maxIndex;i++)\n        {   //Collections.sort(mp.get(i));\n            int size=mp.get(i).size();\n            for(int ii=0;ii<size;ii++)\n            res.add(mp.get(i).get(ii));\n        }\n        //final list containing number of nodes traversed in Vertical Order\n        return res;       \n    }\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6JuGH4xpBrXFLGMaYTMdyU","type":"Asset","createdAt":"2021-11-10T16:32:25.875Z","updatedAt":"2021-11-10T16:32:25.875Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Banner (4)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6JuGH4xpBrXFLGMaYTMdyU/c7a0674ac968c4d1c95ed125a4129722/Banner__4_.png","details":{"size":38234,"image":{"width":1050,"height":600}},"fileName":"Banner (4).png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7Emo2c6hFbIUfF9cBScXj3","type":"Entry","createdAt":"2020-02-20T09:27:12.700Z","updatedAt":"2021-11-06T03:24:31.062Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":418,"revision":56,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Introduction to Graphs and Their Data Structures part 1: Recognizing and Representing a Graph","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Graph","Data structure","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505841)\n<br/>\n<a href=\"#Introduction\">Introduction</a>\n<a href=\"#Recognizinggraphproblem\">Recognizing a graph problem</a>\n<a href=\"#Representinggraphandkeyconcepts\">Representing a graph and key concepts</a>\n<a href=\"#Singlylinkedlists\">Singly linked lists</a>\n<a href=\"#Trees\">Trees</a>\n<a href=\"#Graphs\">Graphs</a>\n<a href=\"#Arrayrepresentation\">Array representation</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nGraphs are a fundamental data structure in the world of programming, and this is no less so on topcoder. Usually appearing as the hard problem in Division 2, or the medium or hard problem in Division 1, there are many different forms solving a graph problem can take. They can range in difficulty from finding a path on a 2D grid from a start location to an end location, to something as hard as finding the maximum amount of water that you can route through a set of pipes, each of which has a maximum capacity (also known as the maximum-flow minimum-cut problem – which we will discuss later). Knowing the correct data structures to use with graph problems is critical. A problem that appears intractable may prove to be a few lines with the proper data structure, and luckily for us the standard libraries of the languages used by topcoder help us a great deal here!\n<br/><br/>\n<a name=\"Recognizinggraphproblem\" id=\"Recognizinggraphproblem\"></a>\n### Recognizing a graph problem\nThe first key to solving a graph related problem is recognizing that it is a graph problem. This can be more difficult than it sounds, because the problem writers don’t usually spell it out for you. Nearly all graph problems will somehow use a grid or network in the problem, but sometimes these will be well disguised. Secondly, if you are required to find a path of any sort, it is usually a graph problem as well. Some common keywords associated with graph problems are: vertices, nodes, edges, connections, connectivity, paths, cycles and direction. An example of a description of a simple problem that exhibits some of these characteristics is:\n\\\n\"Bob has become lost in his neighborhood. He needs to get from his current position back to his home. Bob’s neighborhood is a 2 dimensional grid, that starts at (0, 0) and (width – 1, height – 1). There are empty spaces upon which bob can walk with no difficulty, and houses, which Bob cannot pass through. Bob may only move horizontally or vertically by one square at a time.\n\\\nBob’s initial position will be represented by a ‘B’ and the house location will be represented by an ‘H’. Empty squares on the grid are represented by ‘.’ and houses are represented by ‘X’. Find the minimum number of steps it takes Bob to get back home, but if it is not possible for Bob to return home, return -1.\n\\\nAn example of a neighborhood of width 7 and height 5:\n<br/>\n```\n\n.X.X.XX\n.H…\n…X…\n…X.\"\n```\n\\\nOnce you have recognized that the problem is a graph problem it is time to start building up your representation of the graph in memory.\n<br/><br/>\n<a name=\"Representinggraphandkeyconcepts\" id=\"Representinggraphandkeyconcepts\"></a>\n### Representing a graph and key concepts\nGraphs can represent many different types of systems, from a two-dimensional grid (as in the problem above) to a map of the internet that shows how long it takes data to move from computer A to computer B. We first need to define what components a graph consists of. In fact there are only two, nodes and edges. A node (or vertex) is a discrete position in the graph. An edge (or connection) is a link between two vertices that can be either directed or undirected and may have a cost associated with it. An undirected edge means that there is no restriction on the direction you can travel along the edge. So for example, if there were an undirected edge from A to B you could move from A to B or from B to A. A directed edge only allows travel in one direction, so if there were a directed edge from A to B you could travel from A to B, but not from B to A. An easy way to think about edges and vertices is that edges are a function of two vertices that returns a cost. We will see an example of this methodology in a second.\n\\\nFor those that are used to the mathematical description of graphs, a graph G = {V, E} is defined as a set of vertices, V, and a collection of edges (which is not necessarily a set), E. An edge can then be defined as (u, v) where u and v are elements of V. There are a few technical terms that it would be useful to discuss at this point as well:\n\\\nOrder – The number of vertices in a graph\n\\\nSize – The number of edges in a graph\n<br/><br/>\n<a name=\"Singlylinkedlists\" id=\"Singlylinkedlists\"></a>\n### Singly linked lists\nAn example of one of the simplest types of graphs is a singly linked list! Now we can start to see the power of the graph data structure, as it can represent very complicated relationships, but also something as simple as a list.\n\\\nA singly linked list has one “head” node, and each node has a link to the next node. So the structure looks like this:\n<br/>\n```\nstructure node\n[node] link;\n[data]\nend\n\nnode head;\n```\n\\\nA simple example would be:\n<br/>\n```\nnode B, C;\nhead.next = B;\nB.next = C;\nC.next = null;\n```\n\\\nThis would be represented graphically as head -> B -> C -> null. I’ve used null here to represent the end of a list.\n\\\nGetting back to the concept of a cost function, our cost function would look as follows:\n<br/>\n```\ncost(X, Y) := if (X.link = Y) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nThis cost function represents the fact that we can only move directly to the link node from our current node. Get used to seeing cost functions because anytime that you encounter a graph problem you will be dealing with them in some form or another! A question that you may be asking at this point is “Wait a second, the cost from A to C would return not possible, but I can get to C from A by stepping through B!” This is a very valid point, but the cost function simply encodes the direct cost from a node to another. We will cover how to find distances in generic graphs later on.\n\\\nNow that we have seen an example of the one of the simplest types of graphs, we will move to a more complicated example.\n<br/><br/>\n<a name=\"Trees\" id=\"Trees\"></a>\n### Trees\nThere will be a whole section written on trees. We are going to cover them very briefly as a stepping-stone along the way to a full-fledged graph. In our list example above we are somewhat limited in the type of data we can represent. For example, if you wanted to start a family tree (a hierarchal organization of children to parents, starting from one child) you would not be able to store more than one parent per child. So we obviously need a new type of data structure. Our new node structure will look something like this:\n<br/>\n```\nstructure node\n[node] mother, father;\n[string] name\nend\n\nnode originalChild;\n```\n\\\nWith a cost function of:\n<br/>\n```\ncost(X, Y) := if ((X.mother = Y) or (X.father = Y)) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nHere we can see that every node has a mother and father. And since node is a recursive structure definition, every mother has mother and father, and every father has a mother and father, and so on. One of the problems here is that it might be possible to form a loop if you actually represented this data structure on a computer. And a tree clearly cannot have a loop. A little mind exercise will make this clear: a father of a child is also the son of that child? It’s starting to make my head hurt already. So you have to be very careful when constructing a tree to make sure that it is truly a tree structure, and not a more general graph. A more formal definition of a tree is that it is a connected acyclic graph. This simply means that there are no cycles in the graph and every node is connected to at least one other node in the graph.\n\\\nAnother thing to note is that we could imagine a situation easily where the tree requires more than two node references, for example in an organizational hierarchy, you can have a manager who manages many people then the CEO manages many managers. Our example above was what is known as a binary tree, since it only has two node references. Next we will move onto constructing a data structure that can represent a general graph!\n<br/><br/>\n<a name=\"Graphs\" id=\"Graphs\"></a>\n### Graphs\nA tree only allows a node to have children, and there cannot be any loops in the tree, with a more general graph we can represent many different situations. A very common example used is flight paths between cities. If there is a flight between city A and city B there is an edge between the cities. The cost of the edge can be the length of time that it takes for the flight, or perhaps the amount of fuel used.\n\\\nThe way that we will represent this is to have a concept of a node (or vertex) that contains links to other nodes, and the data associated with that node. So for our flight path example we might have the name of the airport as the node data, and for every flight leaving that city we have an element in neighbors that points to the destination.\n<br/>\n```\nstructure node\n[list of nodes] neighbors\n[data]\nend\n\ncost(X, Y) := if (X.neighbors contains Y) return X.neighbors[Y];\nelse “Not possible”\n\nlist nodes;\n```\n\\\nThis is a very general way to represent a graph. It allows us to have multiple edges from one node to another and it is a very compact representation of a graph as well. However the downside is that it is usually more difficult to work with than other representations (such as the array method discussed below).\n<br/><br/>\n<a name=\"Arrayrepresentation\" id=\"Arrayrepresentation\"></a>\n### Array representation\nRepresenting a graph as a list of nodes is a very flexible method. But usually on topcoder we have limits on the problems that attempt to make life easier for us. Normally our graphs are relatively small, with a small number of nodes and edges. When this is the case we can use a different type of data structure that is easier to work with.\n\\\nThe basic concept is to have a 2 dimensional array of integers, where the element in row i, at column j represents the edge cost from node i to j. If the connection from i to j is not possible, we use some sort of sentinel value (usually a very large or small value, like -1 or the maximum integer). Another nice thing about this type of structure is that we can represent directed or undirected edges very easily.\n\\\nSo for example, the following connection matrix:\n<br/>\n```\nA B C\nA 0 1 5\nB -1 0 1\nC -1 -1 0\n```\n\\\nWould mean that node A has a 0 weight connection to itself, a 1 weight connection to node B and 5 weight connection to node C. Node B on the other hand has no connection to node A, a 0 weight connection to itself, and a 1 weight connection to C. Node C is connected to nobody. This graph would look like this if you were to draw it:\n<br/><div style=\"text-align:center;\">\n![graph](//images.ctfassets.net/piwi0eufbb2g/39urFkSmHSQE5Y9thpTSbl/89c592184413c140e1b8706429dff7d1/graph.gif)\n</div>\nThis representation is very convenient for graphs that do not have multiple edges between each node, and allows us to simplify working with the graph.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Introduction%20to%20Graphs%20and%20Their%20Data%20Structures%20part%202:%20Searching%20a%20Graph)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"7dpViJNiGS7Fflpf8x767t"}}],"upvotes":19,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}},{"sys":{"type":"Link","linkType":"Entry","id":"ypU3M6AxrYYmErQqodsVr"}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5BVGP4CoZCW756Sb7N4L9y","type":"Entry","createdAt":"2021-09-21T10:20:59.677Z","updatedAt":"2022-09-10T06:54:27.585Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":99,"revision":23,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Tree Data Structure","slug":"tree-data-structure","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["Algorithm","Graph"],"creationDate":"2021-09-21","readTime":"10min","content":"### Types of Data Structure\n\nThere are two types of data structures; linear and nonlinear. In **linear** data structure, elements will be attached linearly, like in the case of stack, linked lists, queue etc.  In **nonlinear** data structure elements will not be arranged in sequential order, as seen in trees or graphs, so it is more difficult to traverse.\n\n### Definition\n\nA tree is a collection of nodes. These nodes are arranged in a hierarchical structure and  linked to each other by edges (not making a cycle). Trees are preferred when we want to reduce the cost of operations and memory use.\n\n![image](//images.contentful.com/piwi0eufbb2g/39dpfcSKrtv216GsV9Sr3w/0f01cc76a84affc8435c3c79e12c1b90/image.png)\nFigure 1\n\n### Types of Trees\n\nThe different types of trees in data structure based on their properties : general tree, binary tree, binary search tree, AVL tree, red-black tree, splay tree, and B-tree.  \n\n#### General tree:\nIn this tree its node can have 0 to N number of nodes, in which every node has no degree restrictions. Mainly, a general tree does not have ordered nodes. Hence its subtree will also be unordered.\n\n![image](//images.contentful.com/piwi0eufbb2g/4A4iu2vrAOkh6QlWpwWAzm/967d4b49c63572a1c8c6472d3a38839f/image.png)\nFigure 2\n\n#### Binary tree:\nIt is a recursive tree in which each node can have two child nodes at most.\n\n##### Properties of binary trees are:\nThe number of the total nodes on each level will be double the nodes present at the previous level. The last level will have the number of nodes present on all levels plus one.\n\n#### Binary search tree:\nIs a node-based binary tree but with different properties like:  \n\n1. Left subtree will contain the nodes with the values lesser than the value of its root node.\n\n2. Right subtree will contain nodes with values greater than the value of its root.\n\n3. The left and right subtrees should be binary trees in themselves.\n\n![image](//images.contentful.com/piwi0eufbb2g/3DPH99L4wJDoXwl9j94lKr/739a3dc3da0bf4f7885c2ba293d636fc/image.png)\nFigure 3\n\n#### AVL tree:\nIt satisfies both binary tree and binary search tree properties. This tree is a self-balancing tree which was invented by the mathematician **Adelson Velsky Lindas.**  The self-balancing property says that the difference between the height of the left and right subtree should not be more than one and it is implemented on all the nodes.\n\n![image](//images.contentful.com/piwi0eufbb2g/4vWVSkAsBVL4oJahIZhzLS/2010ae502bd771b646353fd3a84bfa87/image.png)\nFigure 4\n\n### Properties of Trees and Terminologies\n\n#### Node\nBasic unit containing value and nodes pointing to left and right subtree.\n\n```\nCode : class Node {\n\nint data;\n\nNode left, right; //pointer to left and right subtree\n\n}\n```\n\n#### Root\nTopmost node in a tree; it is the ancestor of all the nodes in a tree.  \n\n#### Child\nAny node which is connected to another node when moving away from the root is called a child of its ancestor.\n\n#### Level\nTotal count of edges between current node and root of a tree plus one.\n\n#### Leaf\nAny node which doesn't have any child.\n\n#### Edge\nLink between the two different nodes which does not lead to a cycle.\n\n#### Height\nThe longest path which can be drawn between root node and leaf node.\n\n#### Breadth\nTotal number of leaf nodes present in a tree.\n\n#### Degree\nThe count of child nodes that exist for a node is the degree of a  node.\n\n### Tree Uses in the Real World\nTrees are used widely in databases to implement indexing, to implement dictionaries, for quick pattern searching, and finding the shortest distance. Binary trees are used for fast searching and sorting data.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Y1AOG1YXQlhTmMHfBYvPz","type":"Asset","createdAt":"2021-09-21T10:12:41.521Z","updatedAt":"2021-09-21T10:12:41.521Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"localization example app","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4Y1AOG1YXQlhTmMHfBYvPz/837841b4bfc581f036b8db3c2084ffe8/Banner.png","details":{"size":22355,"image":{"width":455,"height":355}},"fileName":"Banner.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":8,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1ViiHZFGcwDFMBCADZLDpF"}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"38HBoqJsM8qEaQ104fiS1M","type":"Entry","createdAt":"2021-11-15T14:46:15.256Z","updatedAt":"2021-11-15T21:29:11.636Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":42,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Ternary Search Trees","slug":"ternary-search-trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"675c3u6tacMXieHHlB6n7X"}}],"tags":["Trees","C++"],"creationDate":"2021-11-15","readTime":"9min","content":"Ternary search trees are a similar data structure to binary search trees and tries. They encapsulate the memory efficiency of binary search trees and time efficiency of tries.\n\nWe know that by using tries we can search and sort strings efficiently, but it consumes a lot of memory. Here we can use ternary search trees instead, which store fewer references and null objects.\n\nCharacteristics of **Ternary Search Trees (TST)**\n\n-   TST stores characters or strings in nodes\n\n-   Each node has three children: left, equal, right\n\n-   The left pointer contains all the strings which are alphabetically less than the data\n\n-   The equal pointer contains all the strings which are alphabetically equal to the data\n\n-   The right pointer contains all the strings which are alphabetically greater than the data\n\n![image](//images.contentful.com/piwi0eufbb2g/oAztgp79Z1dhuvV7cQQw8/19c74ee1250af0f1eff89d03b3ba0d68/image.png)\n\nTernary search trees declaration\n\n```cpp\nstruct TSTNode{\n    char data;\n    int isEnd;\n    TSTNode* left;\n    TSTNode* equal;\n    TSTNode* right;\n};\n```\n\n![image](//images.contentful.com/piwi0eufbb2g/AwT8SMzqwsJQAfyi0zyrA/d89bb81e06aa796ff15c077d74c74078/image.png)\n\nIn general, we have as many pointers/edges from every node as the number of characters in the alphabet.\nWe have to define an alphabet in advance  + ALP_SIZE. For example: in the English alphabet, there are 26 characters, so ALP_SIZE = 26 -> 26 pointers from every node.\n\n### Inserting string in the TST:\nTo explain it further, we will try to insert some strings in the TST: boats, boat, bat, bats.\n\nWe will insert in this order:\n\nFirst, let's insert boats.\n\n![image](//images.contentful.com/piwi0eufbb2g/6or1ohWIWbWaDuDAZty6jD/a769cd79c81cb7faa491d7f4460d5686/image.png)\n\nNow to insert boat to our TST we just have to mark isEnd of of “t” to 1.\n\n![image](//images.contentful.com/piwi0eufbb2g/3ziV7i7O1MyjDaOB95KLXk/7ff3ecba60eb522ba3cfe5d748217c5b/image.png)\n\nNow, let’s insert *bat*.\n\n![image](//images.contentful.com/piwi0eufbb2g/1cwH4KYPs1Ttr1QYyId4WQ/406f933f4b9fcc2d3d4c5d02134ad74f/image.png)\n\nNow, at last, insert *bats*.\n\n![image](//images.contentful.com/piwi0eufbb2g/CKnQoqiSHmEYP6UdbOkVx/5fe863317da7fd70a6eb4bc4ddac1b1b/image.png)\n\n#### Code for inserting into TST:\n```cpp\nTSTNode *insertInTST(TSTNode* root, char *word){\n\n    if(root == NULL){\n        root = new TSTNode();\n        root->data = *word;\n        root->isEnd = 1;\n        root->left = root->equal = root->right = NULL;\n    }\n\n    if(*word < root->data)\n        root->left = insertInTST(root->left,word);\n    else if(*word == root->data){\n        if(*(word+1))\n            root->equal = insertInTST(root->equal,word+1);\n        else \n            root->isEnd = 1;\n    }\n    else \n        root->right = insertInTST(root->right,word);\n    return root;\n}\n```\n\nTime Complexity: O(N), where N is the length of the string to be inserted.\n\n### Searching string in the TST:\nWhile searching we can follow the same procedure as the binary search tree. The only difference is that in cases when the character matches we check for the remaining characters instead of returning.\n\n#### Code for searching into TST:\n```cpp\nint searchInTST(TSTNode *root,char *word){\n\n    if(!root)\n        return -1;\n    if(*word < root->data)\n        return searchInTST(root->left,word);\n    else if(*word > root->data)\n        return searchInTST(root->right,word);\n    else{\n        if(root->isEnd && *(word+1) == 0)\n            return 1;\n        return searchInTST(root->eq,word+1);\n    }\n}\n```\n\nTime Complexity: O(N), where N is the length of the string to be searched.\n\n### TST vs Hashing\n#### TST\n\n-   Works for strings\n\n-   Examines just enough key characters\n\n-   May only miss a few characters \n\n-   Supports much more operation\n\n-   More flexible than binary search trees\n\n-   Faster than hashing \n\n#### Hashing\n\n-   Needs to examine the entire key\n\n-   Search hits and misses cost the same\n\n-   Run time and performance relies heavily on the hash function\n\n-   Does not support as much operation as TST \n\n#### Applications of TST\n\n-   It can be used to implement the auto-complete feature efficiently\n\n-   Can be used for spell checkers \n\n-   Near neighbor searching \n\n-   For databases, especially when indexing by several non-key fields.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5OnWggND3ytsXYNaJSC2WH","type":"Asset","createdAt":"2021-11-15T14:38:22.172Z","updatedAt":"2021-11-15T14:46:12.965Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"ternary","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5OnWggND3ytsXYNaJSC2WH/7f23bc81873fd8fb13833189e830b0e2/ternary.jpeg","details":{"size":25803,"image":{"width":709,"height":355}},"fileName":"ternary.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":0,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"sys":{"type":"Link","linkType":"Entry","id":"3nm4uYV8GUkxOpsUgx23SF"}}]}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2uNQndGSKrikjHIWwHbc90","type":"Entry","createdAt":"2022-07-28T06:24:39.724Z","updatedAt":"2024-09-28T08:01:45.812Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Comparison Networks","slug":"comparison-networks","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithm","Networks"],"creationDate":"2022-07-28","readTime":"7min","content":"In this article, we look into sorting algorithms that use the comparison network model of computing to conduct several comparison operations at the same time. Comparison networks vary from RAM in two essential ways. For starters, they can only make comparisons. As a result, a [counting sort](https://www.javatpoint.com/counting-sort) algorithm can’t be implemented on a comparison network. Second, unlike the RAM paradigm, where operations are performed sequentially, or one after the other, activities in comparison networks can be performed simultaneously, or \"in parallel.\" This property, as we'll see, enables the creation of comparison networks that order n values in sublinear time.\n\n### Introduction\nComparison networks are one of the types of sorting networks that constantly sort their inputs, therefore starting with comparison networks and their properties makes sense.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1aINrBtCPf8FPnimXBqnC9/466a40f634846d42a75e245fc5aff9e2/Comparison_Networks_-_ss1.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1aINrBtCPf8FPnimXBqnC9/466a40f634846d42a75e245fc5aff9e2/Comparison_Networks_-_ss1.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1aINrBtCPf8FPnimXBqnC9/466a40f634846d42a75e245fc5aff9e2/Comparison_Networks_-_ss1.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n__(a)__ A comparator with x and y inputs and x ′ and y′ outputs.\n__(b)__ A single vertical line representing the same comparator. The outputs x′ = 3 and y′ = 7 for respective inputs x = 7 and y = 3 are presented.\n\nWires and comparators are the only components of a comparison network. (a) part of the above figure shows a comparator, which has two outputs, x′ and y′ variables for the respective input variables x and y, performs the following function:\n\n<div style=\"text-align:center;font-weight:bold\">x′ = min(x, y)</div><div style=\"text-align:center;font-weight:bold\">y′ = max(x, y)</div>\n\nBecause the graphical depiction of a comparator in (a) part of the above figure is too bulky for our needs, we'll stick to portraying comparators as single vertical lines, as seen in the (b) part of the same figure. The smaller input value appears on the top output and the larger input value appears on the bottom output, with outputs on the right and inputs on the left. A comparator can thus be thought of as sorting its two input variables.\n\nWe'll suppose that each comparator takes O(1) time to complete. To put it another way, we suppose that the interval between the emergence of input variables x and y and the generation of output variables x′ and y′ is constant.\n\n### Experimental Analysis\nA wire is responsible for carrying data from one location to another. Wires can be used to link the input of one comparator to the output of another one, but they are either network input or network output wires otherwise. We'll assume throughout this chapter that a comparison network has n input wires a1, a2,..., an, via which the variables to be sorted approach the network, and n output wires  b1, b2,..., bn, which provide the network's results. We'll also refer to the variables on the output and input wires as the output sequence (b1, b2,..., bn) and the input sequences (a1, a2,..., an) respectively. That is, we refer to a wire and the payload it carries by the same name.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/6AX9Yv0pju9QhNut6NJfUe/ea3d0704388087ee17467cf1d84b2e5b/Comparison_Networks_-_ss2.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/6AX9Yv0pju9QhNut6NJfUe/ea3d0704388087ee17467cf1d84b2e5b/Comparison_Networks_-_ss2.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/6AX9Yv0pju9QhNut6NJfUe/ea3d0704388087ee17467cf1d84b2e5b/Comparison_Networks_-_ss2.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n__Figure (a)__ -  A comparison network with four inputs and four outputs, which is actually a sorting network. The input variables presented on the four input lines occur at time zero.\n__Figure  (b)__ -  At time 1, the values displayed appear on the depth 1 output variables of comparators A and B.\n<strong>Figure (<span>c</span>)</strong> -  At time 2, the values shown appear on the outputs of comparators C and D at depth 2. The final variables for output wires b1 and b4 are now known, but not for output wires b2 and b3.\n__Figure (d)__ -  At depth 3, the values depicted occur on the comparator E outputs at time 3. The final values for output wires  b2 and b3 have been determined.\n\nA comparison network is a collection of comparators connected by wires, as seen in the figure above. A comparison network with n inputs is represented as vertically stretched comparators with a group of n horizontal lines. A line represents a succession of different wires connecting various comparators, rather than a single wire. For example, the top line in the figure illustrates three wires:\n- Input wire a1, which links to an input of comparator A.\n- A wire linking an input of comparator C to comparator A's top output to an.\n- And output wire b1, which arrives from comparator C's top output.\n\nEach input of the comparator is linked to one of the network's n input wires a1, a2,..., an or the output of this other comparator. Similarly, each comparator output is linked to a wire that is any one of the network's n output wires b1, b2,..., bn, or another comparator's input. The most critical requirement for interlinking comparators would be that the graph be acyclic; that is if we trace a path from one comparator's output to another's input to output to an input, and so on, the path we trace shouldn't ever cycle back on itself and pass through the same comparator twice.\n\n### Conclusion\nA sorting network is called a comparison when the network in which the output sequence for each input sequence is uniformly increasing (i.e., b1, b2 … bn). Of course, not all comparison networks are also sorting networks, but the network represented in the above figure is. To see why, consider that after time 1, either the top result of comparator B or the top result of comparator A has provided the least of the four input values. As a result, it should be on top of the comparator C output after time 2. After time 2, the bottom result of comparator D has provided the highest of the 4 input values, according to a symmetrical argument. All that's left is for comparator E to check if the two middle values are in the right output places at time 3, which it does.\n\nA comparison network is similar to a process in that it describes how comparisons should be made, but it differs in that its physical size is determined by the number of outputs and inputs. As a result, we'll be talking about the \"families\" of comparison networks. The purpose of this chapter, for example, is to create a SORTER family of sorting networks that is efficient. The number of inputs and the family name is used to identify a specific network within a family (which equals the number of outputs). SORTER[n], for example, is the name of an n-output, n-input sorting network of the SORTER family.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1ftSQbsFvZ7hslLfqCrVSk/176f83f1786cf4b6012ca1f3cffef9ff/Comparison_Networks_-_ss3.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1ftSQbsFvZ7hslLfqCrVSk/176f83f1786cf4b6012ca1f3cffef9ff/Comparison_Networks_-_ss3.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1ftSQbsFvZ7hslLfqCrVSk/176f83f1786cf4b6012ca1f3cffef9ff/Comparison_Networks_-_ss3.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nThe above figure represents a comparison network based on [insertion sort](https://www.geeksforgeeks.org/insertion-sort/).\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1ftSQbsFvZ7hslLfqCrVSk","type":"Asset","createdAt":"2022-07-28T04:57:17.425Z","updatedAt":"2022-07-28T06:24:37.608Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"Comparison Networks - ss3","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1ftSQbsFvZ7hslLfqCrVSk/c5e889dddd40852a26d5d87c7e311e99/comparison-networks.png","details":{"size":22011,"image":{"width":445,"height":355}},"fileName":"comparison-networks.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"f9pUhpnMyK8zZmgYuuEjD","type":"Entry","createdAt":"2022-04-19T07:40:38.653Z","updatedAt":"2022-04-19T07:40:38.653Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Druti Bansal","tcHandle":"drutibansal"}}],"upvotes":3005,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6MjqIZWyvLjThdmam9nIOh","type":"Entry","createdAt":"2021-10-29T08:54:49.485Z","updatedAt":"2024-09-06T04:55:03.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":45,"revision":8,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Kosaraju's Algorithm for Strongly Connected Components","slug":"kosarajus-algorithm-for-strongly-connected-components","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["SCC","C++"],"creationDate":"2021-10-29","readTime":"11min","content":"If we can reach every vertex of a component from every other vertex in that component then it is called a Strongly Connected Component (SCC). Single node is always a SCC. \n\nThe graph below is a basic example of SCC, as it has four SCCs each contained in its own shape.\n\n![image](//images.contentful.com/piwi0eufbb2g/6dwSDyTmfxRrUiE2I3t55N/8e3bb9e7cc56c1c3809f062e3aab2087/image.png)\n\nTo find SCCs we have two algorithms, **Tarjan’s and Kosaraju’s algorithms.** In this article, we are going to cover Kosaraju’s  algorithm. To learn more about **Tarjan’s algorithm** check out [this article](https://www.topcoder.com/thrive/articles/tarjans-algorithm-for-strongly-connected-components).\n\n### Brute Force Method\n\nWe can use the Floyd Warshall algorithm to compute the distance between every two vertices, then check if the distance between any two pairs is infinity. This means both are unreachable, except for the fact that it might be a self-loop. But, it has a time complexity of about O(V3), which we cannot afford in most of the scenarios.\n\n### Kosaraju’s Algorithm\n\nBefore we deep dive into Kasaraju’s algorithm, we must take a note on reversing all the edges of a graph. The type of graph won’t change, as a SCC will still remain a SCC.\nOnly the direction between components is reversed. This property is used in our article to detect SCCs.\n\n![image](//images.contentful.com/piwi0eufbb2g/6CKpwDhLzjKHnN0QxbWCEN/e0ca2e329287f15eedd4e031eba78905/image.png)\n\nThe transpose graph property is why Kosaraju’s algorithm works successfully to search SCCs.\n\nBelow you will see that if we start DFS on the original graph from any node in SCC1 we will be able to reach all the nodes in all the three components, as all are strongly connected components and there is an outgoing edge from the first node to SCCs.\nBut, if we try doing DFS on the transposed graph from any node in SCC1 we will only be able to reach all nodes in the SCC1 component as there is no outgoing edge from one SCC to another. So, to reach the other SCC we have to make a manual jump. When we do this we can deduce that the last component was a strongly connected component. Now we start our counter and do the above steps again to get the remaining SCCs.\n\n![image](//images.contentful.com/piwi0eufbb2g/17dKcJeNCtZwsYYDkVf8VY/d7c51985f796647021780d985afff987/image.png)\n\n**PSEUDOCODE:**\n\n-   Perform DFS traversal of the graph. Push node to stack before returning.\n\n-   Find the transpose graph by reversing the edges.\n\n-   Pop nodes one by one from the stack and again to DFS on the modified graph. \n\nLet’s show an example to support our algorithm:\n\n![image](//images.contentful.com/piwi0eufbb2g/6oUnkJaqwSOwrkEAbLAho3/d4aa587a030f9e870abc88e993cc0e2a/image.png)\n\nWe will begin DFS at 0 on the above graph and traverse every outgoing edge from each node that is unvisited. For visiting information we will make a visited array, and we should also maintain a stack to store the nodes in the order of which we exhausted their outgoing edges. Now we will see the result:\n\n![image](//images.contentful.com/piwi0eufbb2g/3ClZTtAmFjkwFR2jFmkUiv/56e7fa90f1eef283e2cc9e7eb4e1e3bc/image.png)\n\nNow we pop the stack one by one and do DFS on the modified/traversed graph while popping nodes. At the end of each successful DFS we will have an SCC.\n\nNow go ahead and perform this. For the sake of the article I won’t be illustrating it (might take too many pages), I will just show the final result. Here you’ll see each SCC colored differently. We will do the steps the same as the previous one, but the next node to traverse will be given by stack. Ignore those stack elements which have already been considered in previous SCCs.\n\n![image](//images.contentful.com/piwi0eufbb2g/1TE2fX2imobJziKfSHRdF8/83f5a74f7bccfee976af2e635844226d/image.png)\n\n### Code Implementation:\n```cpp\n#include <bits/stdc++.h>\n\n#define MAX_N 20001\n#define ll long long int\nusing namespace std;\nint n, m;\n\nstruct Node\n{\n    vector<int> adj;\n    vector<int> rev_adj;\n};\n\nNode g[MAX_N];\n\nstack<int> S;\nbool visited[MAX_N];\n\nint component[MAX_N];\nvector<int> components[MAX_N];\nint numComponents;\n\nvoid dfs_1(int x){\n    visited[x] = true;\n    for (int i=0;i<g[x].adj.size();i++)\n    {\n        if (!visited[g[x].adj[i]]) dfs_1(g[x].adj[i]);\n    }\n    S.push(x);\n}\n\nvoid dfs_2(int x){\n    printf(\"%d \", x);\n    component[x] = numComponents;\n    components[numComponents].push_back(x);\n    visited[x] = true;\n    for (int i=0;i<g[x].rev_adj.size();i++)\n    {\n        if (!visited[g[x].rev_adj[i]]) dfs_2(g[x].rev_adj[i]);\n    }\n}\n\nvoid Kosaraju()\n{\n    for (int i=0;i<n;i++)\n        if (!visited[i]) dfs_1(i);\n\n    for (int i=0;i<n;i++)\n        visited[i] = false;\n\n    while (!S.empty()){\n        int v = S.top(); S.pop();\n        if (!visited[v])\n        {\n            printf(\"Component %d: \", numComponents);\n            dfs_2(v);\n            numComponents++;\n            printf(\"\\n\");\n        }\n    }\n}\n\nint main()\n{\n\n    cin >> n >> m;\n    int a,b;\n    while(m--){\n        cin >> a >> b;\n        g[a].adj.push_back(b);\n        g[b].rev_adj.push_back(a);\n    }\n\n    Kosaraju();\n    printf(\"Total number of components: %d\\n\", numComponents);\n\n    return 0;\n}\n```\n\n__Input:__\n```\n8 10\n0 1\n1 2\n2 0\n2 3\n3 4\n4 5\n5 6\n6 7\n4 7\n6 4\n```\n\n__Output:__\n```\nComponent 0: 0 2 1 \nComponent 1: 3 \nComponent 2: 4 6 5 \nComponent 3: 7 \nTotal number of components: 4\n```\n\nKosaraju's algorithm aims to find all strongly connected components (SCCs) of a given input graph. It is less effective than Tarjan’s, as here we have two different types of DFS calling, but it is more intuitive.\n\nComplexity: __O(V + E)__","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1bxxqiFLlqQFQecucXOhlA","type":"Asset","createdAt":"2021-10-29T08:31:18.687Z","updatedAt":"2021-10-29T08:54:46.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"kosaraju","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1bxxqiFLlqQFQecucXOhlA/f704fa808ac674f01803d0748be0d898/kosaraju.jpeg","details":{"size":37251,"image":{"width":926,"height":355}},"fileName":"kosaraju.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":5,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"Yq88cq14TQ3XuFPRYqdQu","type":"Entry","createdAt":"2021-10-07T09:56:26.406Z","updatedAt":"2022-07-27T14:36:05.190Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":118,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Tarjan’s Algorithm for Strongly Connected Components","slug":"tarjans-algorithm-for-strongly-connected-components","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["SCC","Tarjan","Low link"],"creationDate":"2021-10-07","readTime":"9min","content":"Strongly connected components (SCCs) can be thought of as self-contained cycles within a directed graph where every vertex in a given cycle can reach every other vertex in the same cycle.\n\nIf you look at the graph below, you will find that it has four SCCs, each has its own self-contained cycle and for each component, there is no way to find a path that leaves a component and returns back. This property ensures that SCCs in a graph are unique.\n\n![image](//images.contentful.com/piwi0eufbb2g/15p4U9s2ie9Md3PcGMIs3P/34dcbfcb2ee2483a67a8f2924227f734/image.png)\n\nTo find SCCs we have two algorithms at hand, Tarjan’s and Kosaraju’s algorithms. In this article we are going to cover Tarjan’s algorithm.\n\n### Low-Link Values\n\nBefore we jump to Tarjan’s algorithm, we must have an understanding of low-link values.\n\nThe low-link value of a node is the smallest node ID reachable from that node when doing a depth-first search (DFS), including itself.\n\nThere is a catch with doing a DFS on the graph, as it is highly dependent on the traversal order of the DFS, which is effectively random.\n\nWe are going to prove our above statement by giving you some examples:\n\n![image](//images.contentful.com/piwi0eufbb2g/1RuYR0FmiHXmFSVyC6griS/e9130e69d68bd923c83b99d3fd0b5f55/image.png)\n\nIn the above graph, we labeled it with some data and did the DFS on the 0th node, and let the DFS play and mark every node with its low-link value. After the graph is labeled it looks like this:\n\n![image](//images.contentful.com/piwi0eufbb2g/lKwKOYnOJsN8OLOULYKiu/9f3d56137b38f9f92b0876a876922704/image.png)\n\nSeeing the results we might feel that it’s working fine. But, to contradict our example, we will now label the nodes differently and start the DFS again from the 0th node. Let’s see how it pans out.\n\n![image](//images.contentful.com/piwi0eufbb2g/Krd8BzrvT6Ts6KgAMxetb/c9e686902f959a13e1e25ffbf969a7c5/image.png)\n\nAs we can see all the nodes have the same low-link value, but there are multiple SCCs.\n\n__Note__: Depending on where the DFS starts, and the order in which nodes/edges are visited, the low-link values for identifying SCCs could be wrong.\n\nSo, to make it work, we have to use an invariant that prevents SCCs from interfering with the low-link value of other SCCs.\n\n### Stack invariant\n\n#### Algorithm:\nTo cope with the random traversal order of the DFS, Tarjan’s algorithm maintains a stack of valid nodes from which to update low-link values. Nodes are added to the stack of valid nodes as they are explored for the first time. Nodes are removed from the stack each time a complete SCC is found.\n\n#### Update Condition for Low-Link\nIf u and v are nodes in a graph and we were currently exploring u, then our new low-link update condition is:\nTo update node u to node v low-link there has to be a path of edges from u to v and node v must be on the stack.\n\n#### Time Complexity\nWe are going to update low-link values on the fly  during the DFS so we can get a linear O(V+E) time complexity.\n\nCode:\n\n```c++\n#include<iostream>\n#include<stack>\n#define v 5\nusing namespace std;\n\nint graph[v][v];\n\nint min(int a, int b) {\n   return (a<b)?a:b;\n}\n\nvoid findComponent(int u, int disc[], int lowLink[], stack<int>&stk, bool stkItem[]) {\n   static int time = 0;\n   disc[u] = lowLink[u] = ++time;    \n   stk.push(u);\n   stkItem[u] = true;    \n\n   for(int v = 0; v<v; v++) {\n      if(graph[u][v]) {\n         if(disc[v] == -1) {   \n            findComponent(v, disc, lowLink, stk, stkItem);\n            lowLink[u] = min(lowLink[u], lowLink[v]);\n         } else if(stkItem[v])    \n            lowLink[u] = min(lowLink[u], disc[v]);\n      }\n   }\n\n   int poppedItem = 0;\n   if(lowLink[u] == disc[u]) {\n      while(stk.top() != u) {\n         poppedItem = stk.top();\n         cout << poppedItem << \" \";\n         stkItem[poppedItem] = false;   \n         stk.pop();\n      }\n      poppedItem = stk.top();\n      cout << poppedItem <<endl;\n      stkItem[poppedItem] = false;\n      stk.pop();\n   }\n}\n\nvoid strongConComponent() {\n   int disc[v], lowLink[v];\n   bool stkItem[v];\n   stack<int> stk;\n\n   for(int i = 0; i<v; i++) {    \n      disc[i] = lowLink[i] = -1;\n      stkItem[i] = false;\n   }\n\n   for(int i = 0; i<v; i++)    \n      if(disc[i] == -1)\n         findComponent(i, disc, lowLink, stk, stkItem);\n}\n\nint main() {\n   strongConComponent();\n}\n```\n\n### Overview \n\nMark the ID of each node as unvisited.\nStart DFS. Upon visiting a node, assign it an ID and a low-link value. Also, mark current nodes as visited and add them to a seen stack. \nOn DFS callback, if the previous node is on the stack, then min the current node’s low-link value with the last node’s low-link value. After visiting all neighbors, if the current node started a connected component, then pop nodes off the stack until the current node is reached.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1WA4wbSfAiGt7pf2mprZ4U","type":"Asset","createdAt":"2021-10-07T09:47:05.963Z","updatedAt":"2021-10-07T09:47:05.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"tarjan","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1WA4wbSfAiGt7pf2mprZ4U/ad45125680ba3a7033501dd8ca75fd5e/tarjan.jpeg","details":{"size":34129,"image":{"width":990,"height":355}},"fileName":"tarjan.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":6,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3KntZ6sSEjLlQmtIa4hbA2"}},{"sys":{"type":"Link","linkType":"Entry","id":"64dCpVTbATrysnaZ8MEmMz"}},{"sys":{"type":"Link","linkType":"Entry","id":"5IShlfU89ow1d1M8sujBp3"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7Emo2c6hFbIUfF9cBScXj3","type":"Entry","createdAt":"2020-02-20T09:27:12.700Z","updatedAt":"2021-11-06T03:24:31.062Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":418,"revision":56,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Introduction to Graphs and Their Data Structures part 1: Recognizing and Representing a Graph","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Graph","Data structure","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505841)\n<br/>\n<a href=\"#Introduction\">Introduction</a>\n<a href=\"#Recognizinggraphproblem\">Recognizing a graph problem</a>\n<a href=\"#Representinggraphandkeyconcepts\">Representing a graph and key concepts</a>\n<a href=\"#Singlylinkedlists\">Singly linked lists</a>\n<a href=\"#Trees\">Trees</a>\n<a href=\"#Graphs\">Graphs</a>\n<a href=\"#Arrayrepresentation\">Array representation</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nGraphs are a fundamental data structure in the world of programming, and this is no less so on topcoder. Usually appearing as the hard problem in Division 2, or the medium or hard problem in Division 1, there are many different forms solving a graph problem can take. They can range in difficulty from finding a path on a 2D grid from a start location to an end location, to something as hard as finding the maximum amount of water that you can route through a set of pipes, each of which has a maximum capacity (also known as the maximum-flow minimum-cut problem – which we will discuss later). Knowing the correct data structures to use with graph problems is critical. A problem that appears intractable may prove to be a few lines with the proper data structure, and luckily for us the standard libraries of the languages used by topcoder help us a great deal here!\n<br/><br/>\n<a name=\"Recognizinggraphproblem\" id=\"Recognizinggraphproblem\"></a>\n### Recognizing a graph problem\nThe first key to solving a graph related problem is recognizing that it is a graph problem. This can be more difficult than it sounds, because the problem writers don’t usually spell it out for you. Nearly all graph problems will somehow use a grid or network in the problem, but sometimes these will be well disguised. Secondly, if you are required to find a path of any sort, it is usually a graph problem as well. Some common keywords associated with graph problems are: vertices, nodes, edges, connections, connectivity, paths, cycles and direction. An example of a description of a simple problem that exhibits some of these characteristics is:\n\\\n\"Bob has become lost in his neighborhood. He needs to get from his current position back to his home. Bob’s neighborhood is a 2 dimensional grid, that starts at (0, 0) and (width – 1, height – 1). There are empty spaces upon which bob can walk with no difficulty, and houses, which Bob cannot pass through. Bob may only move horizontally or vertically by one square at a time.\n\\\nBob’s initial position will be represented by a ‘B’ and the house location will be represented by an ‘H’. Empty squares on the grid are represented by ‘.’ and houses are represented by ‘X’. Find the minimum number of steps it takes Bob to get back home, but if it is not possible for Bob to return home, return -1.\n\\\nAn example of a neighborhood of width 7 and height 5:\n<br/>\n```\n\n.X.X.XX\n.H…\n…X…\n…X.\"\n```\n\\\nOnce you have recognized that the problem is a graph problem it is time to start building up your representation of the graph in memory.\n<br/><br/>\n<a name=\"Representinggraphandkeyconcepts\" id=\"Representinggraphandkeyconcepts\"></a>\n### Representing a graph and key concepts\nGraphs can represent many different types of systems, from a two-dimensional grid (as in the problem above) to a map of the internet that shows how long it takes data to move from computer A to computer B. We first need to define what components a graph consists of. In fact there are only two, nodes and edges. A node (or vertex) is a discrete position in the graph. An edge (or connection) is a link between two vertices that can be either directed or undirected and may have a cost associated with it. An undirected edge means that there is no restriction on the direction you can travel along the edge. So for example, if there were an undirected edge from A to B you could move from A to B or from B to A. A directed edge only allows travel in one direction, so if there were a directed edge from A to B you could travel from A to B, but not from B to A. An easy way to think about edges and vertices is that edges are a function of two vertices that returns a cost. We will see an example of this methodology in a second.\n\\\nFor those that are used to the mathematical description of graphs, a graph G = {V, E} is defined as a set of vertices, V, and a collection of edges (which is not necessarily a set), E. An edge can then be defined as (u, v) where u and v are elements of V. There are a few technical terms that it would be useful to discuss at this point as well:\n\\\nOrder – The number of vertices in a graph\n\\\nSize – The number of edges in a graph\n<br/><br/>\n<a name=\"Singlylinkedlists\" id=\"Singlylinkedlists\"></a>\n### Singly linked lists\nAn example of one of the simplest types of graphs is a singly linked list! Now we can start to see the power of the graph data structure, as it can represent very complicated relationships, but also something as simple as a list.\n\\\nA singly linked list has one “head” node, and each node has a link to the next node. So the structure looks like this:\n<br/>\n```\nstructure node\n[node] link;\n[data]\nend\n\nnode head;\n```\n\\\nA simple example would be:\n<br/>\n```\nnode B, C;\nhead.next = B;\nB.next = C;\nC.next = null;\n```\n\\\nThis would be represented graphically as head -> B -> C -> null. I’ve used null here to represent the end of a list.\n\\\nGetting back to the concept of a cost function, our cost function would look as follows:\n<br/>\n```\ncost(X, Y) := if (X.link = Y) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nThis cost function represents the fact that we can only move directly to the link node from our current node. Get used to seeing cost functions because anytime that you encounter a graph problem you will be dealing with them in some form or another! A question that you may be asking at this point is “Wait a second, the cost from A to C would return not possible, but I can get to C from A by stepping through B!” This is a very valid point, but the cost function simply encodes the direct cost from a node to another. We will cover how to find distances in generic graphs later on.\n\\\nNow that we have seen an example of the one of the simplest types of graphs, we will move to a more complicated example.\n<br/><br/>\n<a name=\"Trees\" id=\"Trees\"></a>\n### Trees\nThere will be a whole section written on trees. We are going to cover them very briefly as a stepping-stone along the way to a full-fledged graph. In our list example above we are somewhat limited in the type of data we can represent. For example, if you wanted to start a family tree (a hierarchal organization of children to parents, starting from one child) you would not be able to store more than one parent per child. So we obviously need a new type of data structure. Our new node structure will look something like this:\n<br/>\n```\nstructure node\n[node] mother, father;\n[string] name\nend\n\nnode originalChild;\n```\n\\\nWith a cost function of:\n<br/>\n```\ncost(X, Y) := if ((X.mother = Y) or (X.father = Y)) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nHere we can see that every node has a mother and father. And since node is a recursive structure definition, every mother has mother and father, and every father has a mother and father, and so on. One of the problems here is that it might be possible to form a loop if you actually represented this data structure on a computer. And a tree clearly cannot have a loop. A little mind exercise will make this clear: a father of a child is also the son of that child? It’s starting to make my head hurt already. So you have to be very careful when constructing a tree to make sure that it is truly a tree structure, and not a more general graph. A more formal definition of a tree is that it is a connected acyclic graph. This simply means that there are no cycles in the graph and every node is connected to at least one other node in the graph.\n\\\nAnother thing to note is that we could imagine a situation easily where the tree requires more than two node references, for example in an organizational hierarchy, you can have a manager who manages many people then the CEO manages many managers. Our example above was what is known as a binary tree, since it only has two node references. Next we will move onto constructing a data structure that can represent a general graph!\n<br/><br/>\n<a name=\"Graphs\" id=\"Graphs\"></a>\n### Graphs\nA tree only allows a node to have children, and there cannot be any loops in the tree, with a more general graph we can represent many different situations. A very common example used is flight paths between cities. If there is a flight between city A and city B there is an edge between the cities. The cost of the edge can be the length of time that it takes for the flight, or perhaps the amount of fuel used.\n\\\nThe way that we will represent this is to have a concept of a node (or vertex) that contains links to other nodes, and the data associated with that node. So for our flight path example we might have the name of the airport as the node data, and for every flight leaving that city we have an element in neighbors that points to the destination.\n<br/>\n```\nstructure node\n[list of nodes] neighbors\n[data]\nend\n\ncost(X, Y) := if (X.neighbors contains Y) return X.neighbors[Y];\nelse “Not possible”\n\nlist nodes;\n```\n\\\nThis is a very general way to represent a graph. It allows us to have multiple edges from one node to another and it is a very compact representation of a graph as well. However the downside is that it is usually more difficult to work with than other representations (such as the array method discussed below).\n<br/><br/>\n<a name=\"Arrayrepresentation\" id=\"Arrayrepresentation\"></a>\n### Array representation\nRepresenting a graph as a list of nodes is a very flexible method. But usually on topcoder we have limits on the problems that attempt to make life easier for us. Normally our graphs are relatively small, with a small number of nodes and edges. When this is the case we can use a different type of data structure that is easier to work with.\n\\\nThe basic concept is to have a 2 dimensional array of integers, where the element in row i, at column j represents the edge cost from node i to j. If the connection from i to j is not possible, we use some sort of sentinel value (usually a very large or small value, like -1 or the maximum integer). Another nice thing about this type of structure is that we can represent directed or undirected edges very easily.\n\\\nSo for example, the following connection matrix:\n<br/>\n```\nA B C\nA 0 1 5\nB -1 0 1\nC -1 -1 0\n```\n\\\nWould mean that node A has a 0 weight connection to itself, a 1 weight connection to node B and 5 weight connection to node C. Node B on the other hand has no connection to node A, a 0 weight connection to itself, and a 1 weight connection to C. Node C is connected to nobody. This graph would look like this if you were to draw it:\n<br/><div style=\"text-align:center;\">\n![graph](//images.ctfassets.net/piwi0eufbb2g/39urFkSmHSQE5Y9thpTSbl/89c592184413c140e1b8706429dff7d1/graph.gif)\n</div>\nThis representation is very convenient for graphs that do not have multiple edges between each node, and allows us to simplify working with the graph.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Introduction%20to%20Graphs%20and%20Their%20Data%20Structures%20part%202:%20Searching%20a%20Graph)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"7dpViJNiGS7Fflpf8x767t"}}],"upvotes":19,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}},{"sys":{"type":"Link","linkType":"Entry","id":"ypU3M6AxrYYmErQqodsVr"}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2FyFPuf9ftL4DguU4YFcoe","type":"Entry","createdAt":"2020-02-19T12:59:58.263Z","updatedAt":"2022-07-11T04:33:32.572Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":148,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Find a Solution","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["SRM","Flood Fill","Problem","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"30 min","content":"[Discuss this article in the forums.](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505843)\n<br/>\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#straightforward\">Straight-forward problems that don’t require a special technique</a>\n<a href=\"#bfs\">Breadth First Search (BFS)</a>\n<a href=\"#floodfill\">Flood Fill</a><\n<a href=\"#bruteNback\">Brute Force and Backtracking</a>\n<a href=\"#bruteforce\">Brute Force</a>\n<a href=\"#backtracking\">Backtracking</a>\n<a href=\"#dp\">Dynamic Programming</a>\n<a href=\"#harddrills\">Hard Drills</a>\n<a href=\"#maximumflow\">Maximum Flow</a>\n<a href=\"#optimal\">Optimal Pair Matching</a>\n<a href=\"#lp\">Linear Programming (Simplex)</a>\n<a href=\"#conclusion\">Conclusion</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nWith many Topcoder problems, the solutions may be found instantly just by reading their descriptions. This is possible thanks to a collection of common traits that problems with similar solutions often have. These traits serve as excellent hints for experienced problem solvers that are able to observe them. The main focus of this article is to teach the reader to be able to observe them too.\n\\\n<a name=\"straightforward\" id=\"straightforward\"></a> __Straight-forward problems that don’t require any special technique (e.g. simulation, searching, sorting etc.)__\n\tIn most cases, these problems will ask you to perform some step by step, straight-forward tasks. Their constraints are not high, and not too low. In most cases the first problems (the easiest ones) in topcoder Single Rounds Matches are of this kind. They test mostly how fast and properly you code, and not necessarily your algorithmic skills.\n\\\nMost simple problems of this type are those that ask you just to execute all steps described in the statement.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BusinessTasks](http://community.topcoder.com/stat?c=problem_statement&pm=1585&rd=6535) – SRM 236 Div 1:__\nN tasks are written down in the form of a circular list, so the first task is adjacent to the last one. A number n is also given. Starting with the first task, move clockwise (from element 1 in the list to element 2 in the list and so on), counting from 1 to n. When your count reaches n, remove that task from the list and start counting from the next available task. Repeat this procedure until one task remains. Return it.\n</div>\n\\\nFor N&lt;=1000 this problem is just a matter of coding, no special algorithm is needed – do this operation step by step until one item is left. Usually these types of problems have a much smaller N, and so we’ll not consider cases where N is very big and for which complicated solution may be needed. Remember that in topcoder competitions even around 100 millions sets of simple operations (i.e. some multiplications, attributions or if statements) will run in allowed time.\n\\\nThis category of problems also includes those that need some simple searches.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[TallPeople](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2923&amp;rd=5854) – SRM 208 Div 1:__\nA group of people stands before you arranged in rows and columns. Looking from above, they form an R by C rectangle of people. Your job is to return 2 specific heights – the first is computed by finding the shortest person in each row, and then finding the tallest person among them (the \"tallest-of-the-shortest\"); and the second is computed by finding the tallest person in each column, and then finding the shortest person among them (the \"shortest-of-the-tallest\").\n</div>\n\\\nAs you see this is a really simple search problem. What you have to do is just to follow the steps described in the statement and find those 2 needed heights. Other TC problems may ask you to sort a collection of items by respecting certain given rules. These problems may be also included in this category, because they too are straight-forward – just sort the items respecting the rules! You can do that with a simple O(N^2) sorting algorithm, or use standard sorting algorithm that exist in your coding language. It’s just a matter of coding.\n<br/>\n__Other example(s):__\n\t__[MedalTable](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2922&amp;rd=5855) – SRM 209 Div 1__.\n<br/>\n\\\n<a name=\"bfs\" id=\"bfs\"></a> __Breadth First Search (BFS)__\n\nProblems that use BFS usually ask to find the fewest number of steps (or the shortest path) needed to reach a certain end point (state) from the starting one. Besides this, certain ways of passing from one point to another are offered, all of them having the same cost of 1 (sometimes it may be equal to another number). Often there is given a N x M table (formed of N lines and M columns) where certain cells are passable and others are impassable, and the target of the problem is to find the shortest time/path needed to reach the end point from the start one. Such tables may represent mazes, maps, cities, and other similar things. These may be considered as classical BFS problems. Because BFS complexity is in most cases linear (sometimes quadratic, or N logN), constraints of N (or M) could be high – even up to 1 million.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[SmartWordToy](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3935&amp;rd=6532) – SRM 233 Div 1:__\nA word composed of four Latin lowercase letters is given. With a single button click you can change any letter to the previous or next letter in alphabetical order (for example ‘c’ can be changed to ‘b’ or ‘d’). The alphabet is circular, thus ‘a’ can become ‘z’, and ‘z’ can become ‘a’ with one click.<br/>\nA collection of constraints is also given, each defining a set of forbidden words. A constraint is composed of 4 strings of letters. A word is forbidden if each of its characters is contained in corresponding string of a single constraint, i.e. first letter is contained in the first string, the second letter – in the second string, and so on. For example, the constraint \"lf a tc e\" defines the words \"late\", \"fate\", \"lace\" and \"face\".<br/>\nYou should find the minimum number of button presses required to reach the word finish from the word start without passing through forbidden words, or return -1 if this is not possible.\n</div>\n\\\n__Problem hints:__\n* Words can be considered as states. There are at most 26^4 different words composed of 4 letters (thus a linear complexity will run in allowed time).\n* There are some ways to pass from one state to another.\n* The cost of passing from a state to another is always 1 (i.e. a single button click).\n* You need to find the minimum number of steps required to reach the end state from start state.\n\nEverything indicates us that it’s a problem solved by the help of a BFS. Similar things can be found in any other BFS problems. Now let’s see an interesting case of BFS problems.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[CaptureThemAll](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2915&amp;rd=5853) – SRM 207 Div 2 (3rd problem):__\nHarry is playing a chess game. He has one knight, and his opponent Joe has a queen and a rook. Find the minimum number of steps that Harry’s knight has to jump so that it captures both the queen and the rook.\n</div>\n\n__Problem hints:__ At first sight this may seem like dynamic programming or backtracking. But as always, take a look into the text of the statement. After a while you should observe the following things: \n\n* A table is given.\n* The knight can jump from one cell to some of its neighbors.\n* The cost of passing from a cell to another is always 1 (just one jump).\n* You need to find the minimum number of steps (jumps).\n\nGiven this information we can see that the problem can be easily solved by the help of BFS. Don’t get confused by the fact that connected points are represented by unconnected cells. Think of cells as points in a graph, or states (whatever you want) – and in order to pass from one point to another, the knight should be able to jump from the first to the second point.\n\nNotice again that the most revealing hint about the BFS solution is the cost of 1 for any jump.\n\nTrain yourself in finding the hints of a BFS problem in following examples:\n\n__Other example(s):__\n__[RevolvingDoors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3064&amp;rd=5869) – SRM 223 Div 1__.\n__[WalkingHome](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3444&amp;rd=5868) – SRM 222 Div 1__.\n__[TurntableService](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3117&amp;rd=5865) – SRM 219 Div 1__.\n<br/>\n\\\n<a name=\"floodfill\" id=\"floodfill\"></a> __Flood Fill__\nSometimes you may encounter problems that are solved by the help of Flood Fill, a technique that uses BFS to find all reachable points. The thing that makes them different from BFS problems described above is that a minimum path/cost is not needed.\nFor example, imagine a maze where 1 represents impassable cells and 0 passable cells. You need to find all cells that are reachable from the upper-left corner. The solution is very simple – take one-by-one a visited vertex, add its unvisited neighbors to the queue of visited vertices and proceed with the next one while the queue is still populated. Note that in most cases a DFS (Depth First Search) will not work for such problems due to stack overflows. Better use a BFS. For inexperienced users it may seem harder to implement, but after a little training it becomes a \"piece of cake\". A good example of such problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[grafixMask](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2998&amp;rd=5857) – SRM 211 Div 1:__\nA 400 x 600 bitmap is given. A set of rectangles covers certain parts of this bitmap (the corners of rectangles have integer coordinates). You need to find all contiguous uncovered areas, including their sizes.\n</div>\n\n__Problem hints:__ What do we have here?\n* A map (table)\n* Certain points are impassable (those covered by given rectangles)\n* Contiguous areas need to be found\n\nIt is easy to understand that a problem with such a statement needs a Flood Fill. Usually problems using it are very easy to detect.\n\\\n<a name=\"bruteNback\" id=\"bruteNback\"></a> __Brute Force and Backtracking__\nI have placed these 2 techniques in the same category because they are very similar.  Both do the same thing – try all possible cases (situations) and choose the best one, or count only those that are needed (depending on the problem). Practically, Backtracking is just more advanced and optimized than Brute Force. It usually uses recursion and is applied to problems having low constraints (for example N&lt;=20). </p>\n\\\n<a name=\"bruteforce\" id=\"bruteforce\"></a>\n__Brute Force__\nThere are many problems that can be solved by the help of a simple brute force. Note that the limits must not be high. How does a brute force algorithm work? Actually, it tries all possible situations and selects the best one. It’s simple to construct and usually simple to implement. If there is a problem that asks to enumerate or find all possible ways (situations) of doing a certain thing, and that doesn’t have high limits – then it’s most probably a brute force problem.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[GeneralChess](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2430&amp;rd=5072) – SRM 197 Div 1:__\nYou are given some knights (at most 8), with their positions on the table (-10000&lt;=x, y&lt;=10000). You need to find all positions to place another one, so that it threatens all given pieces. \n</div>\n\n__Problem hints:__ Well, this is one of the easiest examples. So which are the hints of this statement?\n* You need to find all possible situations (positions) that satisfy a certain rule (threatens all given pieces).\n* The limits are very low – only 8 knights are at most given.\n\nIt’s a common Brute Force problem’s statement. Note that x and y limits are not relevant, because you need only try all positions that threaten one of the knights. For each of these positions see if the knight placed at that position threatens all others too.\n\nAnother interesting problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[LargestCircle](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3005&amp;rd=5858) – SRM 212 Div 2 (3rd problem):__\nGiven a regular square grid, with some number of squares marked, find the largest circle you can draw on the grid that does not pass through any of the marked squares. The circle must be centered on a grid point (the corner of a square) and the radius must be an integer. Return the radius of the circle.\n<br/> The size of the grid is at most 50.\n</div>\n\n__Problem hints:__ And again one of the most important hints is the low limit of the size of the grid – only 50. This problem is possible to be solved with the help of the Brute Force because for each cell you can try to find the circle whose center is situated in that cell and that respects the rules. Among all of these circles found, select the one that has the greatest radius.\n\nComplexity analysis: there are at most 50×50 cells, a circle’s radius is an integer and can be at most 25 units, and you need a linear time (depending on your implementation) for searching the cells situated on the border of the circle. Total complexity is low and thus you can apply a simple Brute Force here.\n\n__Other example(s):__\n__[Cafeteria](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3080&amp;rd=6518) - SRM 229 Div 1__\n__[WordFind](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3972&amp;rd=6521) - SRM 232 Div 1__\n\n<a name=\"backtracking\" id=\"backtracking\"></a> __Backtracking__\nThis technique may be used in many types of problems.  Just take a look at the limits (N, M and other main parameters). They serve as the main hint of a backtrack problem. If these are very small and you haven’t found a solution that’s easier to implement – then just don’t waste your time on searching it and implement a straight-forward backtracking solution.\n\nUsually problems of this kind ask you to find (similarly to Brute Force):\n1. Every possible configuration (subset) of items. These configurations should respect some given rules.\n2. The \"best\" configuration (subset) that respects some given rules.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BridgeCrossing](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1599&amp;rd=4535) – SRM 146 Div 2 (3rd problem):__\nA group of people is crossing an old bridge. The bridge cannot hold more than two people at once. It is dark, so they can’t walk without a flashlight, and they only have one flashlight! Furthermore, the time needed to cross the bridge varies among the people in the group. When people walk together, they always walk at the speed of the slowest person. It is impossible to toss the flashlight across the bridge, so one person always has to go back with the flashlight to the others. What is the minimum amount of time needed to get all the people across the bridge?\n<br/> There are at most 6 people.\n</div>\n\n__Problem hints:__\n* First look at the constraints – there are at most ONLY 6 people! It’s enough for generating all possible permutations, sets etc.\n* There are different possible ways to pass the people from one side to another and you need to find the best one.\n\nThis is of course a problem solved with a backtracking: at the beginning choose any 2 people to pass the bridge first, and after that at each step try to pass any of those that have been left on the start side. From all these passages select the one that needs the smallest amount of time. Note that among persons that have passed over the bridge, the one having the greatest speed should return (it’s better than returning one having a lower speed). This fact makes the code much easier to implement. After having realized these things – just code the solution. There may be others – but you will lose more time to find another than to code this one.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[MNS](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – SRM 148 Div 1:__\n9 numbers need to be arranged in a magic number square. A magic number square is a square of numbers that is arranged such that every row and column has the same sum. You are given 9 numbers that range from 0 to 9 inclusive. Return the number of distinct ways that they can be arranged in a magic number square. Two magic number squares are distinct if they differ in value at one or more positions. \n</div>\n\n__Problem hints:__ Only 9 numbers are given at most; and every distinct way (configuration) to arrange the numbers so that they form a magic number square should be found.\n\nThese are the main properties of a Backtracking problem. If you have observed them – think about the code. You can generate all permutations of numbers and for each of them check if it forms a magic square. If so – add it to the answer. Note that it must be unique. A possible way to do that – is to have a list of earlier found configurations, thus for each new magic square check if it exists in that list and if it doesn’t – add it to the answer. There will not be many distinct magic squares, thus no additional problems will appear when applying this method.\n\n__Other example(s):__\n\n__[WeirdRooks](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3998&amp;rd=6533) - SRM 234 Div 1__\n\\\n<a name=\"dp\" id=\"dp\"></a> __Dynamic Programming__\nQuite a few problems are solved with the help of this technique. Knowing how to detect this type of problem can be very valuable.  However in order to do so, one has to have some experience in dynamic programming. Usually a DP problem has some main integer variables (e.g. N) which are neither too small, nor too big – so that a usual DP complexity of N^2, N^3 etc. fits in time. Note that in the event that N is very small (for TC problems usually less than 30) – then it is likely the problem is not a DP one. Besides that there should exist states and one or more ways (rules) to reach one greater state from another lower one.  In addition, greater states should depend only upon lower states. What is a so-called state? It’s just a certain configuration or situation. To better understand dynamic programming, you may want to read [this article](http://community.topcoder.com/tc?module=Static&amp;d1=tutorials&amp;d2=dynProg).\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nLet’s analyze a simple classic DP problem:<br/>\nGiven a list of N coins with their values (V1, V2, … ,VN), and the total sum S. Find the minimum number of coins the sum of which is S (you can use as many coins of one type as you want), or report that it’s not possible to select coins in such a way that they sum up to S.<br/>\nLet N &lt;= 1,000 and S &lt;= 1,000.\n</div>\n\n__Problem hints:__\n* Two main integer variables are given (N and S). These are neither too small, nor are they too big (i.e. a complexity of N*S fits in time).\n* A state can be defined as the minimum number of coins needed to reach a certain sum.\n* A sum (state) i depends only on lower sums (states) j (j&lt;i).\n* By adding a coin to a certain sum – another greater sum is reached. This is the way to pass from one state to another.\n\nThus all properties of a DP problem are uncovered in this statement. Let’s see another (slightly harder) DP problem:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[ZigZag](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – 2003 TCCC Semifinals 3:__\nA sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a zig-zag sequence. Given a sequence of integers, return the length of the longest subsequence that is a zig-zag sequence. A subsequence is obtained by deleting some number of elements (possibly zero) from the original sequence, leaving the remaining elements in their original order. Assume the sequence contains between 1 and 50 elements, inclusive. \n</div>\n\n__Problem hints:__\n* There are N numbers given (1&lt;=N&lt;=50), thus N isn’t too small, nor too big.\n* A state (i,d) can be defined as the length of the longest zig-zag subsequence ending with the i-th number, for which the number before the last one is smaller than it for d=0, and bigger for d=1.\n* A state i (i.e. a subsequence ending with the i-th number) depends only on lower states j (j&lt;i).\n* By adding a number to the end of a subsequence – another bigger (greater) subsequence is created. This is the way to pass from one state to another.\n\nAs you can see – this statement has almost the same traits (pattern) as in the previous problem. The most difficult part in identifying a DP problem statement is observing/seeing the states with the properties described above. Once you can do that, the next step is to construct the algorithm, which is out of the scope of this article.\n\n__Other example(s):__\n__[ChessMetric](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1592&amp;rd=4482) - 2003 TCCC Round 4__\n__[AvoidRoads](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1889&amp;rd=4709) - 2003 TCO Semifinals 4__\n__[FlowerGarden](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1918&amp;rd=5006) - 2004 TCCC Round 1__\n__[BadNeighbors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2402&amp;rd=5009) - 2004 TCCC Round 4__\n\\\n<a name=\"harddrills\" id=\"harddrills\"></a> __Hard Drills:__\n<a name=\"maximumflow\" id=\"maximumflow\"></a> __Maximum Flow__\n\nIn many cases it’s hard to detect a problem whose solution uses maximum flow.  Often you have to create/define graphs with capacities based on the problem statement.\n\nHere are some signs of a Maximum Flow problem:\n* Take a look at the constraints, they have to be appropriate for a O(N^3) or O(N^4) solution, i.e. N shouldn’t be greater than 500 in extreme cases (usually it’s less than 100).\n* There should be a graph with edges having capacities given, or you should be able to define/create it from data given in the statement.\n* You should be finding a maximum value of something.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nSample problem:<br/>\nYou are given a list of water pipes, each having a certain maximum water flow capacity. There are water pipes connected together at their extremities. <br/>\nYou have to find the maximum amount of water that can flow from start junction to end junction in a unit of time. <br/>\nLet N&lt;=100. <br/>\n</div>\n\nAs you can see – it’s a straight-forward maximum flow problem: water pipes represent edges of the graph, their junctions – vertices; and you have to find the maximum value of amount of water that can flow from start to end vertex in a unit of time.\n\\\n<a name=\"optimal\" id=\"optimal\"></a> __Optimal Pair Matching:__\nThese problems usually have a list of items (from a set A) for which other items (from a set B) should be assigned under some rules, so that all (or a maximum possible number of) items from set A have to each be assigned to a certain item from set B.\n\n__Mixed:__\nSome problems need other techniques in addition to network flows.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Parking](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3530&amp;rd=6535) - SRM 236 Div 1:__\nN cars and M parking lots are given. They are situated on a rectangular surface (represented by a table), where certain cells are impassable. You should find a way to assign each car to a parking lot, so that the greatest of the shortest distances from each car to its assigned parking lot is as small as possible. Each parking lot can have at most one car assigned to it. \n</div>\n__Problem hints:__ By reading this problem one can simply understand the main idea of the solution – it should be something similar to optimal pair matching, because each car (point from a set A) should be assigned to a parking lot (point from a set B) so that all are assigned and that there is at most one car assigned to a parking lot. Additionally, there can be cars that can’t reach certain parking lots, thus some pairs of points (one point from A and the other from B) are not connected. However a graph should be created for optimal pair matching. The way to make it is clear – an edge exists between a car and a parking lot if only there is a path between them, and its cost is equal to the shortest distance needed for the car to reach the parking lot. The next step of the solution is a binary search on the longest edge. Although it may be out of the scope of this article, I will provide a short explanation: At each step delete those edges of the initial graph that have costs greater than a certain value C (Note that you’ll have to save the initial graph’s state in order to repeat this step again for other C values). If it’s possible in this case to assign all the cars to parking lots – then take a smaller C, and repeat the same operation. If not – take a greater C. After a complete binary search, the smallest C for which a complete assignment is possible will be found. This will be the answer.\n\\\n<a name=\"lp\" id=\"lp\"></a> __Linear Programming (Simplex)__\nMost of the common traits of problems solved with the help of the linear programming technique are:\n* You are given collection of items having different costs/weights. There is a certain quantity of each item that must be achieved.\n* A list of sets is given. These sets are composed of some of the available items, having certain quantities of each of them. Each set has a certain cost. \n* The goal of the problem is to find an optimal combination (the cheapest one) of these sets so that the sum of quantities of each of the items they have is exactly the one needed to achieve.\n\nAt first it may seem confusing, but let’s see an example:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Mixture](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3942&amp;rd=6520) - SRM 231 Div 1:__\nA precise mixture of a number of different chemicals, each having a certain amount, is needed. Some mixtures of chemicals may be purchased at a certain price (the chemical components for the mixture might not be available in pure form). Each of them contains certain amounts of some of the chemicals. You need not purchase the available mixtures in integral amounts. Hence if you purchase a 1.5 of a mixture having a price of 3 and amounts of \"2 0 1\", you’ll pay 4.5 and get \"3 0 1.5\" amounts of chemicals. Your task is to determine the lowest price that the desired mixture can be achieved. \n</div>\n__Problem hints:__\n* A collection of items (chemicals).\n* A list of sets (available mixtures), each containing certain amounts of each of the items, and having a certain cost.\n* You need to find the lowest price of the desired collection of items achieved by the combination of the available sets. More than that – you can take also non-integral amounts of mixtures.\n\nThese are exactly the traits described above.\n\\\n<a name=\"conclusion\" id=\"conclusion\"></a>\n__Conclusion__\nIf you have found this article interesting and you have learned new things from it – train yourself on any of the problems in the topcoder Algorithm Arena. Try hard to see the hints and determine the type of the solution by carefully reading through the problem statement. Remember, there are still many problems that may not be included properly in any of the categories described above and may need a different approach.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":27,"downvotes":1}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"01JIR2EKpWpW9ZcokunEDM","type":"Entry","createdAt":"2021-12-15T09:29:38.217Z","updatedAt":"2022-09-10T06:09:40.018Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":60,"revision":10,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Snakes and Ladders Problem","slug":"snakes-and-ladders-problem","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Rte82DJ0sXfUl9RRcJ2O3","type":"Entry","createdAt":"2019-09-18T07:37:35.298Z","updatedAt":"2019-09-18T07:37:35.298Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Dynamic Programming","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["C++","BFS"],"creationDate":"2021-12-15","readTime":"9min","content":"### About the problem:\n\nLike a traditional snakes and ladders game, we are provided with a 10\\*10 board numbered from one to one hundred and dice with faces numbered from one to six. We start from square one, and the game is considered finished when a player reaches square one hundred. \n\nCovering two other aspects of snakes and ladders we are given two vectors of vector ladder and snake where, \n\n-   ladder\\[i\\]\\[0\\] denotes the starting square of the ith ladder and ladder\\[i\\]\\[1\\] denotes the end of the ith ladder.\n\n-   snake\\[i\\]\\[0\\] denotes the mouth of the ith snake and snake\\[i\\]\\[1\\] denotes the tail of the ith snake.\n\nNow we are required to find the minimum number of rolls to reach the hundredth square.\n\n__Example 1:__\n\nInput: ladder = \\[\\[14,28\\],\\[42,78\\],\\[55,97\\],\\[52,92\\]\\]\n\nsnake = \\[\\[99,25\\],\\[88,54\\],\\[29,10\\]\\]\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2a7jMZ4a8BCh3Qzfwog7N4/77bde54994c8c0bdd02c944e661f8697/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2a7jMZ4a8BCh3Qzfwog7N4/77bde54994c8c0bdd02c944e661f8697/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2a7jMZ4a8BCh3Qzfwog7N4/77bde54994c8c0bdd02c944e661f8697/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\nOutput: 9\n\n__Example 2:__\n\nInput: ladder = \\[\\[6,46\\],\\[19,43\\],\\[52,71\\],\\[57,98\\]\\]\n\nsnake = \\[\\[47,9\\],\\[62,40\\],\\[96,75\\]\\]\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\nOutput: 4\n\n### Approach: Breadth-First Search (BFS)\n\nFor this approach, we consider the board a graph and every square as the vertex of the graph. Here our starting vertex is one, and one hundred is the final, or destination, vertex. So, since there are six faces on a dice, we have six possible squares to move to from a particular square.\n\nIf we encounter ladder i, then it would take us from ladder\\[i\\]\\[0\\] to ladder\\[i\\]\\[1\\] in zero moves. Likewise, If we encounter a snake j, then it would take us from snakeji\\]\\[0\\] to snake\\[j\\]\\[1\\] in zero moves.\n\nTo note these details we are using an unordered map like below:\n\n```cpp\nunordered_map<int,int> m;\nfor(vector<int> &i : ladder)\n    m[i[0]] = i[1];\n\nfor(vector<int> &i : snake)\n    m[i[0]] = i[1]\n```\n\nComing to the core approach we do a level order search using BFS, where we push all possible positions in a queue, and in the next iteration loop over only the next level positions, and increment the final answer with the increasing levels in the algorithm.\n\nAlgorithm:\n\n1.  Create an explicit map and insert the ladder, snake jumping possibilities.\n\n2.  Now declare a queue and a variable level incremented with 1.\n\n3.  Now push 1 to queue and start doing a level order search.\n\n4.  Calculate the size of the queue and traverse on each possible value.\n\n1.  The new position will be x + i (1<=i<=6) if x+i is a value in map then we move to that like pos = m\\[x+i\\].\n\n2.  If the new value is 100 then we return the variable level.\n\n3.  Otherwise if the new position was not visited before then we mark it visited and push it into the queue.\n\n6.  If we are out of queue then we return -1.\n\n__Code:__\n\n```cpp\n#include<bits/stdc++.h>\nusing namespace std;\n\nint snakeLadder(vector<vector<int> > &ladder, vector<vector<int> > &snake) {\n    unordered_map<int,int> m;\n    for(vector<int> &i : ladder)\n        m[i[0]] = i[1];\n\n    for(vector<int> &i : snake)\n        m[i[0]] = i[1];\n\n    queue<int> q;\n    q.push(1);\n    int level = 1;\n    vector<bool> vis(101,0); \n    while(!q.empty())\n    {\n        int size = q.size();\n        while(size--)\n        {\n            int x = q.front();\n            q.pop();\n            for(int i=1; i<7; i++)\n            {\n                int finalpos = x+i;\n                if(m.count(x+i))\n                    finalpos = m[x+i];\n\n                if(finalpos == 100)\n                    return level;\n\n                if(!vis[finalpos])\n                {\n                    vis[finalpos] = 1;\n                    q.push(finalpos);\n                }\n\n            }\n        }\n        ++level;\n    }\n    return -1;\n}\n\nint main()\n{   \n    int s,l;\n    cin >> l;\n    vector<vector<int>> snake,ladder;\n\n    int st,en;\n    for(int i=0;i<l;i++){\n        cin >> st >> en;\n        ladder.push_back({st,en});\n    }\n\n    cin  >> s;\n    for(int i=0;i<s;i++){\n        cin >> st >> en;\n        snake.push_back({st,en});\n    }\n\n    cout << snakeLadder(snake,ladder);\n}\n```\n\n__Input:__\n4 6 46 19 43 52 71 57 98\n3 47 9 62 40 96 75\n\n__Output:__\n4","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2bAdOFpJGT2SDWvp6UeM1R","type":"Asset","createdAt":"2021-12-15T09:24:52.920Z","updatedAt":"2021-12-15T09:24:52.920Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"image","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png","details":{"size":222871,"image":{"width":861,"height":632}},"fileName":"image.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":8,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7jt5BLGIRNTxAd0kkhmd7U"}},{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"53DKhRPQZF8wHYXn3Nrpue","type":"Entry","createdAt":"2021-11-16T20:47:39.346Z","updatedAt":"2024-07-02T15:06:59.853Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":54,"revision":27,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competitive Programming at Topcoder: A Step by Step Guide","slug":"competitive-programming-at-topcoder-a-step-by-step-guide","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":67,"downvotes":5,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}}}]}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6SVKkQffchAt1KAGrhgch4","type":"Entry","createdAt":"2020-02-22T15:26:17.339Z","updatedAt":"2022-06-22T21:17:05.347Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Primality Testing : Non-deterministic Algorithms","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","Testing","Java","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=519109)\n\n### Introduction\n\nPrimality testing of a number is perhaps the most common problem concerning number theory that topcoders deal with. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. Some basic algorithms and details regarding primality testing and factorization can be found [here](https://www.topcoder.com/thrive/articles/Prime%20Numbers,%20Factorization%20and%20Euler%20Function).\n\nThe problem of detecting whether a given number is a prime number has been studied extensively but nonetheless, it turns out that all the deterministic algorithms for this problem are too slow to be used in real life situations and the better ones amongst them are tedious to code. But, there are some probabilistic methods which are very fast and very easy to code. Moreover, the probability of getting a wrong result with these algorithms is so low that it can be neglected in normal situations.\n\nThis article discusses some of the popular probabilistic methods such as Fermat’s test, Rabin-Miller test, Solovay-Strassen test.\n\n### Modular Exponentiation\n\nAll the algorithms which we are going to discuss will require you to efficiently compute (ab)%c ( where a,b,c are non-negative integers ). A straightforward algorithm to do the task can be to iteratively multiply the result with ‘a’ and take the remainder with ‘c’ at each step.\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* a function to compute (ab)%c */\nint modulo(int a,int b,int c){\n    // res is kept as long long because intermediate results might overflow in \"int\"\n    long long res = 1; \n    for(int i=0;i<b;i++){\n        res *= a;\n        res %= c; // this step is valid because (a\\*b)%c = ((a%c)\\*(b%c))%c\n    }\n    return res%c;\n}\n</div>\n\nHowever, as you can clearly see, this algorithm takes O(b) time and is not very useful in practice. We can do it in O( log(b) ) by using what is called as exponentiation by squaring. The idea is very simple:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n   (a2)(b/2)           if b is even and b > 0\nab = a*(a2)((b-1)/2)    if b is odd\n   1                  if b = 0\n   </div>\n\nThis idea can be implemented very easily as shown below:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* This function calculates (ab)%c */\nint modulo(int a,int b,int c){\n    long long x=1,y=a; // long long is taken to avoid overflow of intermediate results\n    while(b > 0){\n        if(b%2 == 1){\n            x=(x*y)%c;\n        }\n        y = (y*y)%c; // squaring the base\n        b /= 2;\n    }\n    return x%c;\n}\n</div>\nNotice that after i iterations, b becomes b/(2i), and y becomes (y(2i))%c. Multiplying x with y is equivalent to adding 2i to the overall power. We do this if the ith bit from right in the binary representation of b is 1. Let us take an example by computing (7107)%9\\. If we use the above code, the variables after each iteration of the loop would look like this: ( a = 7, c = 9 )\n\niterations&nbsp;&nbsp;&nbsp;     b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  y\n    0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   107 &nbsp;&nbsp;&nbsp;    1  &nbsp;&nbsp;&nbsp;&nbsp;   7\n    1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    53 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          7  &nbsp;&nbsp;&nbsp;&nbsp;    4\n    2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    26 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          1  &nbsp;&nbsp;&nbsp;&nbsp;    7\n    3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    13 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          1  &nbsp;&nbsp;&nbsp;&nbsp;   4\n    4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     6   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          4  &nbsp;&nbsp;&nbsp;&nbsp;   7\n    5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     3  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           4  &nbsp;&nbsp;&nbsp;&nbsp;   4\n    6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        7  &nbsp;&nbsp;&nbsp;&nbsp;   7\n    7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           4&ensp;&nbsp;&nbsp;&nbsp;&nbsp;                       4\n    \n\n\nNow b becomes 0 and the return value of the function is 4. Hence (7107)%9 = 4.\n\nThe above code could only work for a,b,c in the range of type “int” or the intermediate results will run out of the range of “long long”. To write a function for numbers up to 10^18, we need to compute (a\\*b)%c when computing a\\*b directly can grow larger than what a long long can handle. We can use a similar idea to do that:\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n    (2\\*a)\\*(b/2)              if b is even and b > 0\na\\*b = a + (2\\*a)*((b-1)/2)    if b is odd\n    0       if b = 0\n</div>\n\nHere is some code which uses the idea described above ( you can notice that its the same code as exponentiation, just changing a couple of lines ):\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* this function calculates (a\\*b)%c taking into account that a\\*b might overflow */\nlong long mulmod(long long a,long long b,long long c){\n    long long x = 0,y=a%c;\n    while(b > 0){\n        if(b%2 == 1){\n            x = (x+y)%c;\n        }\n        y = (y*2)%c;\n        b /= 2;\n    }\n    return x%c;\n}\n</div>\n\nWe could replace x=(x\\*y)%c with x = mulmod(x,y,c) and y = (y\\*y)%c with y = mulmod(y,y,c) in the original function for calculating (ab)%c. This function requires that 2*c should be in the range of long long. For numbers larger than this, we could write our own BigInt class ( java has an inbuilt one ) with addition, multiplication and modulus operations and use them.\n\nThis method for exponentiation could be further improved by using Montgomery Multiplication. Montgomery Multiplication algorithm is a quick method to compute (a*b)%c, but since it requires some pre-processing, it doesn’t help much if you are just going to compute one modular multiplication. But while doing exponentiation, we need to do the pre-processing for ‘c’ just once, that makes it a better choice if you are expecting very high speed. You can read about it at the links mentioned in the reference section.\n\nSimilar technique can be used to compute (ab)%c in O(n3 \\* log(b)), where a is a square matrix of size n x n. All we need to do in this case is manipulate all the operations as matrix operations. Matrix exponentiation is a very handy tool for your algorithm library and you can see problems involving this every now and then.\n\n### Fermat Primality Test\n\n**Fermat’s Little Theorem**  \nAccording to Fermat’s Little Theorem if p is a prime number and a is a positive integer less than p, then\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n    ap = a ( mod p )\nor alternatively:\n    a(p-1) = 1 ( mod p )\n</div>\n**Algorithm of the test**  \nIf p is the number which we want to test for primality, then we could randomly choose a, such that a < p and then calculate (a(p-1))%p. If the result is not 1, then by Fermat’s Little Theorem p cannot be prime. What if that is not the case? We can choose another a and then do the same test again. We could stop after some number of iterations and if the result is always 1 in each of them, then we can state with very high probability that p is prime. The more iterations we do, the higher is the probability that our result is correct. You can notice that if the method returns composite, then the number is sure to be composite, otherwise it will be probably prime.\n\nGiven below is a simple function implementing Fermat’s primality test:\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* Fermat's test for checking primality, the more iterations the more is accuracy */\nbool Fermat(long long p,int iterations){\n    if(p == 1){ // 1 isn't prime\n        return false;\n    }\n    for(int i=0;i<iterations;i++){\n        // choose a random integer between 1 and p-1 ( inclusive )\n        long long a = rand()%(p-1)+1; \n        // modulo is the function we developed above for modular exponentiation.\n        if(modulo(a,p-1,p) != 1){ \n            return false; /* p is definitely composite */\n        }\n    }\n    return true; /* p is probably prime */\n}\n</div>\nMore iterations of the function will result in higher accuracy, but will take more time. You can choose the number of iterations depending upon the application.\n\nThough Fermat is highly accurate in practice there are certain composite numbers p known as Carmichael numbers for which all values of a<p for which gcd(a,p)=1, (a(p-1))%p = 1. If we apply Fermat’s test on a Carmichael number the probability of choosing an a such that gcd(a,p) != 1 is very low ( based on the nature of Carmichael numbers ), and in that case, the Fermat’s test will return a wrong result with very high probability. Although Carmichael numbers are very rare ( there are about 250,000 of them less than 1016 ), but that by no way means that the result you get is always correct. Someone could easily challenge you if you were to use Fermat’s test :). Out of the Carmichael numbers less than 1016, about 95% of them are divisible by primes < 1000. This suggests that apart from applying Fermat’s test, you may also test the number for divisibility with small prime numbers and this will further reduce the probability of failing. However, there are other improved primality tests which don’t have this flaw as Fermat’s. We will discuss some of them now.\n\n### Miller-Rabin Primality Test\n\n**Key Ideas and Concepts**  \n\n1.  Fermat’s Little Theorem.\n2.  If p is prime and x2 = 1 ( mod p ), then x = +1 or -1 ( mod p ). We could prove this as follows:\n    <div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n    x2 = 1 ( mod p )\n    x2 \\- 1 = 0 ( mod p )\n    (x-1)(x+1) = 0 ( mod p )\n        </div>\n    \n\nNow if p does not divide both (x-1) and (x+1) and it divides their product, then it cannot be a prime, which is a contradiction. Hence, p will either divide (x-1) or it will divide (x+1), so x = +1 or -1 ( mod p ).\n\nLet us assume that p – 1 = 2d \\* s where s is odd and d >= 0. If p is prime, then either as = 1 ( mod p ) as in this case, repeated squaring from as will always yield 1, so (a(p-1))%p will be 1; or a(s*(2r)) = -1 ( mod p ) for some r such that 0 <= r < d, as repeated squaring from it will always yield 1 and finally a(p-1) = 1 ( mod p ). If none of these hold true, a(p-1) will not be 1 for any prime number a ( otherwise there will be a contradiction with fact #2 ).\n\n**Algorithm**  \nLet p be the given number which we have to test for primality. First we rewrite p-1 as (2d)*s. Now we pick some a in range \\[1,n-1\\] and then check whether as = 1 ( mod p ) or a(s*(2r)) = -1 ( mod p ). If both of them fail, then p is definitely composite. Otherwise p is probably prime. We can choose another a and repeat the same test. We can stop after some fixed number of iterations and claim that either p is definitely composite, or it is probably prime.\n\nA small procedure realizing the above algorithm is given below:\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* Miller-Rabin primality test, iteration signifies the accuracy of the test */\nbool Miller(long long p,int iteration){\n    if(p<2){\n        return false;\n    }\n    if(p!=2 && p%2==0){\n        return false;\n    }\n    long long s=p-1;\n    while(s%2==0){\n        s/=2;\n    }\n    for(int i=0;i<iteration;i++){\n        long long a=rand()%(p-1)+1,temp=s;\n        long long mod=modulo(a,temp,p);\n        while(temp!=p-1 && mod!=1 && mod!=p-1){\n            mod=mulmod(mod,mod,p);tion\n            temp *= 2;\n        }\n        if(mod!=p-1 && temp%2==0){\n            return false;\n        }\n    }\n    return true;\n}\n</div>\nIt can be shown that for any composite number p, at least (3/4) of the numbers less than p will witness p to be composite when chosen as ‘a’ in the above test. Which means that if we do 1 iteration, probability that a composite number is returned as prime is (1/4). With k iterations the probability of test failing is (1/4)k or 4(-k). This test is comparatively slower compared to Fermat’s test but it doesn’t break down for any specific composite numbers and 18-20 iterations is a quite good choice for most applications.\n\n### Solovay-Strassen Primality Test\n\n**Key Ideas and Concepts**\n\n1.  Legendre Symbol: This symbol is defined for a pair of integers a and p such that p is prime. It is denoted by (a/p) and calculated as:\n    <div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n          = 0    if a%p = 0\n    (a/p) = 1    if there exists an integer k such that k2 = a ( mod p )\n          = -1   otherwise.\n    \n    It is proved by Euler that:\n    \n    (a/p) = (a((p-1)/2)) % p\n    \n    So we can also say that:\n    \n    (ab/p) = (ab((p-1)/2)) % p = (a((p-1)/2))%p * (b((p-1)/2))%p = (a/p)*(b/p)\n       </div> \n    \n2.  Jacobian Symbol: This symbol is a generalization of Legendre Symbol as it does not require ‘p’ to be prime. Let a and n be two positive integers, and n = p1k1 \\* .. \\* pnkn, then Jacobian symbol is defined as:\n    <div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n    (a/n) = ((a/p1)k1) \\* ((a/p2)k2) \\* ..... \\* ((a/pn)kn)\n       </div> \n    \n    So you can see that if n is prime, the Jacobian symbol and Legendre symbol are equal.\n    1.  There are some properties of these symbols which we can exploit to quickly calculate them:\n    2.  (a/n) = 0 if gcd(a,n) != 1, Hence (0/n) = 0. This is because if gcd(a,n) != 1, then there must be some prime pi such that pi divides both a and n. In that case (a/pi) = 0 \\[ by definition of Legendre Symbol \\].\n    3.  (ab/n) = (a/n) * (b/n). It can be easily derived from the fact (ab/p) = (a/p)(b/p) ( here (a/p) is the Legendry Symbol ).\n    4.  if a is even, than (a/n) = (2/n)*((a/2)/n). It can be shown that:\n        <div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n              = 1 if n = 1 ( mod 8 ) or n = 7 ( mod 8 )\n        (2/n) = -1 if n = 3 ( mod 8 ) or n = 5 ( mod 8 )\n              = 0 otherwise\n       </div> \n    5.  (a/n) = (n/a)*(-1((a-1)(n-1)/4)) if a and n are both odd.\n\nThe algorithm for the test is really simple. We can pick up a random a and compute (a/n). If n is a prime then (a/n) should be equal to (a((n-1)/2))%n \\[ as proved by Euler \\]. If they are not equal then n is composite, and we can stop. Otherwise we can choose more random values for a and repeat the test. We can declare n to be probably prime after some iterations.\n\nNote that we are not interested in calculating Jacobi Symbol (a/n) if n is an even integer because we can trivially see that n isn’t prime, except 2 of course.\n\nLet us write a little code to compute Jacobian Symbol (a/n) and for the test:\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n//calculates Jacobian(a/n) n>0 and n is odd\nint calculateJacobian(long long a,long long n){\n    if(!a) return 0; // (0/n) = 0\n    int ans=1;\n    long long temp;\n    if(a<0){\n        a=-a;    // (a/n) = (-a/n)*(-1/n)\n        if(n%4==3) ans=-ans; // (-1/n) = -1 if n = 3 ( mod 4 ) \n    }\n    if(a==1) return ans; // (1/n) = 1\n    while(a){\n        if(a<0){\n            a=-a;    // (a/n) = (-a/n)*(-1/n)\n            if(n%4==3) ans=-ans;    // (-1/n) = -1 if n = 3 ( mod 4 )\n        }\n        while(a%2==0){\n            a=a/2;    // Property (iii)\n            if(n%8==3||n%8==5) ans=-ans;    \n        }\n        swap(a,n);    // Property (iv)\n        if(a%4==3 && n%4==3) ans=-ans; // Property (iv)\n        a=a%n; // because (a/p) = (a%p / p ) and a%pi = (a%n)%pi if n % pi = 0\n        if(a>n/2) a=a-n; \n    }\n    if(n==1) return ans;\n    return 0; \n}\n/\\* Iterations determine the accuracy of the test */\nbool Solovoy(long long p,int iteration){\n    if(p<2) return false;\n    if(p!=2 && p%2==0) return false;\n    for(int i=0;i<iteration;i++){\n        long long a=rand()%(p-1)+1;\n        long long jacobian=(p+calculateJacobian(a,p))%p;\n        long long mod=modulo(a,(p-1)/2,p);\n        if(!jacobian || mod!=jacobian){ \n            return false;\n        }\n    }\n    return true;\n}\n</div>\nIt is shown that for any composite n, at least half of the a will result in n being declared as composite according to Solovay-Strassen test. This shows that the probability of getting a wrong result after k iterations is (1/2)k. However, it is generally less preferred than Rabin-Miller test in practice because it gives poorer performance.\n\nThe various routines provided in the article can be highly optimized just by using bitwise operators instead of them. For example /= 2 can be replaced by “>>= 1″, “%2″ can be replaced by “&1″ and “*= 2″ can be replaced by “<<=1″. Inline Assembly can also be used to optimize them further.\n\n### Practice Problems\n\nProblems involving non-deterministic primality tests are not very suitable for the SRM format. But problems involving modular exponentiation and matrix exponentiation are common. Here are some of the problems where you can apply the methods studied above:\n\n[PowerDigit](http://community.topcoder.com/stat?c=problem_statement&pm=4515) ( TCO 06 Online Round 2 )  \n[MarbleMachine](http://community.topcoder.com/stat?c=problem_statement&pm=8045) ( SRM 376 )  \n[DrivingAround](http://community.topcoder.com/stat?c=problem_statement&pm=7412) ( SRM 342 )  \n[PON](http://www.spoj.pl/problems/PON/)  \n[PRIC](http://www.spoj.pl/problems/PRIC/)  \n[SOLSTRAS](http://www.spoj.pl/problems/SOLSTRAS/)  \n[DIVSUM2](http://www.spoj.pl/problems/DIVSUM2/) \\[ this one also involves Pollard's Rho Algorithm \\]\n\n### References and Further Reading\n\n[http://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf](http://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf)  \n[http://security.ece.orst.edu/papers/j37acmon.pdf](http://security.ece.orst.edu/papers/j37acmon.pdf)  \n[http://icpc.baylor.edu/Past/icpc2004/RegReport/guan.cse.nsysu.edu.tw/data/montg.pdf](http://icpc.baylor.edu/Past/icpc2004/RegReport/guan.cse.nsysu.edu.tw/data/montg.pdf)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3InO6045JOvUIUWF4NcVNz"}}],"upvotes":1,"downvotes":0}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2t7t392B1d0m9FS9gokGt","type":"Entry","createdAt":"2020-02-22T14:19:54.975Z","updatedAt":"2024-09-25T09:45:07.669Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":156,"revision":69,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Introduction to String Searching Algorithms","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"### Rabin-Karp and Knuth-Morris-Pratt Algorithms\n \n[Discuss the article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=516215)\n\nThe fundamental string searching (matching) problem is defined as follows: given two strings – a text and a pattern, determine whether the pattern appears in the text. The problem is also known as “the needle in a haystack problem.”\n\nThe “Naive” Method  \nIts idea is straightforward — for every position in the text, consider it a starting position of the pattern and see if you get a match.\n\n```\nfunction brute_force(text[], pattern[]) \n{\n  // let n be the size of the text and m the size of the\n  // pattern\n\n  for(i = 0; i < n; i++) {\n    for(j = 0; j < m && i + j < n; j++) \n      if(text[i + j] != pattern[j]) break;\n      // mismatch found, break the inner loop\n    if(j == m) // match found\n  }\n}\n```\n\nThe “naive” approach is easy to understand and implement but it can be too slow in some cases. If the length of the text is n and the length of the pattern m, in the worst case it may take as much as (n * m) iterations to complete the task.\n\nIt should be noted though, that for most practical purposes, which deal with texts based on human languages, this approach is much faster since the inner loop usually quickly finds a mismatch and breaks. A problem arises when we are faced with different kinds of “texts,” such as the genetic code.\n\nRabin-Karp Algorithm (RK)  \nThis is actually the “naive” approach augmented with a powerful programming technique – the hash function.\n\nEvery string s\\[\\] of length m can be seen as a number H written in a positional numeral system in base B (B >= size of the alphabet used in the string):\n\n**H = s\\[0\\] * B(m – 1) \\+ s\\[1\\] * B(m – 2) \\+ … \\+ s\\[m - 2\\] * B1 \\+ s\\[m - 1\\] * B0**\n\nIf we calculate the number H (the hash value) for the pattern and the same number for every substring of length m of the text than the inner loop of the “naive” method will disappear – instead of comparing two strings character by character we will have just to compare two integers.\n\nA problem arises when m and B are big enough and the number H becomes too large to fit into the standard integer types. To overcome this, instead of the number H itself we use its remainder when divided by some other number M. To get the remainder we do not have to calculate H. Applying the basic rules of modular arithmetic to the above expression:\n\n**A + B = C => (A % M + B % M) % M = C % M  \nA * B = C => ((A % M) * (B % M)) % M = C % M**\n\nWe get:\n\n**H % M = (((s\\[0\\] % M) * (B(m – 1) % M)) % M + ((s\\[1\\] % M) * (B(m – 2) % M)) % M +…  \n…\\+ ((s\\[m - 2\\] % M) * (B1 % M)) % M + ((s\\[m - 1\\] % M) * (B0 % M)) % M) % M**\n\nThe drawback of using remainders is that it may turn out that two different strings map to the same number (it is called a collision). This is less likely to happen if M is sufficiently large and B and M are prime numbers. Still this does not allow us to entirely skip the inner loop of the “naive” method. However, its usage is significantly limited. We have to compare the “candidate” substring of the text with the pattern character by character only when their hash values are equal.\n\nObviously the approach described so far would be absolutely useless if we were not able to calculate the hash value for every substring of length m in the text in just one pass through the entire text. At first glance to do these calculations we will again need two nested loops: an outer one – to iterate through all possible starting positions — and an inner one – to calculate the hash function for every starting position. Fortunately, this is not the case. Let’s consider a string s\\[\\], and let’s suppose we are to calculate the hash value for every substring in s\\[\\] with length say m = 3. It is easy to see that:\n\n**H0 = Hs\\[0\\]…s\\[2\\] = s\\[0\\] * B2 \\+ s\\[1\\] * B + s\\[2\\]**\n\n**H1 = Hs\\[1\\]..s\\[3\\] = s\\[1\\] * B2 \\+ s\\[2\\] * B + s\\[3\\]**\n\n**H1 = (H0 – s\\[0\\] * B2 ) \\* B + s\\[3\\]**\n\nIn general:\n\n**Hi = ( Hi – 1 – s\\[i- 1\\] * Bm - 1 ) \\* B + s\\[i + m - 1\\]**\n\nApplying again the rules of modular arithmetic, we get:\n\n**Hi % M = (((( Hi – 1 % M – ((s\\[i- 1\\] % M) * (Bm – 1 % M)) % M ) % M) * (B % M)) % M +  \n\\+ s\\[i + m - 1\\] % M) % M**\n\nObviously the value of (Hi – 1 – s\\[i - 1\\] * Bm - 1) may be negative. Again, the rules of modular arithmetic come into play:\n\n**A – B = C => (A % M – B % M + k * M) % M = C % M**\n\nSince the absolute value of (Hi – 1 – s\\[i - 1\\] * Bm - 1) is between 0 and (M – 1), we can safely use a value of 1 for k.\n\nPseudocode for RK follows:\n\n```\n// correctly calculates a mod b even if a < 0\nfunction int_mod(int a, int b)\n{\n  return (a % b + b) % b;\n}\n\nfunction Rabin_Karp(text[], pattern[])\n{\n  // let n be the size of the text, m the size of the\n  // pattern, B - the base of the numeral system,\n  // and M - a big enough prime number\n\n  if(n < m) return; // no match is possible\n\n  // calculate the hash value of the pattern\n  hp = 0;\n  for(i = 0; i < m; i++) \n    hp = int_mod(hp * B + pattern[i], M);\n\n  // calculate the hash value of the first segment \n  // of the text of length m\n  ht = 0;\n  for(i = 0; i < m; i++) \n    ht = int_mod(ht * B + text[i], M);\n\n  if(ht == hp) check character by character if the first\n               segment of the text matches the pattern;\n\n  // start the \"rolling hash\" - for every next character in\n  // the text calculate the hash value of the new segment\n  // of length m; E = (Bm-1) modulo M            \n  for(i = m; i < n; i++) {\n    ht = int_mod(ht - int_mod(text[i - m] * E, M), M);\n    ht = int_mod(ht * B, M);\n    ht = int_mod(ht + text[i], M);\n\n    if(ht == hp) check character by character if the\n                 current segment of the text matches\n                 the pattern; \n  }\n}\n\n```\n\nUnfortunately, there are still cases when we will have to run the entire inner loop of the “naive” method for every starting position in the text – for example, when searching for the pattern “aaa” in the string “aaaaaaaaaaaaaaaaaaaaaaaaa” — so in the worst case we will still need (n * m) iterations. How do we overcome this?\n\nLet’s go back to the basic idea of the method — to replace the string comparison character by character by a comparison of two integers. In order to keep those integers small enough we have to use modular arithmetic. This causes a “side effect” — the mapping between strings and integers ceases to be unique. So now whenever the two integers are equal we still have to “confirm” that the two strings are identical by running character-by-character comparison. It can become a kind of vicious circle…\n\nThe way to solve this problem is “rational gambling,” or the so called “double hash” technique. We “gamble” — whenever the hash values of two strings are equal, we assume that the strings are identical, and do not compare them character by character. To make the likelihood of a “mistake” negligibly small we compute for every string not one but two independent hash values based on different numbers B and M. If both are equal, we assume that the strings are identical. Sometimes even a “triple hash” is used, but this is rarely justifiable from a practical point of view.\n\nThe “pure” form of “the needle in a haystack problem” is considered too straightforward and is rarely seen in programming challenges. However, the “rolling hash” technique used in RK is an important weapon. It is especially useful in problems where we have to look at all substrings of fixed length of a given text. An example is “the longest common substring problem”: given two strings find the longest string that is a substring of both. In this case, the combination of binary search (BS) and “rolling hash” works quite well. The important point that allows us to use BS is the fact that if the given strings have a common substring of length n, they also have at least one common substring of any length m < n. And if the two strings do not have a common substring of length n they do not have a common substring of any length m > n. So all we need is to run a BS on the length of the string we are looking for. For every substring of the first string of the length fixed in the BS we insert it in a hash table using one hash value as an index and a second hash value (“double hash”) is inserted in the table. For every substring of the fixed length of the second string, we calculate the corresponding two hash values and check in the table to see if they have been already seen in the first string. A hash table based on open addressing is very suitable for this task.\n\nOf course in “real life” (real challenges) the number of the given strings may be greater than two, and the longest substring we are looking for should not necessarily be present in all the given strings. This does not change the general approach.\n\nAnother type of problems where the “rolling hash” technique is the key to the solution are those that ask us to find the most frequent substring of a fixed length in a given text. Since the length is already fixed we do not need any BS. We just use a hash table and keep track of the frequencies.\n\nKnuth-Morris-Pratt Algorithm (KMP)  \nIn some sense, the “naive” method and its extension RK reflect the standard approach of human logic to “the needle in a haystack problem”. The basic idea behind KMP is a bit different. Let’s suppose that we are able, after one pass through the text, to identify all positions where an existing match with the pattern ends. Obviously, this will solve our problem. Since we know the length of the pattern, we can easily identify the starting position of every match.\n\nIs this approach feasible? It turns out that it is, when we apply the concept of the automaton. We can think of an automaton as of a kind of abstract object, which can be in a finite number of states. At each step some information is presented to it. Depending on this information and its current state the automaton goes to a new state, uniquely determined by a set of internal rules. One of the states is considered as “final”. Every time we reach this “final” state we have found an end position of a match.\n\nThe automaton used in KMP is just an array of “pointers” (which represents the “internal rules”) and a separate “external” pointer to some index of that array (which represents the “current state”). When the next character from the text is presented to the automaton, the position of the “external” pointer changes according to the incoming character, the current position, and the set of “rules” contained in the array. Eventually a “final” state is reached and we can declare that we have found a match.\n\nThe general idea behind the automaton is relatively simple. Let us consider the string\n\n**A B A B A C**\n\nas a pattern, and let’s list all its prefixes:\n\n**0 /the empty string/  \n1 A  \n2 A B  \n3 A B A  \n4 A B A B  \n5 A B A B A  \n6 A B A B A C**\n\nLet us now consider for each such listed string (prefix) the longest proper suffix (a suffix different from the string itself), which is at the same time a prefix of it:\n\n**0 /the empty string/  \n1 /the empty string/  \n2 /the empty string/  \n3 A  \n4 A B  \n5 A B A  \n6 /the empty string/**\n\nIt’s easy to see that if we have at some point a partial match up to say the prefix (A B A B A) we also have a partial match up to the prefixes (A B A), and (A) – which are both prefixes of the initial string and suffix/prefixes of the current match. Depending on the next “incoming” character from the text, three cases arise:\n\n1.  The next character is C. We can “expand” the match at the level of the prefix (A B A B A). In this particular case this leads to a full match and we just notice this fact.\n2.  The next character is B. The partial match for the prefix (A B A B A) cannot be “expanded”. The best we can do is to return to the largest different partial match we have so far – the prefix (A B A) and try to “expand” it. Now B “fits” so we continue with the next character from the text and our current “best” partial match will become the string (A B A B) from our “list of prefixes”.\n3.  The “incoming” character is, for example, D. The “journey” back to (A B A) is obviously insufficient to “expand” the match. In this case we have to go further back to the second largest partial match (the second largest proper suffix of the initial match that is at the same time a prefix of it) – that is (A) and finally to the empty string (the third largest proper suffix in our case). Since it turns out that there is no way to “expand” even the empty string using the character D, we skip D and go to the next character from the text. But now our “best” partial match so far will be the empty string.\n\nIn order to build the KMP automaton (or the so called KMP “failure function”) we have to initialize an integer array F\\[\\]. The indexes (from 0 to m – the length of the pattern) represent the numbers under which the consecutive prefixes of the pattern are listed in our “list of prefixes” above. Under each index is a “pointer” – that identifies the index of the longest proper suffix, which is at the same time a prefix of the given string (or in other words F\\[i\\] is the index of next best partial match for the string under index i). In our case (the string A B A B A C) the array F\\[\\] will look as follows:\n\n**F\\[0\\] = 0  \nF\\[1\\] = 0  \nF\\[2\\] = 0  \nF\\[3\\] = 1  \nF\\[4\\] = 2  \nF\\[5\\] = 3  \nF\\[6\\] = 0**\n\nNotice that after initialization F\\[i\\] contains information not only about the largest next partial match for the string under index i but also about every partial match of it. F\\[i\\] is the first best partial match, F\\[F\\[i\\]\\] – is the second best, F\\[F\\[F\\[i\\]\\]\\] – the third, and so on. Using this information we can calculate F\\[i\\] if we know the values F\\[k\\] for all k < i. The best next partial match of string i will be the largest partial match of string i – 1 whose character that “expands” it is equal to the last character of string i. So all we need to do is to check every partial match of string i – 1 in descending order of length and see if the last character of string i “expands” the match at this level. If no partial match can be “expanded” than F\\[i\\] is the empty string. Otherwise F\\[i\\] is the largest “expanded” partial match (after its “expansion”).\n\nIn terms of pseudocode the initialization of the array F\\[\\] (the “failure function”) may look like this:\n\n```\n// Pay attention! \n// the prefix under index i in the table above is \n// is the string from pattern[0] to pattern[i - 1] \n// inclusive, so the last character of the string under \n// index i is pattern[i - 1]   \n\nfunction build_failure_function(pattern[])\n{\n  // let m be the length of the pattern \n\n  F[0] = F[1] = 0; // always true\n  \n  for(i = 2; i <= m; i++) {\n    // j is the index of the largest next partial match \n    // (the largest suffix/prefix) of the string under  \n    // index i - 1\n    j = F[i - 1];\n    for( ; ; ) {\n      // check to see if the last character of string i - \n      // - pattern[i - 1] \"expands\" the current \"candidate\"\n      // best partial match - the prefix under index j\n      if(pattern[j] == pattern[i - 1]) { \n        F[i] = j + 1; break; \n      }\n      // if we cannot \"expand\" even the empty string\n      if(j == 0) { F[i] = 0; break; }\n      // else go to the next best \"candidate\" partial match\n      j = F[j];\n    }\n  }   \n}\n```\n\nThe automaton consists of the initialized array F\\[\\] (“internal rules”) and a pointer to the index of the prefix of the pattern that is the best (largest) partial match that ends at the current position in the text (“current state”). The use of the automaton is almost identical to what we did in order to build the “failure function”. We take the next character from the text and try to “expand” the current partial match. If we fail, we go to the next best partial match of the current partial match and so on. According to the index where this procedure leads us, the “current state” of the automaton is changed. If we are unable to “expand” even the empty string we just skip this character, go to the next one in the text, and the “current state” becomes zero.\n\n```\nfunction Knuth_Morris_Pratt(text[], pattern[])\n{\n  // let n be the size of the text, m the \n  // size of the pattern, and F[] - the\n  // \"failure function\"\n\n  build_failure_function(pattern[]); \n\n  i = 0; // the initial state of the automaton is\n         // the empty string\n\n  j = 0; // the first character of the text\n  \n  for( ; ; ) {\n    if(j == n) break; // we reached the end of the text\n\n    // if the current character of the text \"expands\" the\n    // current match \n    if(text[j] == pattern[i]) {\n      i++; // change the state of the automaton\n      j++; // get the next character from the text\n      if(i == m) // match found\n    }\n\n    // if the current state is not zero (we have not\n    // reached the empty string yet) we try to\n    // \"expand\" the next best (largest) match\n    else if(i > 0) i = F[i];\n\n    // if we reached the empty string and failed to\n    // \"expand\" even it; we go to the next \n    // character from the text, the state of the\n    // automaton remains zero\n    else j++;\n  }\n}\n```\n\nMany problems in programming challenges focus more on the properties of KMP’s “failure function,” rather than on its use for string matching. An example is: given a string (a quite long one), find all its proper suffixes that are also prefixes of it. All we have to do is just to calculate the “failure function” of the given string and using the information stored in it to print the answer.\n\nA typical problem seen quite often is: given a string find its shortest substring, such that the concatenation of one or more copies of it results in the original string. Again the problem can be reduced to the properties of the failure function. Let’s consider the string\n\n**A B A B A B**\n\nand all its proper suffix/prefixes in descending order:\n\n**1 A B A B  \n2 A B  \n3 /the empty string/**\n\nEvery such suffix/prefix uniquely defines a string, which after being “inserted” in front of the given suffix/prefix gives the initial string. In our case:\n\n**1 A B  \n2 A B A B  \n3 A B A B A B**\n\nEvery such “augmenting” string is a potential “candidate” for a string, the concatenation of several copies of which results in the initial string. This follows from the fact that it is not only a prefix of the initial string but also a prefix of the suffix/prefix it “augments”. But that means that now the suffix/prefix contains at least two copies of the “augmenting” string as a prefix (since it’s also a prefix of the initial string) and so on. Of course if the suffix/prefix under question is long enough. In other words, the length of a successful “candidate” must divide with no remainder the length of the initial string.\n\nSo all we have to do in order to solve the given problem is to iterate through all proper suffixes/prefixes of the initial string in descending order. This is just what the “failure function” is designed for. We iterate until we find an “augmenting” string of the desired length (its length divides with no remainder the length of the initial string) or get to the empty string, in which case the “augmenting” string that meets the above requirement will be the initial string itself.\n\nRabin-Karp and Knuth-Morris-Pratt at TopCoder  \nIn the problem types mentioned above, we are dealing with relatively “pure” forms of RK, KMP and the techniques that are the essence of these algorithms. While you’re unlikely to encounter these pure situations in a TopCoder SRM, the drive towards ever more challenging TopCoder problems can lead to situations where these algorithms appear as one level in complex, “multilayer” problems. The specific input size limitations favor this trend, since we will not be presented as input with multimillion character strings, but rather with a “generator”, which may be by itself algorithmic in nature. A good example is “[InfiniteSoup](http://community.topcoder.com/stat?c=problem_statement&pm=6017&rd=8083),” Division 1 – Level Three, SRM 286.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7LceTr6NvYiCX81vrsy31I","type":"Entry","createdAt":"2020-02-22T14:18:54.241Z","updatedAt":"2020-02-22T14:18:54.241Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"TheLlama"}}],"upvotes":23,"downvotes":7}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"aiNgKJ0eML1w5qUl2oa79","type":"Entry","createdAt":"2021-08-23T10:03:14.050Z","updatedAt":"2024-09-22T14:45:37.293Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":463,"revision":131,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"All about Topcoder Challenges, Tasks and Gig Work Opportunities","slug":"all-about-topcoder-challenges-tasks-and-gig-work-opportunities","type":"Video","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}}],"tags":["Help Article","Community","FAQs"],"creationDate":"2021-08-23","readTime":"13min","content":"\n- <AnchorLink href=\"#1\">What is a Topcoder Challenge?</AnchorLink>\n- <AnchorLink href=\"#2\">What is an SRM (Algorithm Challenge)</AnchorLink>\n- <AnchorLink href=\"#3\">What is a Development Challenge</AnchorLink>\n  - <AnchorLink href=\"#4\">What are RDMs</AnchorLink>\n  - <AnchorLink href=\"#12\">What are Skill Builder Competitions</AnchorLink>\n- <AnchorLink href=\"#41\">What is a First2Finish challenge</AnchorLink>\n- <AnchorLink href=\"#5\">What is a Design Challenge</AnchorLink>\n  - <AnchorLink href=\"#6\">What is LUX/RUX</AnchorLink>\n- <AnchorLink href=\"#7\">What is a QA challenge</AnchorLink>\n- <AnchorLink href=\"#8\">What is a Data Science Challenge</AnchorLink>\n  - <AnchorLink href=\"#9\">What is a Marathon Match</AnchorLink>\n- <AnchorLink href=\"#10\">What is Gig Work</AnchorLink>\n- <AnchorLink href=\"#11\">What is a Task</AnchorLink>\n<a id=\"1\"></a>\n### What is a Topcoder Challenge?\n\nTopcoder is a competition-based community at its heart. Let's go through the main kinds of challenges available at Topcoder. The common features of each challenge type are a strict timeline consisting of multiple phases and a score-based ranking system for competitors, based on their competition history.\n\n<a id=\"2\"></a>\n#### What is an SRM (Algorithm Challenge)\n\nSingle-round matches (SRM) are the oldest kind of challenge available at Topcoder. They are algorithm competitions, usually consisting of three problems (easy, medium and hard), that are solved by the contestants in a short time (often 75 minutes). A Rookie SRM is a variant of these competitions aimed at newer members. They have the exact same match structure, but the problems are easier and more approachable to people with less experience in algorithm competitions.\n\nA contest consists of a \n\n- **Registration Phase** - 24 Hours\n- **Coding Phase** - 75 mins\n- **Intermission Phase** - 5 mins\n- **Challenge Phase** \\- 15 mins\n- **System Tests**, which conclude the round. \n\nThe coding phase is the problem-solving part, during which the contestants write their code to solve the given problems. Competitors are divided into \"rooms\", consisting of twenty competitors each. \n\nDuring the challenge phase, the participants are given access to the code submitted by other competitors in the same room, and have the chance to \"challenge\" this code. A challenge consists of finding a test case for which the submitted code fails or gives a wrong answer. A successful challenge removes all preliminary points from that submission and grants the successful challenger +50 points. A failed challenge costs 25 points.\n\nAfter the challenge phase the system test phase begins, during which every submission is thoroughly tested for correctness. Failed submissions lose their score for that problem. Soon after the system test phase is finished ratings are updated.\n\nSee:\n\n[How to compete in SRMs](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20SRMs)\n\n[General Topcoder Arena Usage Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions)\n\n[How to compete in SRMs:Extras and FAQs](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20SRMs:%20Extras%20and%20FAQs)\n\n<a id=\"3\"></a>\n#### What is a Development Challenge\n\nDevelopment challenges usually run between a few days or one to two weeks. The task is usually to complete a piece of functionality in a software product or to create one from scratch.\n\nDevelopment Track at Topcoder consists of three types of challenges: \n\n-   First2Finish (F2F) challenges - First2Finish are quick challenges in which competitors are asked to fix bugs or do a small task. The challenge is open until the project manager or copilot running the challenge has a winning submission.\n\n-   Code Challenges - Code challenges ask you to develop code for apps, services, etc. Final fixes, which are sometimes required after a typical challenge, are not included in these types of challenges.  \n\n-   Ideation challenges - Ideation Challenges ask you to research and ideate a solution on the problem statement presented to you. \n\nThe most popular challenge type in the development track is the code challenge. The technologies are varied, ranging from AngularJS, Node.js, Java, iOS, Android, Python, and several others. \n\nIn a code challenge, you will develop code for apps, services, etc. You must ensure your submission addresses all the requirements mentioned in the challenge specification. You also need to ensure your code is modularized, clean and well documented, and you need to provide clean documentation for deployment and verification.\n\nSee: \n\n[How to compete in Development Challenges?](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20In%20Development)\n\n<a id=\"4\"></a>\n##### What are RDMs\n\nRapid development matches (RDMs) are quick, fast-paced ranked development challenges, where you have to develop an application strictly according to specification. Speed is of importance since the matches are rated. They usually last for one hour. They represent a great way to test and to improve your development skills. An RDM is structured similarly to an SRM algorithm match, there are three problems: easy, medium and hard. The competitors' submissions will be tested against an automatic tester that can provide instant feedback on the submissions.\n\nSee:\n\n[RDMs](https://www.topcoder.com/thrive/articles/rdm-competition-faqs-and-rules)\n\n<a id=\"12\"></a>\n##### What are Skill Builder Competitions\nSkill Builders Competitions are competitions meant to help you build proficiency in a certain technology or product. A Topcoder Skill Builder challenge consists of three consecutive problems: Easy, Medium and Hard. Each problem is usually related, such that they build on each other. There will be a separate leaderboard for a Skill Builder challenge that keeps track of points across all three problems. A Skill Builder challenge usually runs for an extended period of time, such as a month. During the first run of a challenge, there are usually prizes and swag as well, these are generally given to the first submissions that pass review. Skill Builder challenges are ranked, and grant verified skill badges for your Topcoder profile.\n\nSee:\n\n[Topcoder Skill Builder Competitions](https://www.topcoder.com/thrive/articles/topcoder-skill-builder-competitions)\n\n<a id=\"41\"></a>\n#### What is a First2Finish challenge\nA F2F (First2Finish) match is a kind of development or design challenge where, as the name implies, the winner is determined as the competitor with the first submission to pass the minimum requirements for the challenge. Due to the nature of the challenge, review is performed during the Submission Phase of the match as the submissions keep coming it. Once a passing submission is found, the winner is determined and the match ends. These challenges are usually reasonably small in scale, such as bug fixes or configuration work. Speed is of the essence here, so keep your eyes peeled on that [Challenge listing](https://www.topcoder.com/challenges?tracks[Dev]=true&types[]=F2F)!\n\n<a id=\"5\"></a>\n#### What is a Design Challenge\n\nTopcoder Design Challenges provide coverage for a full range of design needs, from responsive and mobile application user experience to marketing collateral creation and support. To be specific, there are seven types of design challenges that we offer in the Design track.\n\n-   Application Front End Design\n-   Web Design\n-   Widget or Mobile Screen Design\n-   Wireframes\n-   Print/Presentation\n-   Design First2Finish\n-   Idea Generation\n\nYou must ensure your design submission addresses all the requirements mentioned in the challenge specification, and ensure your design follows the best practice for the specific interface or devices. \n\nSee: \n\n[How to compete in Design Challenges?](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20Design)\n\n<a id=\"6\"></a>\n##### What is LUX/RUX\n\nThe Live User Experience (LUX) is a fast challenge that runs for 48 hours and has a number of big prizes. The LUX challenge takes place during a live event with Topcoder and a customer. The Rapid User Experience (RUX) is similar to a LUX but it runs for 72 hours and awards 5 big prizes. Both challenges run fast and are only a one round challenge.\n\nLUX & RUX challenges provide designers with the opportunity to show digital leaders from some of the largest companies in the world, just how good they are at creating concepts, User Experience (UX) Design, and User Interface (UI) Design. They are fast, fun, and designers have more chances to earn prize money! We even have leaderboards for these!\n\nSee:\n\n[A guide for creating Topcoder LUX RUX presentations](https://www.topcoder.com/blog/a-guide-for-creating-topcoder-lux-rux-presentations/)\n\n<a id=\"7\"></a>\n#### What is a QA challenge\n\nQuality assurance (QA) track competitions call for competitors to participate in organized QA testing of a piece of software. Technical background is not necessarily required, but experience plays an important part in gaining a good score and rating. \n\nThe QA Track, consists of four types of challenges: \n\n-   Unstructured Testing: In these types of challenges you are asked to test without predefined test cases, also known as Bug Hunt.\n\n-   Structured Testing: In these types of challenges you are asked to execute predefined test cases step by step and check if test results are correct\n\n-   Structured Test Case Writing: In these types of challenges you are asked to write test cases based on prototypes and functional requirement specifications.\n\n-   Automated Testing: In these types of challenges you are asked to use automation tools to execute test cases.\n\nThe most popular challenge type in the QA track is Bug Hunt. Here you are asked to report bugs including the steps to reproduce and the type of bug you found. While competing with others, you are paid for each verified bug and can also receive extra prize money for finding the most number of bugs. \n\nSee:\n\n[What is QA?](https://www.topcoder.com/thrive/articles/What%20is%20QA)\n\n[How to Compete in Testing Competitions](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20Testing%20Competitions)\n\n[What is a Bug Hunt?](https://www.topcoder.com/thrive/articles/What%20is%20a%20Bug%20Hunt)\n\n[How To Compete in a Bug Hunt Challenge](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20a%20Bug%20Hunt%20Challenge)\n\n<a id=\"8\"></a>\n#### What is a Data Science Challenge\n\nA data science challenge is a special kind of challenge for problems related to machine learning, data science, mathematics and statistics. They are typically longer in duration, usually at least a week, and often up to a month or more. The contestants are tasked with developing a data science solution that matches the given problem area and data as closely as possible. Some example cases might be the development of an image classification model, or to forecast data based on historical data points.\n\nSee:\n\n[Data Science Challenge Types](https://www.topcoder.com/thrive/articles/Data-Science-Challenge-Types)\n\n[Practical Skills Needed to Win Data Science Competitions](https://www.topcoder.com/thrive/articles/Practical%20Skills%20Needed%20to%20Win%20Data%20Science%20Competitions)\n\n<a id=\"9\"></a>\n##### What is a Marathon Match\n\nA marathon match is another old competition type at Topcoder. Marathon Matches are challenges where your submission is automatically scored according to the scoring details mentioned in the match specification.\n\nThey are longer than SRM matches, usually lasting one week. They consist of one difficult problem that may not have a single correct solution, but rather something where optimization must be used to create a solution that performs better than the competition. A problem may consist of a board game simulation that must be solved as efficiently as possible, or a machine learning-related task, such as classification.\n\nThese matches are mainly divided into two categories: \n\n-   **Algorithm Optimization Matches** \\- These matches are hosted by Topcoder for practice and fun. The problems are usually NP-Hard, so no optimal solution is known. The matches usually run for one week, in which you write a program to score as well as possible against the problem's scoring system. They are generally named as Marathon Match followed by a sequence number. Example: [Marathon Match 118](https://www.topcoder.com/challenges/70402b3e-fb5b-4d3d-9277-20c1fa512806)\n\n-   **Machine Learning / Data Analytics / Image Processing / Predictive Analytics etc** - These matches are designed with the help of our customers. They involve tasks with real-world applications and datasets. Example: [CDC Text Classification - Marathon Match](https://www.topcoder.com/challenges/30103825)\n\nSee:\n\n[How to compete in a Marathon Match](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20a%20Marathon%20Match)\n\n[Curated Marathon Matches Guide](https://www.topcoder.com/blog/complete-guide-topcoder-marathon-matches-curated-just/)\n\n<a id=\"10\"></a>\n### What is Gig Work\n\nGig work is the latest addition to the numerous ways you can challenge yourself and earn money on Topcoder. Gig work is contract work for a fixed duration in a specific role for a client. You can apply to these freelance positions from the gig work page LINK, and if your skills are a match for the role, you will be contacted for an interview. Gig work provides you a way to earn a safe, fixed income for a duration. Gigs usually last at least one month and often longer. Your Topcoder profile will be valuable in proving your skills for a successful gig application.\n\nSee: \n\n[Gig Work at Topcoder](https://www.topcoder.com/thrive/articles/gig-work-at-topcoder)\n\n<a id=\"11\"></a>\n### What is a Task\n\nA private task is a special challenge given to only a single person. This person is usually the winner of a competition or a series of competitions. Through the task, they are given a special appointment to add extra features or to do some other extra work related to the challenges they've done. A task may also be unrelated to a specific challenge, but still target a highly qualified member with the right skills for it. To gain tasks, you should compete and place highly in competitions, and also be active on Slack, where new tasks are often posted.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3g1nKR4UqmmAfvEfYXCIjB","type":"Entry","createdAt":"2021-06-30T05:59:50.778Z","updatedAt":"2021-08-23T13:07:02.867Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Pentti Sunila","tcHandle":"pena","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"upvotes":41,"downvotes":2}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fExfNMgkaAN9f6RE1lI5W","type":"Entry","createdAt":"2021-02-23T22:29:23.663Z","updatedAt":"2024-09-16T13:15:23.337Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":126,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Gig Work at Topcoder and FAQs","slug":"gig-work-at-topcoder","type":"Article","trackCategory":["Gig Work"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4NginLfmkkwHs5ZSGXI9Qt","type":"Entry","createdAt":"2020-09-07T12:17:11.233Z","updatedAt":"2020-09-07T12:17:11.233Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Gig Work"}}],"tags":["Gig Work"],"creationDate":"2021-02-23","readTime":"15min","content":"Gig Work at Topcoder is part of our “Talent as a Service” or TaaS offering. In cases where it makes more sense for the customer to work with defined resources rather than strictly with challenges. It is much closer to a traditional freelancing model where you and the customer work directly together instead of working through challenges. You can also say a Topcoder gig is a freelance contractor position.\n\n#### How do I get started?\n\nCompete and build up your profiles and skills! Topcoder members become eligible to work on Gig Work projects by first proving themselves in various skillsets through Topcoder competitions. Keep learning and competing to earn statistics on your Topcoder profile page that demonstrates your expertise. Once you become [rated](https://www.topcoder.com/thrive/articles/Ratings) and/or show success by either winning challenges or successfully passing review in any competition track, you are eligible to participate in Gig Work engagements. If you do not have a competition history at Topcoder, that is okay.\n\n#### Once I compete enough to become eligible, then what?\n\nBy having an in-depth profile that shows expertise in at least one area, you will be moved higher in the list as we match Gig Work members to customer requests. Our platform scans our community looking for the top members for various in-demand skill sets.If you’re competing in a track that is currently not rated (like Design), we’ll instead look at other statistics we track such as # of wins, # of passed reviews, etc.\n\n#### What type of talent are we looking for?\n\nOur customers have a broad array of needs they are looking to fill.\n\nHere are a few skills we are always looking for:\n\n-   Full Stack Developers\n\n-   Front End Developers\n\n-   Back End Developers\n\n-   Designers\n\n-   Data Engineers\n\n-   Data Scientists\n\n-   DevOps Engineers with AWS, Azure, GCP\n\n#### What should I do right now if I’m interested in Gig Work?\n\nRight now, just some basics.\n\n1.  As a part of our Topcoder community, if you are interested in working on freelancer style work with different customers and projects, visit our Gig work page and [sign up for a weekly email](https://www.topcoder.com/community/gig-subscribe). While you are doing that, take a look at our open Gigs to see if something fits your talent and experience.  \n\n2.  Make sure your [complete Topcoder profile](https://profiles.topcoder.com/) is filled out. The more complete it is, the more likely it will be that you are identified for opportunities. At a minimum, you must have the following completed on your profile:\n\n-   First/Last Name\n\n-   Address\n\n-   Birthdate\n\n-   Payment Preferences\n\n-   Bio\n\n-   Current Location\n\n-   Primary Interests\n\n-   Tracks\n\n-   Languages\n\n-   Education\n\n-   Work\n\n-   Skills\n\n-   Hobbies\n\n-   Tools\n\nFavorite Projects: Tell us what your favorite 2 or 3 projects have been that you worked on.\n\nBio: Write a quick bio that personifies you. Feel free to make it fun and show your personality, but also make sure it’s professional. This is visible to customers as they are reviewing candidates for their gig work so you want to put your best foot forward.\n\nComplete your identity verification. Instructions will be sent to you after you sign up for Topcoder gigs.\n\n#### What is the onboarding process?\n\nThis process can vary depending on the customer; however, here is a general rundown of the process once you accept a Gig Work offer:\n\n-   Offer Accepted\n\n-   Topcoder will notify our client team that the offer is accepted.\n\n-   You will receive an email from our Customer Success Team to schedule a kickoff call with the customer.\n\n-   Clients will reach out to begin company-specific onboarding (Two weeks or more).  Could include:\n\n-   Laptop\n\n-   Network Credentials and access\n\n-   Background Check (On an “As needed basis based on the client)\n\n#### Will there be training?\n\nEach client is different based on the task needed to be done. Our client and Topcoder will always be available to support you in this process.  \n\nHowever, you were selected for the skills you already possess, and the expectation is that you will be able to complete the work that you are already skilled in.\n\n#### Would I get health insurance?\n\nYou would not be provided an insurance plan when you are working on a Gig, and you would need to seek your own private insurance.\n\n#### Do we have any clients that would be interested in offering internships?\n\nNot at this time. But we recommend students spend time with Topcoder challenges to help build their resume.\n\n#### How do I get paid?\n\nYou will be paid weekly, per your offer letter from Topcoder. We have a link to more specifics on how to set that up. [Information on How do I get paid](https://www.topcoder.com/thrive/tracks?track=Topcoder&tax=Getting%20Paid).\n\n#### What support do you give your candidates while they are working in a Gig?\n\nTopcoder is a community and we always want to make sure that you feel you are a valued member of the community. We are always here to help and assist and point you in the direction of where to get your answer.\n\nWe have [Topcoder forums](http://discussions.topcoder.com), [other ways to contact us](https://www.topcoder.com/community/contact), [weekly community chats](https://us02web.zoom.us/meeting/register/tZMsdO-rrDMiHNPnEbEksD-259GbzAuTbid7) on Mondays, a [Topcoder Nation Facebook group](https://www.facebook.com/groups/topcoder.nation), and so much more! Our community team is always here to help you so please take advantage of that and all the networking opportunities we have.\n\n#### What is expected of me?\n\nAs a member of Topcoder, you will need to decide if you are willing to make the commitment to a given project and/or customer depending on how the opportunity is outlined. If you are not able to accept an assignment, there is no obligation. However, if you do accept an assignment, it is expected that you adhere to the requirements of the assignment. Most gigs will require full time hours for a certain amount of weeks. Some gigs will also require certain time zone restrictions to be adhered to.\n\n#### What do I do if I am having technical issues and need help?\n\nIf there are any technical issues that are specific to client systems, software, hardware, your client-side manager or handler is your point of contact.  If you are having trouble understanding who your point of contact is, please consult your Customer Success Manager.  \n\n#### Do I have to interact directly with the customer?\n\nYou should expect to have direct interaction with the client on these projects. In some rare cases, you may become part of an existing project team that is a blend of Topcoder members and other resources. We feel that the members that are able to present themselves well, communicate consistently and often, and are willing to participate in client meetings/standups/etc will have the most impact on these opportunities. Since every customer is different, forms of communication and collaboration will also vary.\n\nIt’s also important to note that professionalism while on a Topcoder gig really matters. Please be sure to follow proper business etiquette as you are representing Topcoder and yourself. If you are ever unsure of something, we are happy to help. Please email the gig work team at gigwork@topcoder.com.\n\n#### Why do we have gig work for members?\n\nGig Work becomes more relevant in situations where public challenges are not ideal. For example, when certain work requires developers to gain access to client environments or when the customer prefers to work in more of a one on one situation with a resource. Also, some work may be more efficient to complete in a collaborative manner rather than in a competition style. In these cases, having a group of skilled members working together with the customer’s team may be more practical.\n\n#### Are you obligated to participate in a Gig Work opportunity you are offered?\n\nNo. Even if you are in a pool, you are still a community member, not an employee so you can participate in other work at the same time. \n\nHowever, some things to consider:\n\n-   In some of these engagements, we may invest in background checks or other types of certifications. Please consider the level of commitment before signing up, or just do not sign up if you feel you do not have the skill or the time to do work. Keep in mind that many of these assignments will most likely be full-time work.\n\n-   Please consider your reputation as a community member if you pre-committed to any type of work. Informing those in charge that you will not be able to compete is better than walking away without telling anyone.\n\n-   Your performance on assignments will be tracked and will become part of your Topcoder profile. Therefore, it’s important to maintain a high level of professionalism and quality of work in order to gain more opportunities in the future.\n\n#### Why are there Identity checks and NDA’s?\n\nYou will likely be given access to the client’s secure environment for some of the gig related projects. Since this privilege is usually meant for cleared employees/contractors, any Topcoder member doing similar work will likely have to undergo an identity check and/or background check to ensure they are cleared to enter the client’s environment. Depending on the client, this can potentially be non-negotiable.\n\n#### Will I still be participating in Topcoder Challenges to do the work?\n\nNo. For these engagements, you will be assigned work directly by a customer resource.\n\n#### Can I still compete in regular Topcoder challenges if I’m doing a gig?\n\nSure! As long as it doesn’t interfere with your gig engagement we encourage all members to continue competing.\n\n#### How do I know if the customer is satisfied with me?\n\nFirst, just ask! Topcoder also performs regular outreach to customers to gain a measurement of customer satisfaction.\n\n#### What happens if the customer is disputing the work I’m delivering?\n\nIf the customer is unhappy with your work, you should first discuss it with the customer and try to find a solution. If you are unable to find a solution, contact the Success Manager that helped you with onboarding at the start of the gig. Be sure to include a full description and as many details as possible of the issue along with any supporting evidence.\n\n#### Are their criteria for being removed from an engagement?\n\nTopcoder prides itself on being fair, especially when it comes to our community. So, removing a member from an engagement would not be done without merit.  \n\nMembers may be removed for various reasons. Some of these reasons include:\n\n-   The member is no longer able to commit the agreed amount of time to the project.\n\n-   The customer is not satisfied with the work the member is delivering.\n\n-   Sometimes it’s just not a good fit. It happens.\n\n-   Client requirements have changed and the work is no longer required\n\n#### Will Copilots be involved in Gigs?\n\nNo. At this time, copilots will not be used to manage work with the Topcoder Community on gig projects. If you are a copilot and would like to work on a gig assignment, you may still do so but it would be in a non-copilot role.\n\n#### How does Payment work?\n\nOnce you receive your offer letter, you will be given instructions on how to set up payment with Topcoder.  Topcoder only uses three payment providers (Paypal, Payoneer, Western Union).  \n\nYou will be paid a fixed amount per week based on the role, your Topcoder merit-based accomplishments (i.e. [Ratings](https://www.topcoder.com/thrive/articles/Ratings), # of wins, etc.), your work experience, and the listed payment range on the Job Listing. **Note** - We are very transparent with our rates in the job listing.  If you are not comfortable with the payment range listed, do not apply for this position, as we will not negotiate above the maximum amount of a specific job listing.\n\nTopcoder pays gig workers weekly. Payments for a given week are entered into your Topcoder wallet by Tuesday of the following week. **Once payments are entered, they become available to withdraw after a 15 day hold period**.  The 15 day hold period is for some backend processing we have to go through to clear payments.  We are looking to lower this time in the future, but currently, it will stay at 15 days.  \n\nYou may see a pro-rated payment for your first and last gig payment, as well as potential days you may take leave.  For example, If you started work on a Friday, you would only get paid for ⅕ of the amount of your weekly payment, for that specific week.  \n\nBe sure your Success Manager is aware of your start date and be sure **not** to conduct any actual work unless you have confirmation that billing has commenced.\n\n#### What if I work a lot more than the expected time on an engagement?\n\nMany projects experience weeks that are busier than normal and some that are slower than normal. We set the expectation with customers that these busy and slow times should balance out over the course of the project. We also track this through a survey we send you each week. There are a few things you can do if you believe you are working more than expected.\n\n1.  Complete the survey every week. It’s a simple 2 question survey so it won’t take much time. We monitor your responses and will contact you if you are consistently reporting working more than expected.\n\n2.  Discuss timelines and scope of work with the customer to come to an understanding. \n\n3.  Contact your Success Manager if you’re not able to find a solution with the customer. Be sure to provide as much information as you can about the situation.\n\n4.  Again - complete the survey every week. Your Success Manager will be able to support you much better if you have completed the surveys consistently. \n\n#### What if I am no longer able to work on an assignment?\n\nWe understand this will happen sometimes.\n\n1.  Try to avoid the situation by understanding how your schedule matches with the customer’s schedule.  \n\n2.  Alert your Success Manager and your customer as soon as possible.  \n\n3.  We require a minimum of 1-week notice if you need to leave an assignment, but we highly recommend providing at least 2 weeks’ notice.\n\n#### Do I need to go onsite with a customer?\n\nWe’re currently not supporting onsite resources in Topcoder gigs. All work is done virtually.\n\n#### Will I still get paid if I finish the gig early?\n\nYou will get paid for the work that you complete, when a gig closes early you will be paid for the work that you do\n\n#### What is the timeline and application process for getting a gig?\n\nGig’s timeline from application to finding out if you got the Gig is about 2 weeks. This can be longer depending on the client, the project, and how many candidates are needed for the Gig. The process with be roughly as follows:\n\n1.  Apply for the Gig.\n\n2.  A Team member will review our application 24-48 hours after you submit it. We will review skills, professional experience, as well as Topcoder experience. If you are a match based on the job description you will be asked to set up a phone screen with a Gig Work Team member. \n\n3.  During your phone screen, you will be asked to verify your identity, location, availability, and that you have the skills listed in the job description. \n\n4.  We will then be sending your resume off to the client to evaluate if you’re a match for the specific project they are looking for work on. \n\n5.  If a match, Topcoder or the client will be asked to set up an interview with them. \n\n6.  If the interview is a success you will be given an offer via email.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3TdAZLeLjjtJvf5Sux7sAx","type":"Asset","createdAt":"2020-01-23T08:33:47.104Z","updatedAt":"2020-01-23T08:33:47.104Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"photo-of-people-leaning-on-wooden-table-3183183","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3TdAZLeLjjtJvf5Sux7sAx/15435a836e6edea36635eee03e242034/photo-of-people-leaning-on-wooden-table-3183183.jpg","details":{"size":251590,"image":{"width":1280,"height":854}},"fileName":"photo-of-people-leaning-on-wooden-table-3183183.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4t9tk68FsQY2xMdLmqMMBg","type":"Entry","createdAt":"2019-09-18T07:37:27.120Z","updatedAt":"2020-10-22T11:23:19.046Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":22,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Jessie D'Amato Ford","tcHandle":"jmpld40","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"upvotes":48,"downvotes":4}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8TlVFApfgpZXwGuSuLjp","type":"Entry","createdAt":"2021-10-14T14:18:29.276Z","updatedAt":"2024-09-15T08:43:46.499Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":55,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Counting and Bucket Sort","slug":"counting-and-bucket-sort","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3uKZbb8OsFeBR3aWFRNWUi","type":"Entry","createdAt":"2019-09-18T07:37:16.187Z","updatedAt":"2019-09-18T07:37:16.187Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Search","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["Sort","C"],"creationDate":"2021-10-14","readTime":"15min","content":"### Counting sort\nCounting sort is a sorting algorithm that works on the range of the input values. Counting sort is somewhat different from other sorting techniques, as it is a linear sorting algorithm. This means it runs in learn time O(N), whereas the best comparison-based sorting algorithms have the complexity of O(N log N) (where N is the number of elements in an array).\n\nAs stated above, the values are to be in a range. So, for algorithm implementation, we take an auxiliary array which stores the count of the occurrences of each element in the array lying between 0 to N -1, then the array is used to produce the sorted version of the array using arithmetic operations.\n\nHere we are using an extra array which increases the space complexity. This makes it a bit more costly than other sorting algorithms, as it works only with ranges and is therefore only suitable where the element values’ range is close to the size of the array and the **range = max\\_element - min\\_element + 1.**\n\nNow we will show an example of the process to illustrate this more clearly. \n\nLet's consider an array **A** of length **N** which we are going to sort using counting sort, and an array **aux** of length **K where K is** **max\\_element - min\\_element + 1.**\n\nBasic terminology:\n\n-   The aux array is 0 indexed, which is initially initiated to 0.\n\n-   Every i ranging from 0 <= i <=N-1, store the number of occurrences of i values in the original array or contain the arr\\[i\\] - min element occurrences.\n\nPSEUDOCODE:\n\n-   Use an aux array to store the counts for all unique integers in our input array A.\n\n-   Modify the aux array such that the elements at each index store the sum of previous counts.\n\n-   Now iterate over A and output each integer to its corresponding position in the output array.\n\nOur example array **A**: \\[ 1 , 4 , 1 , 2 , 7 , 5 , 2\\] and N=7;\n\nIn our explanation, we have simplified things by taking the value of K just greater than N.\n\n__STEPS:__\n\nLet’s consider the values to be in the range of 0 to 9.\n\n1.  Take the count of each unique element in the range\n\n![image](//images.contentful.com/piwi0eufbb2g/y7N76X8SHB65iCQHScNLP/da7b9eae1681f03d028823d99cc4fe1b/image.png)\n\n2. Now modify the aux array such that each ith element contains the sum of previous counts.\n\n![image](//images.contentful.com/piwi0eufbb2g/7puW7ggmZoJEUPtQGTGIvb/421228ead407343008f8d833319f9369/image.png)\n\n3. The above-modified array indicated the position of each object in the output sequence. Now to make it indexed, rotate the array clockwise once.\n\n![image](//images.contentful.com/piwi0eufbb2g/67gBHbpguRb0i3jJACMHkb/9a7a48eaac8c13c4de7b70bfda33a438/image.png)\n\n4. Build the output using the above info.\n\n#### Code Implementation(C++):\nThe code below is implemented and handles the negative number. Here we ground the minimum element and store the count of that minimum element at the 0th index.\n\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\n\nvoid countingSort(vector<int>& arr)\n{\n    int max = *max_element(arr.begin(), arr.end());\n    int min = *min_element(arr.begin(), arr.end());\n    int range = max - min + 1;\n\n    vector<int> aux(range), output(arr.size());\n    for (int i = 0; i < arr.size(); i++)\n        aux[arr[i] - min]++;\n\n    for (int i = 1; i < aux.size(); i++)\n        aux[i] += aux[i - 1];\n\n    for (int i = arr.size() - 1; i >= 0; i--) {\n        output[aux[arr[i] - min] - 1] = arr[i];\n        aux[arr[i] - min]--;\n    }\n\n    for (int i = 0; i < arr.size(); i++)\n        arr[i] = output[i];\n}\nint main()\n{   \n    int n;\n    cin >> n;\n\n    vector<int> arr(n);\n    for(int i=0;i<n;i++) cin >> arr[i];\n\n    countingSort(arr);\n\n    for (int i = 0; i < arr.size(); i++)\n        cout << arr[i] << \" \";\n    return 0;\n}\n```\n\n#### Time Complexity:\n\n**Space complexity: O(N)**\n\nModifying aux array: O(K)\n\nOutput integers to output array: O(N)\n\n**Overall time complexity: O(K + N)**\n\n**In practice, it becomes O(N)**\n\n**A couple of remarks:**\n\n-   Counting sort is stable: if two elemsta A\\[i\\] and A\\[j\\] have the same key value and i < j ,A\\[i\\] will appear before A\\[j\\] in the output.\n\n-   If instead of going from N-1 to 0 (as above), i goes from 0 to N-1, the sort is not stable.\n\n-   Counting sort can be very efficient if k is much smaller than N.\n\n### Bucket Sort\n\nBucket sort is a starting algorithm mainly used when we have data uniformly distributed over a range. As the name suggests, in bucket sort we have several groups called **buckets,** each containing specified elements of the input array. Each bucket is then sorted by either recursively applying the same bucket algorithm or suitable **sorting algorithms**.\n\n**Basic steps for bucket sort:**\n\n-   Partition the range into a fixed number of groups **(buckets),**\n\n-   Iterate over the elements once you have put the elements into the appropriate bucket,\n\n-   Sort the buckets individually using some sorting algorithm,\n\n-   Now, concatenate the buckets together. \n\n**Use cases of bucket sort:**\n\n-   For sorting floating-point numbers.\n\n-   For input uniformly distributed over a range.\n\n#### Scatter-gather Approach\n\nFor further understanding we are going to discuss the scatter-gather approach. As the name suggests we first scatter the given elements into several buckets, then sort the buckets using a sorting algorithm, and at last, gather them in order.\n\nHere is an example which will more clearly explain the process. \n\nLet's consider an array **A** of length **N** which we are going to sort using bucket sort.\n\nHere A = { 10 , 8 , 20 , 7 , 16 , 18 , 12 , 1 , 23 ,11 } and N = 9\n\n![image](//images.contentful.com/piwi0eufbb2g/7gJgKHGnfnmXO9ROuim069/f6d7246ded6a773948b24dfa7807581a/image.png)\n\nAs we can observe, the elements are in a range of about \\[0,25). The buckets would be of the following ranges.\n\n![image](//images.contentful.com/piwi0eufbb2g/lZjEfWUtknuqmRLArE9ZR/055e6bfd85dfe825526958e054bc83ee/image.png)\n\nAs you see above we have distributed our range into five equal buckets. If there is an element like 9 it would go into the second bucket ranging from 5-10. Similarly, every item of the array is placed into its respective bucket.\n\nAfter placing the elements into buckets or __scattering the array elements__:\n\n![image](//images.contentful.com/piwi0eufbb2g/nfe3L6ceqUyZdZ9cC9R49/ad1ecde1c40e201074c75c19eab168b2/image.png)\n\nNow, we should individually sort the buckets using any stable sorting algorithms.\n\n![image](//images.contentful.com/piwi0eufbb2g/1Gg6TdOycfuk3rPqzj4CuK/c9cf61c63741332a5e66b7a438a875b1/image.png)\n\nNow, at last, we should gather them bucket by bucket.\n\n![image](//images.contentful.com/piwi0eufbb2g/249lz9xmadZb5frH5Fov5X/74d23199ca68b40f1611280f69462de3/image.png)\n\n#### Code Implementation:\n```cpp\n#include <stdio.h>  \nint getMax(int a[], int n) // function to get maximum element from the given array  \n{  \n  int max = a[0];  \n  for (int i = 1; i < n; i++)  \n    if (a[i] > max)  \n      max = a[i];  \n  return max;  \n}  \nvoid bucket(int a[], int n) // function to implement bucket sort  \n{  \n  int max = getMax(a, n); //max is the maximum element of array  \n  int bucket[max], i;  \n  for (int i = 0; i <= max; i++)  \n  {  \n    bucket[i] = 0;  \n  }  \n  for (int i = 0; i < n; i++)  \n  {  \n    bucket[a[i]]++;  \n  }  \n  for (int i = 0, j = 0; i <= max; i++)  \n  {  \n    while (bucket[i] > 0)  \n    {  \n      a[j++] = i;  \n      bucket[i]--;  \n    }  \n  }  \n}  \nvoid printArr(int a[], int n) // function to print array elements  \n{  \n  for (int i = 0; i < n; ++i)  \n    printf(\"%d  \", a[i]);  \n}  \nint main()  \n{  \n  int a[] = {54, 12, 84, 57, 69, 41, 9, 5};  \n  int n = sizeof(a) / sizeof(a[0]);  \n  printf(\"Before sorting array elements are - \\n\");  \n  printArr(a, n);  \n  bucket(a, n);  \n  printf(\"\\nAfter sorting array elements are - \\n\");  \n  printArr(a, n);  \n} \n```\n\n### Bucket sort complexity:\n-   **Best case complexity -** occurs when the array is already sorted and when the elements are uniformly distributed in buckets. It could improve further if the elements in the bucket are sorted as well. As we know the individual buckets aren't sorted, we can improve our complexity further by using insertion sort which makes our overall complexity linear i.e., O(n+k), where O(n) is for distribution among buckets and O(k) for insertion sort among buckets. The best-case time complexity of bucket sort is **O(n + k)**.\n\n-   **Average case complexity -** occurs when the elements are not in proper sorted order, not ascending and not descending. Bucket sort runs in linear time, even when the elements are uniformly distributed. The average case time complexity of bucket sort is **O(n + K)**.\n\n-   **Worst case complexity -**occurs when elements are in very close range. It means they differ marginally, and due to this property they are placed in the same bucket, causing some buckets to consist of more elements than others. The complexity will get worse when the elements are in reverse order. The worst-case time complexity of bucket sort is **O(n****2****)**.\n\n**The advantages of bucket sort are -**\n\n-   Fewer comparisons than other algorithms,\n\n-   Works faster because of the uniform distribution of elements.\n\n**The limitations of bucket sort are -**\n\n-   Not necessarily a stable algorithm,\n\n-   Efficiency decreases with an increase in the size of the array,\n\n-   Uses extra space, costing a space complexity of O(n).\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6uqY80Xv4nhpVfZtPZwAot","type":"Asset","createdAt":"2021-10-14T14:03:58.177Z","updatedAt":"2021-10-14T14:04:17.815Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"couting","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6uqY80Xv4nhpVfZtPZwAot/c725bc250b7928a8ba058c3bf6a71223/couting.png","details":{"size":29399,"image":{"width":626,"height":355}},"fileName":"couting.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":2,"downvotes":1,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5BVGP4CoZCW756Sb7N4L9y","type":"Entry","createdAt":"2021-09-21T10:20:59.677Z","updatedAt":"2022-09-10T06:54:27.585Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":99,"revision":23,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Tree Data Structure","slug":"tree-data-structure","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["Algorithm","Graph"],"creationDate":"2021-09-21","readTime":"10min","content":"### Types of Data Structure\n\nThere are two types of data structures; linear and nonlinear. In **linear** data structure, elements will be attached linearly, like in the case of stack, linked lists, queue etc.  In **nonlinear** data structure elements will not be arranged in sequential order, as seen in trees or graphs, so it is more difficult to traverse.\n\n### Definition\n\nA tree is a collection of nodes. These nodes are arranged in a hierarchical structure and  linked to each other by edges (not making a cycle). Trees are preferred when we want to reduce the cost of operations and memory use.\n\n![image](//images.contentful.com/piwi0eufbb2g/39dpfcSKrtv216GsV9Sr3w/0f01cc76a84affc8435c3c79e12c1b90/image.png)\nFigure 1\n\n### Types of Trees\n\nThe different types of trees in data structure based on their properties : general tree, binary tree, binary search tree, AVL tree, red-black tree, splay tree, and B-tree.  \n\n#### General tree:\nIn this tree its node can have 0 to N number of nodes, in which every node has no degree restrictions. Mainly, a general tree does not have ordered nodes. Hence its subtree will also be unordered.\n\n![image](//images.contentful.com/piwi0eufbb2g/4A4iu2vrAOkh6QlWpwWAzm/967d4b49c63572a1c8c6472d3a38839f/image.png)\nFigure 2\n\n#### Binary tree:\nIt is a recursive tree in which each node can have two child nodes at most.\n\n##### Properties of binary trees are:\nThe number of the total nodes on each level will be double the nodes present at the previous level. The last level will have the number of nodes present on all levels plus one.\n\n#### Binary search tree:\nIs a node-based binary tree but with different properties like:  \n\n1. Left subtree will contain the nodes with the values lesser than the value of its root node.\n\n2. Right subtree will contain nodes with values greater than the value of its root.\n\n3. The left and right subtrees should be binary trees in themselves.\n\n![image](//images.contentful.com/piwi0eufbb2g/3DPH99L4wJDoXwl9j94lKr/739a3dc3da0bf4f7885c2ba293d636fc/image.png)\nFigure 3\n\n#### AVL tree:\nIt satisfies both binary tree and binary search tree properties. This tree is a self-balancing tree which was invented by the mathematician **Adelson Velsky Lindas.**  The self-balancing property says that the difference between the height of the left and right subtree should not be more than one and it is implemented on all the nodes.\n\n![image](//images.contentful.com/piwi0eufbb2g/4vWVSkAsBVL4oJahIZhzLS/2010ae502bd771b646353fd3a84bfa87/image.png)\nFigure 4\n\n### Properties of Trees and Terminologies\n\n#### Node\nBasic unit containing value and nodes pointing to left and right subtree.\n\n```\nCode : class Node {\n\nint data;\n\nNode left, right; //pointer to left and right subtree\n\n}\n```\n\n#### Root\nTopmost node in a tree; it is the ancestor of all the nodes in a tree.  \n\n#### Child\nAny node which is connected to another node when moving away from the root is called a child of its ancestor.\n\n#### Level\nTotal count of edges between current node and root of a tree plus one.\n\n#### Leaf\nAny node which doesn't have any child.\n\n#### Edge\nLink between the two different nodes which does not lead to a cycle.\n\n#### Height\nThe longest path which can be drawn between root node and leaf node.\n\n#### Breadth\nTotal number of leaf nodes present in a tree.\n\n#### Degree\nThe count of child nodes that exist for a node is the degree of a  node.\n\n### Tree Uses in the Real World\nTrees are used widely in databases to implement indexing, to implement dictionaries, for quick pattern searching, and finding the shortest distance. Binary trees are used for fast searching and sorting data.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Y1AOG1YXQlhTmMHfBYvPz","type":"Asset","createdAt":"2021-09-21T10:12:41.521Z","updatedAt":"2021-09-21T10:12:41.521Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"localization example app","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4Y1AOG1YXQlhTmMHfBYvPz/837841b4bfc581f036b8db3c2084ffe8/Banner.png","details":{"size":22355,"image":{"width":455,"height":355}},"fileName":"Banner.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":8,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1ViiHZFGcwDFMBCADZLDpF"}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70ppAv0WygqfWWlipllAZu","type":"Entry","createdAt":"2020-02-20T15:37:44.048Z","updatedAt":"2022-02-13T10:37:14.930Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":372,"revision":78,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Data Structures","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Data Structures","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505847)\n<br/>\nEven though computers can perform literally millions of mathematical computations per second, when a problem gets large and complicated, performance can nonetheless be an important consideration. One of the most crucial aspects to how quickly a problem can be solved is how the data is stored in memory.\n\\\nTo illustrate this point, consider going to the local library to find a book about a specific subject matter. Most likely, you will be able to use some kind of electronic reference or, in the worst case, a card catalog, to determine the title and author of the book you want. Since the books are typically shelved by category, and within each category sorted by author’s name, it is a fairly straightforward and painless process to then physically select your book from the shelves.\n\\\nNow, suppose instead you came to the library in search of a particular book, but instead of organized shelves, were greeted with large garbage bags lining both sides of the room, each arbitrarily filled with books that may or may not have anything to do with one another. It would take hours, or even days, to find the book you needed, a comparative eternity. This is how software runs when data is not stored in an efficient format appropriate to the application.\n<br/><br/>\n### Simple Data Structures\nThe simplest data structures are primitive variables. They hold a single value, and beyond that, are of limited use. When many related values need to be stored, an array is used. It is assumed that the reader of this article has a solid understanding of variables and arrays.\n\\\nA somewhat more difficult concept, though equally primitive, are pointers. Pointers, instead of holding an actual value, simply hold a memory address that, in theory, contains some useful piece of data. Most seasoned C++ coders have a solid understanding of how to use pointers, and many of the caveats, while fledgling programmers may find themselves a bit spoiled by more modern “managed” languages which, for better or worse, handle pointers implicitly. Either way, it should suffice to know that pointers “point” somewhere in memory, and do not actually store data themselves.\n\\\nA less abstract way to think about pointers is in how the human mind remembers (or cannot remember) certain things. Many times, a good engineer may not necessarily know a particular formula/constant/equation, but when asked, they could tell you exactly which reference to check.\n<br/><br/>\n### Arrays\nArrays are a very simple data structure, and may be thought of as a list of a fixed length. Arrays are nice because of their simplicity, and are well suited for situations where the number of data items is known (or can be programmatically determined). Suppose you need a piece of code to calculate the average of several numbers. An array is a perfect data structure to hold the individual values, since they have no specific order, and the required computations do not require any special handling other than to iterate through all of the values. The other big strength of arrays is that they can be accessed randomly, by index. For instance, if you have an array containing a list of names of students seated in a classroom, where each seat is numbered 1 through n, then studentName[i] is a trivial way to read or store the name of the student in seat i.\n\\\nAn array might also be thought of as a pre-bound pad of paper. It has a fixed number of pages, each page holds information, and is in a predefined location that never changes.\n<br/><br/>\n### Linked Lists\nA linked list is a data structure that can hold an arbitrary number of data items, and can easily change size to add or remove items. A linked list, at its simplest, is a pointer to a data node. Each data node is then composed of data (possibly a record with several data values), and a pointer to the next node. At the end of the list, the pointer is set to null.\n\\\nBy nature of its design, a linked list is great for storing data when the number of items is either unknown, or subject to change. However, it provides no way to access an arbitrary item from the list, short of starting at the beginning and traversing through every node until you reach the one you want. The same is true if you want to insert a new node at a specific location. It is not difficult to see the problem of inefficiency.\n\\\nA typical linked list implementation would have code that defines a node, and looks something like this:\n<br/>\n```\nclass ListNode {\nString data;\nListNode nextNode;\n}\nListNode firstNode;\n```\n\\\nYou could then write a method to add new nodes by inserting them at the beginning of the list:\n<br/>\n```\nListNode newNode = new ListNode();\nNewNode.nextNode = firstNode;\nfirstNode = newNode;\n```\n\\\nIterating through all of the items in the list is a simple task:\n<br/>\n```\nListNode curNode = firstNode;\nwhile (curNode != null) {\nProcessData(curNode);\ncurNode = curNode.nextNode;\n}\n```\n\\\nA related data structure, the doubly linked list, helps this problem somewhat. The difference from a typical linked list is that the root data structure stores a pointer to both the first and last nodes. Each individual node then has a link to both the previous and next node in the list. This creates a more flexible structure that allows travel in both directions. Even still, however, this is rather limited.\n<br/><br/>\n### Queues\nA queue is a data structure that is best described as “first in, first out”. A real world example of a queue is people waiting in line at the bank. As each person enters the bank, he or she is “enqueued” at the back of the line. When a teller becomes available, they are “dequeued” at the front of the line.\n\\\nPerhaps the most common use of a queue within a topcoder problem is to implement a Breadth First Search (BFS). BFS means to first explore all states that can be reached in one step, then all states that can be reached in two steps, etc. A queue assists in implementing this solution because it stores a list of all state spaces that have been visited.\n\\\nA common type of problem might be the shortest path through a maze. Starting with the point of origin, determine all possible locations that can be reached in a single step, and add them to the queue. Then, dequeue a position, and find all locations that can be reached in one more step, and enqueue those new positions. Continue this process until either a path is found, or the queue is empty (in which case there is no path). Whenever a “shortest path” or “least number of moves” is requested, there is a good chance that a BFS, using a queue, will lead to a successful solution.\n\\\nMost standard libraries, such the Java API, and the .NET framework, provide a Queue class that provides these two basic interfaces for adding and removing items from a queue.\n\\\nBFS type problems appear frequently on challenges; on some problems, successful identification of BFS is simple and immediately, other times it is not so obvious.\n\\\nA queue implementation may be as simple as an array, and a pointer to the current position within the array. For instance, if you know that you are trying to get from point A to point B on a 50×50 grid, and have determined that the direction you are facing (or any other details) are not relevant, then you know that there are no more than 2,500 “states” to visit. Thus, your queue is programmed like so:\n<br/>\n```\nclass StateNode {\nint xPos;\nint yPos;\nint moveCount;\n}\n\n\nclass MyQueue {\nStateNode[] queueData = new StateNode[2500];\nint queueFront = 0;\nint queueBack = 0;\n\n\nvoid Enqueue(StateNode node) {\nqueueData[queueBack] = node;\nqueueBack++;\n}\n\n\nStateNode Dequeue() {\nStateNode returnValue = null;\nif (queueBack > queueFront) {\nreturnValue = queueData[queueFront];\nQueueFront++;\n}\nreturn returnValue;\n}\n\n\nboolean isNotEmpty() {\nreturn (queueBack > queueFront);\n}\n}\n```\n\\\nThen, the main code of your solution looks something like this. (Note that if our queue runs out of possible states, and we still haven’t reached our destination, then it must be impossible to get there, hence we return the typical “-1” value.)\n<br/>\n```\nMyQueue queue = new MyQueue();\nqueue.Enqueue(initialState);\nwhile (queue.isNotEmpty()) {\nStateNode curState = queue.Dequeue();\nif (curState == destState)\nreturn curState.moveCount;\nfor (int dir = 0; dir < 3; dir++) {\nif (CanMove(curState, dir))\nqueue.Enqueue(MoveState(curState, dir));\n}\n}\n```\n<br/><br/>\n### Stacks\nStacks are, in a sense, the opposite of queues, in that they are described as “last in, first out”. The classic example is the pile of plates at the local buffet. The workers can continue to add clean plates to the stack indefinitely, but every time, a visitor will remove from the stack the top plate, which is the last one that was added.\n\\\nWhile it may seem that stacks are rarely implemented explicitly, a solid understanding of how they work, and how they are used implicitly, is worthwhile education. Those who have been programming for a while are intimately familiar with the way the stack is used every time a subroutine is called from within a program. Any parameters, and usually any local variables, are allocated out of space on the stack. Then, after the subroutine has finished, the local variables are removed, and the return address is “popped” from the stack, so that program execution can continue where it left off before calling the subroutine.\n\\\nAn understanding of what this implies becomes more important as functions call other functions, which in turn call other functions. Each function call increases the “nesting level” (the depth of function calls, if you will) of the execution, and uses increasingly more space on the stack. Of paramount importance is the case of a recursive function. When a recursive function continually calls itself, stack space is quickly used as the depth of recursion increases. Nearly every seasoned programmer has made the mistake of writing a recursive function that never properly returns, and calls itself until the system throws up an “out of stack space” type of error.\n\\\nNevertheless, all of this talk about the depth of recursion is important, because stacks, even when not used explicitly, are at the heart of a depth first search. A depth first search is typical when traversing through a tree, for instance looking for a particular node in an XML document. The stack is responsible for maintaining, in a sense, a trail of what path was taken to get to the current node, so that the program can “backtrack” (e.g. return from a recursive function call without having found the desired node) and proceed to the next adjacent node.\n\\\n[Soma](http://community.topcoder.com/stat?c=problem_statement&pm=2824&rd=5073) (SRM 198) is an excellent example of a problem solved with this type of approach.\n<br/><br/>\n### Trees\nTrees are a data structure consisting of one or more data nodes. The first node is called the “root”, and each node has zero or more “child nodes”. The maximum number of children of a single node, and the maximum depth of children are limited in some cases by the exact type of data represented by the tree.\n\\\nOne of the most common examples of a tree is an XML document. The top-level document element is the root node, and each tag found within that is a child. Each of those tags may have children, and so on. At each node, the type of tag, and any attributes, constitutes the data for that node. In such a tree, the hierarchy and order of the nodes is well defined, and an important part of the data itself. Another good example of a tree is a written outline. The entire outline itself is a root node containing each of the top-level bullet points, each of which may contain one or more sub-bullets, and so on. The file storage system on most disks is also a tree structure.\n\\\nCorporate structures also lend themselves well to trees. In a classical management hierarchy, a President may have one or more vice presidents, each of whom is in charge of several managers, each of whom presides over several employees.\n\\\n[PermissionTree](http://community.topcoder.com/stat?c=problem_statement&pm=3093&rd=5864) (SRM 218) provides an unusual problem on a common file system.\n\\\n[bloggoDocStructure](http://community.topcoder.com/stat?c=problem_statement&pm=3025&rd=5860) (SRM 214) is another good example of a problem using trees.\n<br/><br/>\n### Binary Trees\nA special type of tree is a binary tree. A binary tree also happens to be one of the most efficient ways to store and read a set of records that can be indexed by a key value in some way. The idea behind a binary tree is that each node has, at most, two children.\n\\\nIn the most typical implementations, the key value of the left node is less than that of its parent, and the key value of the right node is greater than that of its parent. Thus, the data stored in a binary tree is always indexed by a key value. When traversing a binary tree, it is simple to determine which child node to traverse when looking for a given key value.\n\\\nOne might ask why a binary tree is preferable to an array of values that has been sorted. In either case, finding a given key value (by traversing a binary tree, or by performing a binary search on a sorted array) carries a time complexity of O(log n). However, adding a new item to a binary tree is an equally simple operation. In contrast, adding an arbitrary item to a sorted array requires some time-consuming reorganization of the existing data in order to maintain the desired ordering.\n\\\nIf you have ever used a field guide to attempt to identify a leaf that you find in the wild, then this is a good way to understand how data is found in a binary tree. To use a field guide, you start at the beginning, and answer a series of questions like “is the leaf jagged, or smooth?” that have only two possible answers. Based upon your answer, you are directed to another page, which asks another question, and so on. After several questions have sufficiently narrowed down the details, you are presented with the name, and perhaps some further information about your leaf. If one were the editor of such a field guide, newly cataloged species could be added to field guide in much the same manner, by traversing through the questions, and finally at the end, inserting a new question that differentiates the new leaf from any other similar leaves. In the case of a computer, the question asked at each node is simply “are you less than or greater than X?”\n<br/><br/>\n### Priority Queues\nIn a typical breadth first search (BFS) algorithm, a simple queue works great for keeping track of what states have been visited. Since each new state is one more operational step than the current state, adding new locations to the end of the queue is sufficient to insure that the quickest path is found first. However, the assumption here is that each operation from one state to the next is a single step.\n\\\nLet us consider another example where you are driving a car, and wish to get to your destination as quickly as possible. A typical problem statement might say that you can move one block up/down/left/right in one minute. In such a case, a simple queue-based BFS works perfectly, and is guaranteed to provide a correct result.\n\\\nBut what happens if we say that the car can move forward one block in two minute, but requires three minutes to make a turn and then move one block (in a direction different from how the car was originally facing)? Depending on what type of move operation we attempt, a new state is not simply one “step” from the current state, and the “in order” nature of a simple queue is lost.\n\\\nThis is where priority queues come in. Simply put, a priority queue accepts states, and internally stores them in a method such that it can quickly pull out the state that has the least cost. (Since, by the nature of a “shortest time/path” type of problem, we always want to explore the states of least cost first.)\n\\\nA real world example of a priority queue might be waiting to board an airplane. Individuals arriving at their gate earlier will tend to sit closest to the door, so that they can get in line as soon as they are called. However, those individuals with a “gold card”, or who travel first class, will always be called first, regardless of when they actually arrived.\n\\\nOne very simple implementation of a priority queue is just an array that searches (one by one) for the lowest cost state contained within, and appends new elements to the end. Such an implementation has a trivial time-complexity for insertions, but is painfully slow to pull objects out again.\n\\\nA special type of binary tree called a heap is typically used for priority queues. In a heap, the root node is always less than (or greater than, depending on how your value of “priority” is implemented) either of its children. Furthermore, this tree is a “complete tree” from the left. A very simple definition of a complete tree is one where no branch is n + 1 levels deep until all other branches are n levels deep. Furthermore, it is always the leftmost node(s) that are filled first.\n\\\nTo extract a value from a heap, the root node (with the lowest cost or highest priority) is pulled. The deepest, rightmost leaf then becomes the new root node. If the new root node is larger than at at least one of its children, then the root is swapped with its smallest child, in order to maintain the property that the root is always less than its children. This continues downward as far as necessary. Adding a value to the heap is the reverse. The new value is added as the next leaf, and swapped upward as many times as necessary to maintain the heap property.\n\\\nA convenient property of trees that are complete from the left is that they can be stored very efficiently in a flat array. In general, element 0 of the array is the root, and elements 2k + 1 and 2k + 2 are the children of element k. The effect here is that adding the next leaf simply means appending to the array.\n<br/><br/>\n### Hash Tables\nHash tables are a unique data structure, and are typically used to implement a “dictionary” interface, whereby a set of keys each has an associated value. The key is used as an index to locate the associated values. This is not unlike a classical dictionary, where someone can find a definition (value) of a given word (key).\n\\\nUnfortunately, not every type of data is quite as easy to sort as a simple dictionary word, and this is where the “hash” comes into play. Hashing is the process of generating a key value (in this case, typically a 32 or 64 bit integer) from a piece of data. This hash value then becomes a basis for organizing and sorting the data. The hash value might be the first n bits of data, the last n bits of data, a modulus of the value, or in some cases, a more complicated function. Using the hash value, different “hash buckets” can be set up to store data. If the hash values are distributed evenly (which is the case for an ideal hash algorithm), then the buckets will tend to fill up evenly, and in many cases, most buckets will have no more than one or only a few objects in them. This makes the search even faster.\n\\\nA hash bucket containing more than one value is known as a “collision”. The exact nature of collision handling is implementation specific, and is crucial to the performance of the hash table. One of the simplest methods is to implement a structure like a linked list at the hash bucket level, so that elements with the same hash value can be chained together at the proper location. Other, more complicated schemes may involve utilizing adjacent, unused locations in the table, or re-hashing the hash value to obtain a new value. As always, there are good and bad performance considerations (regarding time, size, and complexity) with any approach.\n\\\nAnother good example of a hash table is the Dewey decimal system, used in many libraries. Every book is assigned a number, based upon its subject matterï¿½ the 500′s are all science books, the 700′s are all the arts, etc. Much like a real hash table, the speed at which a person could find a given book is based upon how well the hash buckets are evenly dividedï¿½ It will take longer to find a book about frogs in a library with many science materials than in a library consisting mostly of classical literature.\n\\\nIn applications development, hash tables are a convenient place to store reference data, like state abbreviations that link to full state names. In problem solving, hash tables are useful for implementing a divide-and-conquer approach to knapsack-type problems. In LongPipes, we are asked to find the minimum number of pipes needed to construct a single pipe of a given length, and we have up to 38 pieces of pipe. By dividing this into two sets of 19, and calculating all possible lengths from each set, we create hash tables linking the length of the pipe to the fewest number of segments used. Then, for each constructed pipe in one set, we can easily look up, whether or not we constructed a pipe of corresponding length in the other set, such that the two join to form a complete pipe of the desired length.\n<br/><br/>\n### Conclusion\nThe larger picture to be seen from all of this is that data structures are just another set of tools that should be in the kit of a seasoned programmer. Comprehensive libraries and frameworks available with most languages nowadays preempt the need for a full understanding of how to implement each of these tools. The result is that developers are able to quickly produce quality solutions that take advantage of powerful ideas. The challenge lies in knowing which one to select.\n\\\nNonetheless, knowing a little about how these tools work should help to make the choices easier. And, when the need arises, perhaps leave the programmer better equipped to think up a new solution to a new problemï¿½ if not while on the job doing work for a client, then perhaps while contemplating the 1000 point problem 45 minutes into the coding phase of the next SRM.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"5rg0EyMG9aQUeBU99KbVPd"}}],"upvotes":34,"downvotes":3,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"28xML395bHNDwAhdOKvY9R"}},{"sys":{"type":"Link","linkType":"Entry","id":"3RUcXHuc3tXWkmdesAkmr7"}},{"sys":{"type":"Link","linkType":"Entry","id":"6qQ5n5nHfLRZ0DyCdK5Zfg"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7o89qvqMdNvufmuOMEHPly","type":"Entry","createdAt":"2021-10-07T13:15:49.832Z","updatedAt":"2024-09-06T06:40:11.258Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":306,"revision":136,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topological Sort","slug":"topological-sort","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Graphs","Algorithm","Sorting"],"creationDate":"2021-10-07","readTime":"11min","content":"John recently bought the latest TboX game station and cannot wait to try out the adventure game. But to his surprise, the game levels are ordered in some random fashion and unlike other classical games (where the user starts with level one followed by level two, then three and so on), this game follows an unusually difficult ordering. The user manual lists that any level can be unlocked only after all of its dependent levels are unlocked, and these dependent level's IDs may be bigger than that level's ID. The manual looks like:\n\nNumber of levels = 4\n\n| Level ID     | Dependent on Level ID     |\n| ---------- | ---------- |\n| 1       | 2,3       |\n| 2       | None       |\n| 3       | 2       |\n| 4       | 1,3       |\n\nFor the above example, level one can be unlocked only after levels two and three are unlocked, level three in turn can be unlocked only after level two is unlocked. Level two is not dependent on any other level and thus can be always unlocked. John, being an impatient PRO gamer, wants to complete the whole game in one sitting and is trying to list the levels in an order that he must follow to unlock the whole game. Can you help him to do so?\n\nThe answer for the above example can be \\[2, 3, 1, 4\\] (play level two followed by three, then one, then four).\n\nLet's choose the first level which we can start playing; intuitively it would be the level that is not dependent on any other level. It's also crucial to observe that there can be multiple correct answers to this problem. Suppose multiple levels have zero dependencies. In that case, John can start his game with any of these levels and we can get more than one order.\nOnce the first level is decided let's choose the second level, again following intuition, the second level has to be either one with zero dependencies or one which is dependent only on the level we chose on the previous step.\nFor the third level, we can choose either a level that has zero dependencies or one which is dependent only on our first level or which is dependent only on our second level or which is dependent only on our first and second level. Can you spot the pattern here?\nThis is called __topological sorting__.\n\n### Making the problem more intuitive and standard\n\nLet's convert the whole problem into a graph where each level is a vertex, and there is a directed node from level __u__ to level __v__, if __u__ is dependent on level __v__. The graph for the above chart then looks like this:\n\n![image](//images.contentful.com/piwi0eufbb2g/4pOjQaDky835E0WAlngTWR/d03abc9514ec41a2d3bc47dc42e86307/image.png)\n\nAccording to the problem, to reach vertex four we first need to reach all the vertices that four has a directed edge to. This reminds us of depth-first search (DFS). When run from any vertex **v**, DFS goes to all the vertices reachable from **v**. If, for every DFS call, we can store the current vertex in a list, then we get the topological sorting of the graph. This is exactly what we want.\n\nThe main algorithm for that would be:\n\nDFS()\n\n1.  Iterate over all the vertices of the graph\n\n2.  If the current vertex is not marked:\n\n1.  Recursively call DFS() on the neighbors of this vertex\n\n4.  Insert this vertex on a global list\n\n__Implementation in C++__\n```c++\nvector<vector<int>> adj;\t// adjacency list containing the graph\nvector<int> order;\nvector<bool> marked;\n\nvoid DFS(int idx){\n\tmarked[idx] = true;\n\n\tfor(int neighbors : adj[idx])\n\t\tif(!marked[neighbors])\n\t\t\tDFS(neighbors)\n\n\torder.push_back(idx);\n}\n\nvoid topologicalSort(int n){\n\tmarked.assign(n + 1, false);\n\n\tfor(int i = 1; i < n; i++)\n\t\tif(!marked[i])\n\t\t\tDFS(i);\n\n\t// \"order\" now stores the topo sort.\n\t// Do the further required operations with order\n}\n```\n\n### Condition where topological order does not exist\n\nThe only condition for topological sort to exist is that the graph should be acyclic, i.e, there should not be a cycle in the graph. It's easy to see why that is true, we are traversing from a vertex to all its dependencies but in the case of a cycle, the vertex itself becomes one of its dependencies and thus contradicts the algorithm.\n\n### Conclusion\n\nProblems involving topological sorting are easy to spot and the algorithm can be applied quickly. One just has to look for patterns, such as if any job can be achieved only after some other certain jobs are completed and make sure the resulting graph is acyclic. Problems employing just topological sort can easily be solved and are therefore standard, but a lot of beautiful problems can be created in which finding the topo-order is just a small step required to achieve the final answer.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5pjpijWpkZDtQEvBNKJN9a","type":"Entry","createdAt":"2021-01-07T07:49:04.332Z","updatedAt":"2021-10-07T13:10:26.845Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Shivam Singh","tcHandle":"shivam51","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"upvotes":16,"downvotes":1,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70ppAv0WygqfWWlipllAZu","type":"Entry","createdAt":"2020-02-20T15:37:44.048Z","updatedAt":"2022-02-13T10:37:14.930Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":372,"revision":78,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Data Structures","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Data Structures","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505847)\n<br/>\nEven though computers can perform literally millions of mathematical computations per second, when a problem gets large and complicated, performance can nonetheless be an important consideration. One of the most crucial aspects to how quickly a problem can be solved is how the data is stored in memory.\n\\\nTo illustrate this point, consider going to the local library to find a book about a specific subject matter. Most likely, you will be able to use some kind of electronic reference or, in the worst case, a card catalog, to determine the title and author of the book you want. Since the books are typically shelved by category, and within each category sorted by author’s name, it is a fairly straightforward and painless process to then physically select your book from the shelves.\n\\\nNow, suppose instead you came to the library in search of a particular book, but instead of organized shelves, were greeted with large garbage bags lining both sides of the room, each arbitrarily filled with books that may or may not have anything to do with one another. It would take hours, or even days, to find the book you needed, a comparative eternity. This is how software runs when data is not stored in an efficient format appropriate to the application.\n<br/><br/>\n### Simple Data Structures\nThe simplest data structures are primitive variables. They hold a single value, and beyond that, are of limited use. When many related values need to be stored, an array is used. It is assumed that the reader of this article has a solid understanding of variables and arrays.\n\\\nA somewhat more difficult concept, though equally primitive, are pointers. Pointers, instead of holding an actual value, simply hold a memory address that, in theory, contains some useful piece of data. Most seasoned C++ coders have a solid understanding of how to use pointers, and many of the caveats, while fledgling programmers may find themselves a bit spoiled by more modern “managed” languages which, for better or worse, handle pointers implicitly. Either way, it should suffice to know that pointers “point” somewhere in memory, and do not actually store data themselves.\n\\\nA less abstract way to think about pointers is in how the human mind remembers (or cannot remember) certain things. Many times, a good engineer may not necessarily know a particular formula/constant/equation, but when asked, they could tell you exactly which reference to check.\n<br/><br/>\n### Arrays\nArrays are a very simple data structure, and may be thought of as a list of a fixed length. Arrays are nice because of their simplicity, and are well suited for situations where the number of data items is known (or can be programmatically determined). Suppose you need a piece of code to calculate the average of several numbers. An array is a perfect data structure to hold the individual values, since they have no specific order, and the required computations do not require any special handling other than to iterate through all of the values. The other big strength of arrays is that they can be accessed randomly, by index. For instance, if you have an array containing a list of names of students seated in a classroom, where each seat is numbered 1 through n, then studentName[i] is a trivial way to read or store the name of the student in seat i.\n\\\nAn array might also be thought of as a pre-bound pad of paper. It has a fixed number of pages, each page holds information, and is in a predefined location that never changes.\n<br/><br/>\n### Linked Lists\nA linked list is a data structure that can hold an arbitrary number of data items, and can easily change size to add or remove items. A linked list, at its simplest, is a pointer to a data node. Each data node is then composed of data (possibly a record with several data values), and a pointer to the next node. At the end of the list, the pointer is set to null.\n\\\nBy nature of its design, a linked list is great for storing data when the number of items is either unknown, or subject to change. However, it provides no way to access an arbitrary item from the list, short of starting at the beginning and traversing through every node until you reach the one you want. The same is true if you want to insert a new node at a specific location. It is not difficult to see the problem of inefficiency.\n\\\nA typical linked list implementation would have code that defines a node, and looks something like this:\n<br/>\n```\nclass ListNode {\nString data;\nListNode nextNode;\n}\nListNode firstNode;\n```\n\\\nYou could then write a method to add new nodes by inserting them at the beginning of the list:\n<br/>\n```\nListNode newNode = new ListNode();\nNewNode.nextNode = firstNode;\nfirstNode = newNode;\n```\n\\\nIterating through all of the items in the list is a simple task:\n<br/>\n```\nListNode curNode = firstNode;\nwhile (curNode != null) {\nProcessData(curNode);\ncurNode = curNode.nextNode;\n}\n```\n\\\nA related data structure, the doubly linked list, helps this problem somewhat. The difference from a typical linked list is that the root data structure stores a pointer to both the first and last nodes. Each individual node then has a link to both the previous and next node in the list. This creates a more flexible structure that allows travel in both directions. Even still, however, this is rather limited.\n<br/><br/>\n### Queues\nA queue is a data structure that is best described as “first in, first out”. A real world example of a queue is people waiting in line at the bank. As each person enters the bank, he or she is “enqueued” at the back of the line. When a teller becomes available, they are “dequeued” at the front of the line.\n\\\nPerhaps the most common use of a queue within a topcoder problem is to implement a Breadth First Search (BFS). BFS means to first explore all states that can be reached in one step, then all states that can be reached in two steps, etc. A queue assists in implementing this solution because it stores a list of all state spaces that have been visited.\n\\\nA common type of problem might be the shortest path through a maze. Starting with the point of origin, determine all possible locations that can be reached in a single step, and add them to the queue. Then, dequeue a position, and find all locations that can be reached in one more step, and enqueue those new positions. Continue this process until either a path is found, or the queue is empty (in which case there is no path). Whenever a “shortest path” or “least number of moves” is requested, there is a good chance that a BFS, using a queue, will lead to a successful solution.\n\\\nMost standard libraries, such the Java API, and the .NET framework, provide a Queue class that provides these two basic interfaces for adding and removing items from a queue.\n\\\nBFS type problems appear frequently on challenges; on some problems, successful identification of BFS is simple and immediately, other times it is not so obvious.\n\\\nA queue implementation may be as simple as an array, and a pointer to the current position within the array. For instance, if you know that you are trying to get from point A to point B on a 50×50 grid, and have determined that the direction you are facing (or any other details) are not relevant, then you know that there are no more than 2,500 “states” to visit. Thus, your queue is programmed like so:\n<br/>\n```\nclass StateNode {\nint xPos;\nint yPos;\nint moveCount;\n}\n\n\nclass MyQueue {\nStateNode[] queueData = new StateNode[2500];\nint queueFront = 0;\nint queueBack = 0;\n\n\nvoid Enqueue(StateNode node) {\nqueueData[queueBack] = node;\nqueueBack++;\n}\n\n\nStateNode Dequeue() {\nStateNode returnValue = null;\nif (queueBack > queueFront) {\nreturnValue = queueData[queueFront];\nQueueFront++;\n}\nreturn returnValue;\n}\n\n\nboolean isNotEmpty() {\nreturn (queueBack > queueFront);\n}\n}\n```\n\\\nThen, the main code of your solution looks something like this. (Note that if our queue runs out of possible states, and we still haven’t reached our destination, then it must be impossible to get there, hence we return the typical “-1” value.)\n<br/>\n```\nMyQueue queue = new MyQueue();\nqueue.Enqueue(initialState);\nwhile (queue.isNotEmpty()) {\nStateNode curState = queue.Dequeue();\nif (curState == destState)\nreturn curState.moveCount;\nfor (int dir = 0; dir < 3; dir++) {\nif (CanMove(curState, dir))\nqueue.Enqueue(MoveState(curState, dir));\n}\n}\n```\n<br/><br/>\n### Stacks\nStacks are, in a sense, the opposite of queues, in that they are described as “last in, first out”. The classic example is the pile of plates at the local buffet. The workers can continue to add clean plates to the stack indefinitely, but every time, a visitor will remove from the stack the top plate, which is the last one that was added.\n\\\nWhile it may seem that stacks are rarely implemented explicitly, a solid understanding of how they work, and how they are used implicitly, is worthwhile education. Those who have been programming for a while are intimately familiar with the way the stack is used every time a subroutine is called from within a program. Any parameters, and usually any local variables, are allocated out of space on the stack. Then, after the subroutine has finished, the local variables are removed, and the return address is “popped” from the stack, so that program execution can continue where it left off before calling the subroutine.\n\\\nAn understanding of what this implies becomes more important as functions call other functions, which in turn call other functions. Each function call increases the “nesting level” (the depth of function calls, if you will) of the execution, and uses increasingly more space on the stack. Of paramount importance is the case of a recursive function. When a recursive function continually calls itself, stack space is quickly used as the depth of recursion increases. Nearly every seasoned programmer has made the mistake of writing a recursive function that never properly returns, and calls itself until the system throws up an “out of stack space” type of error.\n\\\nNevertheless, all of this talk about the depth of recursion is important, because stacks, even when not used explicitly, are at the heart of a depth first search. A depth first search is typical when traversing through a tree, for instance looking for a particular node in an XML document. The stack is responsible for maintaining, in a sense, a trail of what path was taken to get to the current node, so that the program can “backtrack” (e.g. return from a recursive function call without having found the desired node) and proceed to the next adjacent node.\n\\\n[Soma](http://community.topcoder.com/stat?c=problem_statement&pm=2824&rd=5073) (SRM 198) is an excellent example of a problem solved with this type of approach.\n<br/><br/>\n### Trees\nTrees are a data structure consisting of one or more data nodes. The first node is called the “root”, and each node has zero or more “child nodes”. The maximum number of children of a single node, and the maximum depth of children are limited in some cases by the exact type of data represented by the tree.\n\\\nOne of the most common examples of a tree is an XML document. The top-level document element is the root node, and each tag found within that is a child. Each of those tags may have children, and so on. At each node, the type of tag, and any attributes, constitutes the data for that node. In such a tree, the hierarchy and order of the nodes is well defined, and an important part of the data itself. Another good example of a tree is a written outline. The entire outline itself is a root node containing each of the top-level bullet points, each of which may contain one or more sub-bullets, and so on. The file storage system on most disks is also a tree structure.\n\\\nCorporate structures also lend themselves well to trees. In a classical management hierarchy, a President may have one or more vice presidents, each of whom is in charge of several managers, each of whom presides over several employees.\n\\\n[PermissionTree](http://community.topcoder.com/stat?c=problem_statement&pm=3093&rd=5864) (SRM 218) provides an unusual problem on a common file system.\n\\\n[bloggoDocStructure](http://community.topcoder.com/stat?c=problem_statement&pm=3025&rd=5860) (SRM 214) is another good example of a problem using trees.\n<br/><br/>\n### Binary Trees\nA special type of tree is a binary tree. A binary tree also happens to be one of the most efficient ways to store and read a set of records that can be indexed by a key value in some way. The idea behind a binary tree is that each node has, at most, two children.\n\\\nIn the most typical implementations, the key value of the left node is less than that of its parent, and the key value of the right node is greater than that of its parent. Thus, the data stored in a binary tree is always indexed by a key value. When traversing a binary tree, it is simple to determine which child node to traverse when looking for a given key value.\n\\\nOne might ask why a binary tree is preferable to an array of values that has been sorted. In either case, finding a given key value (by traversing a binary tree, or by performing a binary search on a sorted array) carries a time complexity of O(log n). However, adding a new item to a binary tree is an equally simple operation. In contrast, adding an arbitrary item to a sorted array requires some time-consuming reorganization of the existing data in order to maintain the desired ordering.\n\\\nIf you have ever used a field guide to attempt to identify a leaf that you find in the wild, then this is a good way to understand how data is found in a binary tree. To use a field guide, you start at the beginning, and answer a series of questions like “is the leaf jagged, or smooth?” that have only two possible answers. Based upon your answer, you are directed to another page, which asks another question, and so on. After several questions have sufficiently narrowed down the details, you are presented with the name, and perhaps some further information about your leaf. If one were the editor of such a field guide, newly cataloged species could be added to field guide in much the same manner, by traversing through the questions, and finally at the end, inserting a new question that differentiates the new leaf from any other similar leaves. In the case of a computer, the question asked at each node is simply “are you less than or greater than X?”\n<br/><br/>\n### Priority Queues\nIn a typical breadth first search (BFS) algorithm, a simple queue works great for keeping track of what states have been visited. Since each new state is one more operational step than the current state, adding new locations to the end of the queue is sufficient to insure that the quickest path is found first. However, the assumption here is that each operation from one state to the next is a single step.\n\\\nLet us consider another example where you are driving a car, and wish to get to your destination as quickly as possible. A typical problem statement might say that you can move one block up/down/left/right in one minute. In such a case, a simple queue-based BFS works perfectly, and is guaranteed to provide a correct result.\n\\\nBut what happens if we say that the car can move forward one block in two minute, but requires three minutes to make a turn and then move one block (in a direction different from how the car was originally facing)? Depending on what type of move operation we attempt, a new state is not simply one “step” from the current state, and the “in order” nature of a simple queue is lost.\n\\\nThis is where priority queues come in. Simply put, a priority queue accepts states, and internally stores them in a method such that it can quickly pull out the state that has the least cost. (Since, by the nature of a “shortest time/path” type of problem, we always want to explore the states of least cost first.)\n\\\nA real world example of a priority queue might be waiting to board an airplane. Individuals arriving at their gate earlier will tend to sit closest to the door, so that they can get in line as soon as they are called. However, those individuals with a “gold card”, or who travel first class, will always be called first, regardless of when they actually arrived.\n\\\nOne very simple implementation of a priority queue is just an array that searches (one by one) for the lowest cost state contained within, and appends new elements to the end. Such an implementation has a trivial time-complexity for insertions, but is painfully slow to pull objects out again.\n\\\nA special type of binary tree called a heap is typically used for priority queues. In a heap, the root node is always less than (or greater than, depending on how your value of “priority” is implemented) either of its children. Furthermore, this tree is a “complete tree” from the left. A very simple definition of a complete tree is one where no branch is n + 1 levels deep until all other branches are n levels deep. Furthermore, it is always the leftmost node(s) that are filled first.\n\\\nTo extract a value from a heap, the root node (with the lowest cost or highest priority) is pulled. The deepest, rightmost leaf then becomes the new root node. If the new root node is larger than at at least one of its children, then the root is swapped with its smallest child, in order to maintain the property that the root is always less than its children. This continues downward as far as necessary. Adding a value to the heap is the reverse. The new value is added as the next leaf, and swapped upward as many times as necessary to maintain the heap property.\n\\\nA convenient property of trees that are complete from the left is that they can be stored very efficiently in a flat array. In general, element 0 of the array is the root, and elements 2k + 1 and 2k + 2 are the children of element k. The effect here is that adding the next leaf simply means appending to the array.\n<br/><br/>\n### Hash Tables\nHash tables are a unique data structure, and are typically used to implement a “dictionary” interface, whereby a set of keys each has an associated value. The key is used as an index to locate the associated values. This is not unlike a classical dictionary, where someone can find a definition (value) of a given word (key).\n\\\nUnfortunately, not every type of data is quite as easy to sort as a simple dictionary word, and this is where the “hash” comes into play. Hashing is the process of generating a key value (in this case, typically a 32 or 64 bit integer) from a piece of data. This hash value then becomes a basis for organizing and sorting the data. The hash value might be the first n bits of data, the last n bits of data, a modulus of the value, or in some cases, a more complicated function. Using the hash value, different “hash buckets” can be set up to store data. If the hash values are distributed evenly (which is the case for an ideal hash algorithm), then the buckets will tend to fill up evenly, and in many cases, most buckets will have no more than one or only a few objects in them. This makes the search even faster.\n\\\nA hash bucket containing more than one value is known as a “collision”. The exact nature of collision handling is implementation specific, and is crucial to the performance of the hash table. One of the simplest methods is to implement a structure like a linked list at the hash bucket level, so that elements with the same hash value can be chained together at the proper location. Other, more complicated schemes may involve utilizing adjacent, unused locations in the table, or re-hashing the hash value to obtain a new value. As always, there are good and bad performance considerations (regarding time, size, and complexity) with any approach.\n\\\nAnother good example of a hash table is the Dewey decimal system, used in many libraries. Every book is assigned a number, based upon its subject matterï¿½ the 500′s are all science books, the 700′s are all the arts, etc. Much like a real hash table, the speed at which a person could find a given book is based upon how well the hash buckets are evenly dividedï¿½ It will take longer to find a book about frogs in a library with many science materials than in a library consisting mostly of classical literature.\n\\\nIn applications development, hash tables are a convenient place to store reference data, like state abbreviations that link to full state names. In problem solving, hash tables are useful for implementing a divide-and-conquer approach to knapsack-type problems. In LongPipes, we are asked to find the minimum number of pipes needed to construct a single pipe of a given length, and we have up to 38 pieces of pipe. By dividing this into two sets of 19, and calculating all possible lengths from each set, we create hash tables linking the length of the pipe to the fewest number of segments used. Then, for each constructed pipe in one set, we can easily look up, whether or not we constructed a pipe of corresponding length in the other set, such that the two join to form a complete pipe of the desired length.\n<br/><br/>\n### Conclusion\nThe larger picture to be seen from all of this is that data structures are just another set of tools that should be in the kit of a seasoned programmer. Comprehensive libraries and frameworks available with most languages nowadays preempt the need for a full understanding of how to implement each of these tools. The result is that developers are able to quickly produce quality solutions that take advantage of powerful ideas. The challenge lies in knowing which one to select.\n\\\nNonetheless, knowing a little about how these tools work should help to make the choices easier. And, when the need arises, perhaps leave the programmer better equipped to think up a new solution to a new problemï¿½ if not while on the job doing work for a client, then perhaps while contemplating the 1000 point problem 45 minutes into the coding phase of the next SRM.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"5rg0EyMG9aQUeBU99KbVPd"}}],"upvotes":34,"downvotes":3,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"28xML395bHNDwAhdOKvY9R"}},{"sys":{"type":"Link","linkType":"Entry","id":"3RUcXHuc3tXWkmdesAkmr7"}},{"sys":{"type":"Link","linkType":"Entry","id":"6qQ5n5nHfLRZ0DyCdK5Zfg"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2LF4An9w0IDCr6w8k43kXF","type":"Entry","createdAt":"2020-02-24T22:44:09.126Z","updatedAt":"2024-07-31T06:30:05.201Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1296,"revision":586,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Dynamic Programming: From Novice to Advanced","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Sorting","Libraries","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"<a href=\"http://apps.topcoder.com/forums/?module=ThreadList&forumID=505844\">Discuss this article in the forums</a> \n\\\nAn important part of given problems can be solved with the help of dynamic programming (<strong>DP</strong> for short).  Being able to tackle problems of this type would greatly increase your skill. I will try to help you in understanding how to solve problems using DP. The article is based on examples, because a raw theory is very hard to understand. \n\\\n__Note__: If you’re bored reading one section and you already know what’s being discussed in it – skip it and go to the next one. \n\n### Introduction (Beginner)\n<em><strong>What is a dynamic programming, how can it be described?</strong></em> A <strong>DP</strong> is an algorithmic technique which is usually based on a recurrent formula and one (or some) starting states. A sub-solution of the problem is constructed from previously found ones. DP solutions have a polynomial complexity which assures a much faster running time than other techniques like backtracking, brute-force etc.\n\\\nNow let’s see the base of DP with the help of an example: \n\\\nGiven a list of N coins, their values (<strong>V<sub>1</sub></strong>, <strong>V<sub>2</sub></strong>, … , <strong>V<sub>N</sub></strong>), and the total sum <strong>S</strong>. Find the minimum number of coins the sum of which is <strong>S</strong> (we can use as many coins of one type as we want), or report that it’s not possible to select coins in such a way that they sum up to <strong>S</strong>. \n\\\nNow let’s start constructing a DP solution: \n\\\nFirst of all we need to find a state for which an optimal solution is found and with the help of which we can find the optimal solution for the next state. \n\\\n<em><strong>What does a \"state\" stand for?</strong></em> \n\\\nIt’s a way to describe a situation, a sub-solution for the problem. For example a state would be the solution for sum <strong>i</strong>, where <strong>i≤S</strong>. A smaller state than state <strong>i</strong> would be the solution for any sum <strong>j</strong>, where <strong>j&lt;i</strong>. For finding a <strong>state i</strong>, we need to first find all smaller states <strong>j (j&lt;i) </strong>. Having found the minimum number of coins which sum up to <strong>i</strong>, we can easily find the next state – the solution for <strong>i+1</strong>. \n\\\n<em><strong>How can we find it?</strong></em> \n\\\nIt is simple – for each coin <strong>j, V<sub>j</sub>≤i</strong>, look at the minimum number of coins found for the <strong>i-V<sub>j</sub></strong>sum (we have already found it previously). Let this number be <strong>m</strong>. If <strong>m+1</strong> is less than the minimum number of coins already found for current sum <strong>i</strong>, then we write the new result for it. \n\\\nFor a better understanding let’s take this example:<br>Given coins with values 1, 3, and 5.<br>And the sum <strong>S</strong> is set to be 11. \n\\\nFirst of all we mark that for state 0 (sum 0) we have found a solution with a minimum number of 0 coins. We then go to sum 1. First, we mark that we haven’t yet found a solution for this one (a value of Infinity would be fine). Then we see that only coin 1 is less than or equal to the current sum. Analyzing it, we see that for sum 1-<strong>V<sub>1</sub></strong>= 0  we have a solution with 0 coins. Because we add one coin to this solution, we’ll have a solution with 1 coin for sum 1. It’s the only solution yet found for this sum. We write (save) it. Then we proceed to the next state – <strong>sum 2</strong>. We again see that the only coin which is less or equal to this sum is the first coin, having a value of 1. The optimal solution found for sum (2-1) = 1  is coin 1. This coin 1 plus the first coin will sum up to 2, and thus make a sum of 2 with the help of only 2 coins. This is the best and only solution for sum 2. Now we proceed to sum 3. We now have 2 coins which are to be analyzed – first and second one, having values of 1 and 3. Let’s see the first one. There exists a solution for sum 2 (3 – 1) and therefore we can construct from it a solution for sum 3 by adding the first coin to it. Because the best solution for sum 2 that we found has 2 coins, the new solution for sum 3 will have 3 coins. Now let’s take the second coin with value equal to 3. The sum for which this coin needs to be added to make 3 , is 0. We know that sum 0 is made up of 0 coins. Thus we can make a sum of 3 with only one coin – 3. We see that it’s better than the previous found solution for sum 3 , which was composed of 3 coins. We update it and mark it as having only 1 coin. The same we do for sum 4, and get a solution of 2 coins – 1+3. And so on. \n\\\n<strong>Pseudocode:</strong> \n```\nSet Min[i] equal to Infinity for all of i\nMin[0]=0\n\nFor i = 1 to S\nFor j = 0 to N - 1\n\tIf (Vj<=i AND Min[i-Vj]+1 < Min[i])\nThen Min[i]=Min[i-Vj]+1\n\nOutput Min[S]\n```\n\nHere are the solutions found for all sums:\n\\\n<table class=\"tableizer-table\"><thead><tr class=\"tableizer-firstrow\"><th style=\"width:20%\">Sum</th><th style=\"width:32%\">Min. nr. of coins</th><th>Coin value (Previous Smaller Sum)</th></tr></thead><tbody><tr><td>0</td><td>0</td><td>-</td></tr><tr><td>1</td><td>1</td><td>1 (0)</td></tr><tr><td>2</td><td>2</td><td>1 (1)</td></tr><tr><td>3</td><td>1</td><td>3 (0)</td></tr><tr><td>4</td><td>2</td><td>1 (3)</td></tr><tr><td>5</td><td>1</td><td>5 (0)</td></tr><tr><td>6</td><td>2</td><td>3 (3)</td></tr><tr><td>7</td><td>3</td><td>1 (6)</td></tr><tr><td>8</td><td>2</td><td>3 (5)</td></tr><tr><td>9</td><td>3</td><td>1 (8)</td></tr><tr><td>10</td><td>2</td><td>5 (5)</td></tr><tr><td>11</td><td>3</td><td>1 (10)</td></tr> </tbody></table>\n\nAs a result we have found a solution of 3 coins which sum up to 11. \n\nAdditionally, by tracking data about how we got to a certain sum from a previous one, we can find what coins were used in building it. For example: to sum 11 we got by adding the coin with value 1 to a sum of 10. To sum 10 we got from 5. To 5 – from 0. This way we find the coins used: 1, 5 and 5. \n\nHaving understood the basic way a <strong>DP</strong> is used, we may now see a slightly different approach to it. It involves the change (update) of best solution yet found for a sum i, whenever a better solution for this sum was found. In this case the states aren’t calculated consecutively. Let’s consider the problem above. Start with having a solution of 0 coins for sum 0. Now let’s try to add first coin (with value 1) to all sums already found. If the resulting sum <strong>t</strong> will be composed of fewer coins than the one previously found – we’ll update the solution for it. Then we do the same thing for the second coin, third coin, and so on for the rest of them. For example, we first add coin 1 to sum 0 and get sum 1. Because we haven’t yet found a possible way to make a sum of 1 – this is the best solution yet found, and we mark <strong>S[1]=1</strong>. By adding the same coin to sum 1, we’ll get sum 2, thus making <strong>S[2]=2</strong>. And so on for the first coin. After the first coin is processed, take coin 2 (having a value of 3) and consecutively try to add it to each of the sums already found. Adding it to 0, a sum 3 made up of 1 coin will result. Till now, <strong>S[3]</strong> has been equal to 3, thus the new solution is better than the previously found one. We update it and mark <strong>S[3]=1</strong>. After adding the same coin to sum 1, we’ll get a sum 4 composed of 2 coins. Previously we found a sum of 4 composed of 4 coins; having now found a better solution we update <strong>S[4]</strong> to 2. The same thing is done for next sums – each time a better solution is found, the results are updated.\n\n### Elementary\n\nTo this point, very simple examples have been discussed. Now let’s see how to find a way for passing from one state to another, for harder problems. For that we will introduce a new term called recurrent relation, which makes a connection between a lower and a greater state.\n\nLet’s see how it works: \n\nGiven a sequence of N numbers – <strong>A[1] </strong>, <strong>A[2] </strong>, …, <strong>A[N] </strong>. Find the length of the longest non-decreasing sequence. \n\nAs described above we must first find how to define a \"state\" which represents a sub-problem and thus we have to find a solution for it. Note that in most cases the states rely on lower states and are independent from greater states. \n\nLet’s define a state <strong>i</strong> as being the longest non-decreasing sequence which has its last number <strong>A[i] </strong>. This state carries only data about the length of this sequence. Note that for <strong>i&lt;j</strong> the state <strong>i</strong> is independent from <strong>j</strong>, i.e. doesn’t change when we calculate state <strong>j</strong>. Let’s see now how these states are connected to each other. Having found the solutions for all states lower than <strong>i</strong>, we may now look for state <strong>i</strong>. At first we initialize it with a solution of 1, which consists only of the <strong>i-th</strong> number itself. Now for each <strong>j&lt;i</strong> let’s see if it’s possible to pass from it to state i. This is possible only when <strong>A[j]≤A[i] </strong>, thus keeping (assuring) the sequence non-decreasing. So if <strong>S[j] </strong> (the solution found for state <strong>j</strong>) + <strong>1</strong> (number <strong>A[i] </strong> added to this sequence which ends with number <strong>A[j] </strong>) is better than a solution found for <strong>i</strong> (ie. <strong>S[j]+1&gt;S[i] </strong>), we make <strong>S[i]=S[j]+1</strong>. This way we consecutively find the best solutions for each <strong>i</strong>, until last state N. \n\nLet’s see what happens for a randomly generated sequence: 5, 3, 4, 8, 6, 7: \n\n<table><thead><tr class=\"tableizer-firstrow\"><th style=\"width:20%\">I</th><th style=\"width:32%\">Length of Longest non-decreasing sequence (first I numbers)</th><th>The last sequence i from which we \"arrived\" to this one</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>1 (first number itself)</td></tr><tr><td>2</td><td>1</td><td>2 (second number itself)</td></tr><tr><td>3</td><td>2</td><td>2</td></tr><tr><td>4</td><td>3</td><td>3</td></tr><tr><td>5</td><td>3</td><td>3</td></tr><tr><td>6</td><td>4</td><td>5</td></tr> </tbody></table>\n\n<strong>Practice problem:</strong><br>\n\nGiven an undirected graph <strong>G</strong> having <strong>N</strong> (1&lt;N&lt;=1000) vertices and positive weights. Find the shortest path from vertex 1 to vertex N, or state that such path doesn’t exist.\n\nHint: At each step, among the vertices which weren’t yet checked and for which a path from vertex 1 was found, take the one which has the shortest path, from vertex 1 to it, yet found. \n\nTry to solve the following problems from Topcoder competitions:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4493&pm=1259\">ZigZag</a> – 2003 TCCC Semifinals 3\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5009&pm=2402\">BadNeighbors</a> – 2004 TCCC Round 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5006&pm=1918\">FlowerGarden</a> – 2004 TCCC Round 1\n\n### Intermediate\n\nLet’s see now how to tackle bi-dimensional DP problems.\n\n<strong>Problem:</strong>\n\nA table composed of <strong>N x M</strong> cells, each having a certain quantity of apples, is given. You start from the upper-left corner. At each step you can go down or right one cell. Find the maximum number of apples you can collect. \n\nThis problem is solved in the same way as other DP problems; there is almost no difference.\n\nFirst of all we have to find a state. The first thing that must be observed is that there are at most 2 ways we can come to a cell – from the left (if it’s not situated on the first column) and from the top (if it’s not situated on the most upper row). Thus to find the best solution for that cell, we have to have already found the best solutions for all of the cells from which we can arrive to the current cell. \n\nFrom above, a recurrent relation can be easily obtained:<br>\n<strong>S[i][j]=A[i][j] + max(S[i-1][j], if i&gt;0 ; S[i][j-1], if j&gt;0) </strong> (where <strong>i</strong> represents the row and <strong>j</strong> the column of the table , its left-upper corner having coordinates {0,0} ; and <strong>A[i][j]</strong> being the number of apples situated in cell <strong>i,j</strong>). \n\n<strong>S[i][j] </strong> must be calculated by going first from left to right in each row and process the rows from top to bottom, or by going first from top to bottom in each column and process the columns from left to right. \n\nPseudocode:\n```\nFor i = 0 to N - 1\n\tFor j = 0 to M - 1\n\tS[i][j] = A[i][j] +\n\t\tmax(S[i][j-1], if j>0 ; S[i-1][j], if i>0 ; 0)\n\nOutput S[n-1][m-1]\n```\n\nHere are a few problems, from Topcoder Competitions, for practicing:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4709&pm=1889\">AvoidRoads</a> – 2003 TCO Semifinals 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4482&pm=1592\">ChessMetric</a> – 2003 TCCC Round 4\n\n### Upper-Intermediate\n\nThis section will discuss about dealing DP problems which have an additional condition besides the values that must be calculated.\n\nAs a good example would serve the following problem: \n\nGiven an undirected graph <strong>G</strong> having positive weights and <strong>N</strong> vertices.\n\nYou start with having a sum of <strong>M</strong> money. For passing through a vertex <strong>i</strong>, you must pay <strong>S[i] </strong> money. If you don’t have enough money – you can’t pass through that vertex. Find the shortest path from vertex 1 to vertex N, respecting the above conditions; or state that such path doesn’t exist. If there exist more than one path having the same length, then output the cheapest one. Restrictions: 1&lt;N&lt;=100 ; 0&lt;=M&lt;=100 ; for each i, 0&lt;=S[i]&lt;=100. As we can see, this is the same as the classical Dijkstra problem (finding the shortest path between two vertices), with the exception that it has a condition. In the classical Dijkstra problem we would have used a uni-dimensional array <strong>Min[i] </strong>, which marks the length of the shortest path found to vertex <strong>i</strong>. However in this problem we should also keep information about the money we have. Thus it would be reasonable to extend the array to something like <strong>Min[i][j] </strong>, which represents the length of the shortest path found to vertex <strong>i</strong>, with <strong>j</strong> money being left. In this way the problem is reduced to the original path-finding algorithm. At each step we find the unmarked state (i,j) for which the shortest path was found. We mark it as visited (not to use it later), and for each of its neighbors we look if the shortest path to it may be improved. If so – then update it. We repeat this step until there will remain no unmarked state to which a path was found. The solution will be represented by <strong>Min[N-1][j] </strong> having the least value (and the greatest <strong>j</strong> possible among the states having the same value, i.e. the shortest paths to which has the same length). \n\nPseudocode:\n```\nSet states(i,j) as unvisited for all (i,j)\nSet Min[i][j] to Infinity for all (i,j)\n\nMin[0][M]=0\n\nWhile(TRUE)\n\nAmong all unvisited states(i,j) find the one for which Min[i][j]\nis the smallest. Let this state found be (k,l).\n\nIf there wasn't found any state (k,l) for which Min[k][l] is\nless than Infinity - exit While loop.\n\nMark state(k,l) as visited\n\nFor All Neighbors p of Vertex k.\n\tIf (l-S[p]>=0 AND\n\tMin[p][l-S[p]]>Min[k][l]+Dist[k][p])\n\t\tThen Min[p][l-S[p]]=Min[k][l]+Dist[k][p]\ni.e.\nIf for state(i,j) there are enough money left for\ngoing to vertex p (l-S[p] represents the money that\nwill remain after passing to vertex p), and the\nshortest path found for state(p,l-S[p]) is bigger\nthan [the shortest path found for\nstate(k,l)] + [distance from vertex k to vertex p)],\nthen set the shortest path for state(i,j) to be equal\nto this sum.\nEnd For\n\nEnd While\n\nFind the smallest number among Min[N-1][j] (for all j, 0<=j<=M);\nif there are more than one such states, then take the one with greater\nj. If there are no states(N-1,j) with value less than Infinity - then\nsuch a path doesn't exist.\n```\n\nHere are a few Topcoder problems for practicing:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4705&pm=1166\">Jewelry</a> – 2003 TCO Online Round 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4555&pm=1215\">StripePainter</a> – SRM 150 Div 1\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829\">QuickSums</a> – SRM 197 Div 2\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4630&pm=1861\">ShortPalindromes</a> – SRM 165 Div 2\n\n### Advanced\n\nThe following problems will need some good observations in order to reduce them to a dynamic solution.\n\n<strong>Problem <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5854&pm=2940\">StarAdventure</a> – SRM 208 Div 1:</strong> \n\nGiven a matrix with <strong>M</strong> rows and <strong>N</strong> columns (<strong>N x M</strong>). In each cell there’s a number of apples.<br> You start from the upper-left corner of the matrix. You can go down or right one cell. You need to arrive to the bottom-right corner. Then you need to go back to the upper-left cell by going each step one cell left or up. Having arrived at this upper-left cell, you need to go again back to the bottom-right cell.<br> Find the maximum number of apples you can collect.<br>When you pass through a cell – you collect all the apples left there.\n\nRestrictions: 1 &lt; <strong>N</strong>, <strong>M</strong> &lt;= 50 ; each cell contains between 0 and 1000 apples inclusive. \n First of all we observe that this problem resembles to the classical one (described in Section 3 of this article), in which you need to go only once from the top-left cell to the bottom-right one, collecting the maximum possible number of apples. It would be better to try to reduce the problem to this one. Take a good look into the statement of the problem – what can be reduced or modified in a certain way to make it possible to solve using DP? First observation is that we can consider the second path (going from bottom-right cell to the top-left cell) as a path which goes from top-left to bottom-right cell. It makes no difference, because a path passed from bottom to top, may be passed from top to bottom just in reverse order. In this way we get three paths going from top to bottom. This somehow decreases the difficulty of the problem. We can consider these 3 paths as left, middle and right. When 2 paths intersect (like in the figure below) \n\n<center>\n<img src=\"https://www.topcoder.com/i/education/dynProg_1.gif\" border=\"0/\">\n</center>\n\nwe may consider them as in the following picture, without affecting the result: \n\n<center>\n<img src=\"https://www.topcoder.com/i/education/dynProg_2.gif\" border=\"0/\">\n</center>\n\nThis way we’ll get 3 paths, which we may consider as being one left, one middle and the other – right. More than that, we may see that for getting an optimal results they must not intersect (except in the leftmost upper corner and rightmost bottom corner). So for each row <strong>y</strong> (except first and last), the <strong>x</strong> coordinates of the lines (<strong>x1[y] </strong>, <strong>x2[y] </strong> and respectively <strong>x3[y] </strong>) will be : <strong>x1[y] </strong> &lt; <strong>x2[y] </strong> &lt; <strong>x3[y] </strong>. Having done that – the DP solution now becomes much clearer. Let’s consider the row y. Now suppose that for any configuration of <strong>x1[y-1] </strong>, <strong>x2[y-1] </strong> and <strong>x3[y-1] </strong> we have already found the paths which collect the maximum number of apples. From them we can find the optimal solution for row <strong>y</strong>. We now have to find only the way for passing from one row to the next one. Let <strong>Max[i][j][k] </strong> represent the maximum number of apples collected till row <strong>y-1</strong> inclusive, with three paths finishing at column <strong>i</strong>, <strong>j</strong>, and respectively <strong>k</strong>. For the next row <strong>y</strong>, add to each <strong>Max[i][j][k] </strong> (obtained previously) the number of apples situated in cells (<strong>y,i</strong>) , (<strong>y,j</strong>) and (<strong>y,k</strong>). Thus we move down at each step. After we made such a move, we must consider that the paths may move in a row to the right. For keeping the paths out of an intersection, we must first consider the move to the right of the left path, after this of the middle path, and then of the right path. For a better understanding think about the move to the right of the left path – take every possible pair of, <strong>k</strong> (where <strong>j&lt;k</strong>), and for each i (1 i&lt;j) consider the move from position (<strong>i-1,j,k</strong>) to position (<strong>i,j,k</strong>). Having done this for the left path, start processing the middle one, which is done similarly; and then process the right path.  \n\nTC problems for practicing:\n\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4710&pm=1996\">MiniPaint</a> – SRM 178 Div 1\n\n<strong>Additional Note:</strong>\n\nWhen have read the description of a problem and started to solve it, first look at its restrictions. If a polynomial-time algorithm should be developed, then it’s possible that the solution may be of DP type. In this case try to see if there exist such states (sub-solutions) with the help of which the next states (sub-solutions) may be found. Having found that – think about how to pass from one state to another. If it seems to be a DP problem, but you can’t define such states, then try to reduce the problem to another one (like in the example above, from Section 5).\n\n<strong>Mentioned in this writeup:</strong>\n\nTCCC ’03 Semifinals 3 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4493&pm=1259\">ZigZag</a>\nTCCC ’04 Round 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5009&pm=2402\">BadNeighbors</a>\nTCCC ’04 Round 1 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5006&pm=1918\">FlowerGarden</a>\nTCO ’03 Semifinals 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4709&pm=1889\">AvoidRoads</a>\nTCCC ’03 Round 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4482&pm=1592\">ChessMetric</a>\nTCO ’03 Round 4 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4705&pm=1166\">Jewelry</a>\nSRM 150 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4555&pm=1215\">StripePainter</a>\nSRM 197 Div II Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829\">QuickSums</a>\nSRM 165 Div II Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4630&pm=1861\">ShortPalindromes</a>\nSRM 208 Div I Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5854&pm=2940\">StarAdventure</a>\nSRM 178 Div I Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4710&pm=1996\">MiniPaint</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":200,"downvotes":32}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5BVGP4CoZCW756Sb7N4L9y","type":"Entry","createdAt":"2021-09-21T10:20:59.677Z","updatedAt":"2022-09-10T06:54:27.585Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":99,"revision":23,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Tree Data Structure","slug":"tree-data-structure","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["Algorithm","Graph"],"creationDate":"2021-09-21","readTime":"10min","content":"### Types of Data Structure\n\nThere are two types of data structures; linear and nonlinear. In **linear** data structure, elements will be attached linearly, like in the case of stack, linked lists, queue etc.  In **nonlinear** data structure elements will not be arranged in sequential order, as seen in trees or graphs, so it is more difficult to traverse.\n\n### Definition\n\nA tree is a collection of nodes. These nodes are arranged in a hierarchical structure and  linked to each other by edges (not making a cycle). Trees are preferred when we want to reduce the cost of operations and memory use.\n\n![image](//images.contentful.com/piwi0eufbb2g/39dpfcSKrtv216GsV9Sr3w/0f01cc76a84affc8435c3c79e12c1b90/image.png)\nFigure 1\n\n### Types of Trees\n\nThe different types of trees in data structure based on their properties : general tree, binary tree, binary search tree, AVL tree, red-black tree, splay tree, and B-tree.  \n\n#### General tree:\nIn this tree its node can have 0 to N number of nodes, in which every node has no degree restrictions. Mainly, a general tree does not have ordered nodes. Hence its subtree will also be unordered.\n\n![image](//images.contentful.com/piwi0eufbb2g/4A4iu2vrAOkh6QlWpwWAzm/967d4b49c63572a1c8c6472d3a38839f/image.png)\nFigure 2\n\n#### Binary tree:\nIt is a recursive tree in which each node can have two child nodes at most.\n\n##### Properties of binary trees are:\nThe number of the total nodes on each level will be double the nodes present at the previous level. The last level will have the number of nodes present on all levels plus one.\n\n#### Binary search tree:\nIs a node-based binary tree but with different properties like:  \n\n1. Left subtree will contain the nodes with the values lesser than the value of its root node.\n\n2. Right subtree will contain nodes with values greater than the value of its root.\n\n3. The left and right subtrees should be binary trees in themselves.\n\n![image](//images.contentful.com/piwi0eufbb2g/3DPH99L4wJDoXwl9j94lKr/739a3dc3da0bf4f7885c2ba293d636fc/image.png)\nFigure 3\n\n#### AVL tree:\nIt satisfies both binary tree and binary search tree properties. This tree is a self-balancing tree which was invented by the mathematician **Adelson Velsky Lindas.**  The self-balancing property says that the difference between the height of the left and right subtree should not be more than one and it is implemented on all the nodes.\n\n![image](//images.contentful.com/piwi0eufbb2g/4vWVSkAsBVL4oJahIZhzLS/2010ae502bd771b646353fd3a84bfa87/image.png)\nFigure 4\n\n### Properties of Trees and Terminologies\n\n#### Node\nBasic unit containing value and nodes pointing to left and right subtree.\n\n```\nCode : class Node {\n\nint data;\n\nNode left, right; //pointer to left and right subtree\n\n}\n```\n\n#### Root\nTopmost node in a tree; it is the ancestor of all the nodes in a tree.  \n\n#### Child\nAny node which is connected to another node when moving away from the root is called a child of its ancestor.\n\n#### Level\nTotal count of edges between current node and root of a tree plus one.\n\n#### Leaf\nAny node which doesn't have any child.\n\n#### Edge\nLink between the two different nodes which does not lead to a cycle.\n\n#### Height\nThe longest path which can be drawn between root node and leaf node.\n\n#### Breadth\nTotal number of leaf nodes present in a tree.\n\n#### Degree\nThe count of child nodes that exist for a node is the degree of a  node.\n\n### Tree Uses in the Real World\nTrees are used widely in databases to implement indexing, to implement dictionaries, for quick pattern searching, and finding the shortest distance. Binary trees are used for fast searching and sorting data.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Y1AOG1YXQlhTmMHfBYvPz","type":"Asset","createdAt":"2021-09-21T10:12:41.521Z","updatedAt":"2021-09-21T10:12:41.521Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"localization example app","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4Y1AOG1YXQlhTmMHfBYvPz/837841b4bfc581f036b8db3c2084ffe8/Banner.png","details":{"size":22355,"image":{"width":455,"height":355}},"fileName":"Banner.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":8,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1ViiHZFGcwDFMBCADZLDpF"}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6MjqIZWyvLjThdmam9nIOh","type":"Entry","createdAt":"2021-10-29T08:54:49.485Z","updatedAt":"2024-09-06T04:55:03.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":45,"revision":8,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Kosaraju's Algorithm for Strongly Connected Components","slug":"kosarajus-algorithm-for-strongly-connected-components","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["SCC","C++"],"creationDate":"2021-10-29","readTime":"11min","content":"If we can reach every vertex of a component from every other vertex in that component then it is called a Strongly Connected Component (SCC). Single node is always a SCC. \n\nThe graph below is a basic example of SCC, as it has four SCCs each contained in its own shape.\n\n![image](//images.contentful.com/piwi0eufbb2g/6dwSDyTmfxRrUiE2I3t55N/8e3bb9e7cc56c1c3809f062e3aab2087/image.png)\n\nTo find SCCs we have two algorithms, **Tarjan’s and Kosaraju’s algorithms.** In this article, we are going to cover Kosaraju’s  algorithm. To learn more about **Tarjan’s algorithm** check out [this article](https://www.topcoder.com/thrive/articles/tarjans-algorithm-for-strongly-connected-components).\n\n### Brute Force Method\n\nWe can use the Floyd Warshall algorithm to compute the distance between every two vertices, then check if the distance between any two pairs is infinity. This means both are unreachable, except for the fact that it might be a self-loop. But, it has a time complexity of about O(V3), which we cannot afford in most of the scenarios.\n\n### Kosaraju’s Algorithm\n\nBefore we deep dive into Kasaraju’s algorithm, we must take a note on reversing all the edges of a graph. The type of graph won’t change, as a SCC will still remain a SCC.\nOnly the direction between components is reversed. This property is used in our article to detect SCCs.\n\n![image](//images.contentful.com/piwi0eufbb2g/6CKpwDhLzjKHnN0QxbWCEN/e0ca2e329287f15eedd4e031eba78905/image.png)\n\nThe transpose graph property is why Kosaraju’s algorithm works successfully to search SCCs.\n\nBelow you will see that if we start DFS on the original graph from any node in SCC1 we will be able to reach all the nodes in all the three components, as all are strongly connected components and there is an outgoing edge from the first node to SCCs.\nBut, if we try doing DFS on the transposed graph from any node in SCC1 we will only be able to reach all nodes in the SCC1 component as there is no outgoing edge from one SCC to another. So, to reach the other SCC we have to make a manual jump. When we do this we can deduce that the last component was a strongly connected component. Now we start our counter and do the above steps again to get the remaining SCCs.\n\n![image](//images.contentful.com/piwi0eufbb2g/17dKcJeNCtZwsYYDkVf8VY/d7c51985f796647021780d985afff987/image.png)\n\n**PSEUDOCODE:**\n\n-   Perform DFS traversal of the graph. Push node to stack before returning.\n\n-   Find the transpose graph by reversing the edges.\n\n-   Pop nodes one by one from the stack and again to DFS on the modified graph. \n\nLet’s show an example to support our algorithm:\n\n![image](//images.contentful.com/piwi0eufbb2g/6oUnkJaqwSOwrkEAbLAho3/d4aa587a030f9e870abc88e993cc0e2a/image.png)\n\nWe will begin DFS at 0 on the above graph and traverse every outgoing edge from each node that is unvisited. For visiting information we will make a visited array, and we should also maintain a stack to store the nodes in the order of which we exhausted their outgoing edges. Now we will see the result:\n\n![image](//images.contentful.com/piwi0eufbb2g/3ClZTtAmFjkwFR2jFmkUiv/56e7fa90f1eef283e2cc9e7eb4e1e3bc/image.png)\n\nNow we pop the stack one by one and do DFS on the modified/traversed graph while popping nodes. At the end of each successful DFS we will have an SCC.\n\nNow go ahead and perform this. For the sake of the article I won’t be illustrating it (might take too many pages), I will just show the final result. Here you’ll see each SCC colored differently. We will do the steps the same as the previous one, but the next node to traverse will be given by stack. Ignore those stack elements which have already been considered in previous SCCs.\n\n![image](//images.contentful.com/piwi0eufbb2g/1TE2fX2imobJziKfSHRdF8/83f5a74f7bccfee976af2e635844226d/image.png)\n\n### Code Implementation:\n```cpp\n#include <bits/stdc++.h>\n\n#define MAX_N 20001\n#define ll long long int\nusing namespace std;\nint n, m;\n\nstruct Node\n{\n    vector<int> adj;\n    vector<int> rev_adj;\n};\n\nNode g[MAX_N];\n\nstack<int> S;\nbool visited[MAX_N];\n\nint component[MAX_N];\nvector<int> components[MAX_N];\nint numComponents;\n\nvoid dfs_1(int x){\n    visited[x] = true;\n    for (int i=0;i<g[x].adj.size();i++)\n    {\n        if (!visited[g[x].adj[i]]) dfs_1(g[x].adj[i]);\n    }\n    S.push(x);\n}\n\nvoid dfs_2(int x){\n    printf(\"%d \", x);\n    component[x] = numComponents;\n    components[numComponents].push_back(x);\n    visited[x] = true;\n    for (int i=0;i<g[x].rev_adj.size();i++)\n    {\n        if (!visited[g[x].rev_adj[i]]) dfs_2(g[x].rev_adj[i]);\n    }\n}\n\nvoid Kosaraju()\n{\n    for (int i=0;i<n;i++)\n        if (!visited[i]) dfs_1(i);\n\n    for (int i=0;i<n;i++)\n        visited[i] = false;\n\n    while (!S.empty()){\n        int v = S.top(); S.pop();\n        if (!visited[v])\n        {\n            printf(\"Component %d: \", numComponents);\n            dfs_2(v);\n            numComponents++;\n            printf(\"\\n\");\n        }\n    }\n}\n\nint main()\n{\n\n    cin >> n >> m;\n    int a,b;\n    while(m--){\n        cin >> a >> b;\n        g[a].adj.push_back(b);\n        g[b].rev_adj.push_back(a);\n    }\n\n    Kosaraju();\n    printf(\"Total number of components: %d\\n\", numComponents);\n\n    return 0;\n}\n```\n\n__Input:__\n```\n8 10\n0 1\n1 2\n2 0\n2 3\n3 4\n4 5\n5 6\n6 7\n4 7\n6 4\n```\n\n__Output:__\n```\nComponent 0: 0 2 1 \nComponent 1: 3 \nComponent 2: 4 6 5 \nComponent 3: 7 \nTotal number of components: 4\n```\n\nKosaraju's algorithm aims to find all strongly connected components (SCCs) of a given input graph. It is less effective than Tarjan’s, as here we have two different types of DFS calling, but it is more intuitive.\n\nComplexity: __O(V + E)__","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1bxxqiFLlqQFQecucXOhlA","type":"Asset","createdAt":"2021-10-29T08:31:18.687Z","updatedAt":"2021-10-29T08:54:46.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"kosaraju","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1bxxqiFLlqQFQecucXOhlA/f704fa808ac674f01803d0748be0d898/kosaraju.jpeg","details":{"size":37251,"image":{"width":926,"height":355}},"fileName":"kosaraju.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":5,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"Yq88cq14TQ3XuFPRYqdQu","type":"Entry","createdAt":"2021-10-07T09:56:26.406Z","updatedAt":"2022-07-27T14:36:05.190Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":118,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Tarjan’s Algorithm for Strongly Connected Components","slug":"tarjans-algorithm-for-strongly-connected-components","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["SCC","Tarjan","Low link"],"creationDate":"2021-10-07","readTime":"9min","content":"Strongly connected components (SCCs) can be thought of as self-contained cycles within a directed graph where every vertex in a given cycle can reach every other vertex in the same cycle.\n\nIf you look at the graph below, you will find that it has four SCCs, each has its own self-contained cycle and for each component, there is no way to find a path that leaves a component and returns back. This property ensures that SCCs in a graph are unique.\n\n![image](//images.contentful.com/piwi0eufbb2g/15p4U9s2ie9Md3PcGMIs3P/34dcbfcb2ee2483a67a8f2924227f734/image.png)\n\nTo find SCCs we have two algorithms at hand, Tarjan’s and Kosaraju’s algorithms. In this article we are going to cover Tarjan’s algorithm.\n\n### Low-Link Values\n\nBefore we jump to Tarjan’s algorithm, we must have an understanding of low-link values.\n\nThe low-link value of a node is the smallest node ID reachable from that node when doing a depth-first search (DFS), including itself.\n\nThere is a catch with doing a DFS on the graph, as it is highly dependent on the traversal order of the DFS, which is effectively random.\n\nWe are going to prove our above statement by giving you some examples:\n\n![image](//images.contentful.com/piwi0eufbb2g/1RuYR0FmiHXmFSVyC6griS/e9130e69d68bd923c83b99d3fd0b5f55/image.png)\n\nIn the above graph, we labeled it with some data and did the DFS on the 0th node, and let the DFS play and mark every node with its low-link value. After the graph is labeled it looks like this:\n\n![image](//images.contentful.com/piwi0eufbb2g/lKwKOYnOJsN8OLOULYKiu/9f3d56137b38f9f92b0876a876922704/image.png)\n\nSeeing the results we might feel that it’s working fine. But, to contradict our example, we will now label the nodes differently and start the DFS again from the 0th node. Let’s see how it pans out.\n\n![image](//images.contentful.com/piwi0eufbb2g/Krd8BzrvT6Ts6KgAMxetb/c9e686902f959a13e1e25ffbf969a7c5/image.png)\n\nAs we can see all the nodes have the same low-link value, but there are multiple SCCs.\n\n__Note__: Depending on where the DFS starts, and the order in which nodes/edges are visited, the low-link values for identifying SCCs could be wrong.\n\nSo, to make it work, we have to use an invariant that prevents SCCs from interfering with the low-link value of other SCCs.\n\n### Stack invariant\n\n#### Algorithm:\nTo cope with the random traversal order of the DFS, Tarjan’s algorithm maintains a stack of valid nodes from which to update low-link values. Nodes are added to the stack of valid nodes as they are explored for the first time. Nodes are removed from the stack each time a complete SCC is found.\n\n#### Update Condition for Low-Link\nIf u and v are nodes in a graph and we were currently exploring u, then our new low-link update condition is:\nTo update node u to node v low-link there has to be a path of edges from u to v and node v must be on the stack.\n\n#### Time Complexity\nWe are going to update low-link values on the fly  during the DFS so we can get a linear O(V+E) time complexity.\n\nCode:\n\n```c++\n#include<iostream>\n#include<stack>\n#define v 5\nusing namespace std;\n\nint graph[v][v];\n\nint min(int a, int b) {\n   return (a<b)?a:b;\n}\n\nvoid findComponent(int u, int disc[], int lowLink[], stack<int>&stk, bool stkItem[]) {\n   static int time = 0;\n   disc[u] = lowLink[u] = ++time;    \n   stk.push(u);\n   stkItem[u] = true;    \n\n   for(int v = 0; v<v; v++) {\n      if(graph[u][v]) {\n         if(disc[v] == -1) {   \n            findComponent(v, disc, lowLink, stk, stkItem);\n            lowLink[u] = min(lowLink[u], lowLink[v]);\n         } else if(stkItem[v])    \n            lowLink[u] = min(lowLink[u], disc[v]);\n      }\n   }\n\n   int poppedItem = 0;\n   if(lowLink[u] == disc[u]) {\n      while(stk.top() != u) {\n         poppedItem = stk.top();\n         cout << poppedItem << \" \";\n         stkItem[poppedItem] = false;   \n         stk.pop();\n      }\n      poppedItem = stk.top();\n      cout << poppedItem <<endl;\n      stkItem[poppedItem] = false;\n      stk.pop();\n   }\n}\n\nvoid strongConComponent() {\n   int disc[v], lowLink[v];\n   bool stkItem[v];\n   stack<int> stk;\n\n   for(int i = 0; i<v; i++) {    \n      disc[i] = lowLink[i] = -1;\n      stkItem[i] = false;\n   }\n\n   for(int i = 0; i<v; i++)    \n      if(disc[i] == -1)\n         findComponent(i, disc, lowLink, stk, stkItem);\n}\n\nint main() {\n   strongConComponent();\n}\n```\n\n### Overview \n\nMark the ID of each node as unvisited.\nStart DFS. Upon visiting a node, assign it an ID and a low-link value. Also, mark current nodes as visited and add them to a seen stack. \nOn DFS callback, if the previous node is on the stack, then min the current node’s low-link value with the last node’s low-link value. After visiting all neighbors, if the current node started a connected component, then pop nodes off the stack until the current node is reached.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1WA4wbSfAiGt7pf2mprZ4U","type":"Asset","createdAt":"2021-10-07T09:47:05.963Z","updatedAt":"2021-10-07T09:47:05.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"tarjan","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1WA4wbSfAiGt7pf2mprZ4U/ad45125680ba3a7033501dd8ca75fd5e/tarjan.jpeg","details":{"size":34129,"image":{"width":990,"height":355}},"fileName":"tarjan.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":6,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3KntZ6sSEjLlQmtIa4hbA2"}},{"sys":{"type":"Link","linkType":"Entry","id":"64dCpVTbATrysnaZ8MEmMz"}},{"sys":{"type":"Link","linkType":"Entry","id":"5IShlfU89ow1d1M8sujBp3"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7Emo2c6hFbIUfF9cBScXj3","type":"Entry","createdAt":"2020-02-20T09:27:12.700Z","updatedAt":"2021-11-06T03:24:31.062Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":418,"revision":56,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Introduction to Graphs and Their Data Structures part 1: Recognizing and Representing a Graph","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Graph","Data structure","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505841)\n<br/>\n<a href=\"#Introduction\">Introduction</a>\n<a href=\"#Recognizinggraphproblem\">Recognizing a graph problem</a>\n<a href=\"#Representinggraphandkeyconcepts\">Representing a graph and key concepts</a>\n<a href=\"#Singlylinkedlists\">Singly linked lists</a>\n<a href=\"#Trees\">Trees</a>\n<a href=\"#Graphs\">Graphs</a>\n<a href=\"#Arrayrepresentation\">Array representation</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nGraphs are a fundamental data structure in the world of programming, and this is no less so on topcoder. Usually appearing as the hard problem in Division 2, or the medium or hard problem in Division 1, there are many different forms solving a graph problem can take. They can range in difficulty from finding a path on a 2D grid from a start location to an end location, to something as hard as finding the maximum amount of water that you can route through a set of pipes, each of which has a maximum capacity (also known as the maximum-flow minimum-cut problem – which we will discuss later). Knowing the correct data structures to use with graph problems is critical. A problem that appears intractable may prove to be a few lines with the proper data structure, and luckily for us the standard libraries of the languages used by topcoder help us a great deal here!\n<br/><br/>\n<a name=\"Recognizinggraphproblem\" id=\"Recognizinggraphproblem\"></a>\n### Recognizing a graph problem\nThe first key to solving a graph related problem is recognizing that it is a graph problem. This can be more difficult than it sounds, because the problem writers don’t usually spell it out for you. Nearly all graph problems will somehow use a grid or network in the problem, but sometimes these will be well disguised. Secondly, if you are required to find a path of any sort, it is usually a graph problem as well. Some common keywords associated with graph problems are: vertices, nodes, edges, connections, connectivity, paths, cycles and direction. An example of a description of a simple problem that exhibits some of these characteristics is:\n\\\n\"Bob has become lost in his neighborhood. He needs to get from his current position back to his home. Bob’s neighborhood is a 2 dimensional grid, that starts at (0, 0) and (width – 1, height – 1). There are empty spaces upon which bob can walk with no difficulty, and houses, which Bob cannot pass through. Bob may only move horizontally or vertically by one square at a time.\n\\\nBob’s initial position will be represented by a ‘B’ and the house location will be represented by an ‘H’. Empty squares on the grid are represented by ‘.’ and houses are represented by ‘X’. Find the minimum number of steps it takes Bob to get back home, but if it is not possible for Bob to return home, return -1.\n\\\nAn example of a neighborhood of width 7 and height 5:\n<br/>\n```\n\n.X.X.XX\n.H…\n…X…\n…X.\"\n```\n\\\nOnce you have recognized that the problem is a graph problem it is time to start building up your representation of the graph in memory.\n<br/><br/>\n<a name=\"Representinggraphandkeyconcepts\" id=\"Representinggraphandkeyconcepts\"></a>\n### Representing a graph and key concepts\nGraphs can represent many different types of systems, from a two-dimensional grid (as in the problem above) to a map of the internet that shows how long it takes data to move from computer A to computer B. We first need to define what components a graph consists of. In fact there are only two, nodes and edges. A node (or vertex) is a discrete position in the graph. An edge (or connection) is a link between two vertices that can be either directed or undirected and may have a cost associated with it. An undirected edge means that there is no restriction on the direction you can travel along the edge. So for example, if there were an undirected edge from A to B you could move from A to B or from B to A. A directed edge only allows travel in one direction, so if there were a directed edge from A to B you could travel from A to B, but not from B to A. An easy way to think about edges and vertices is that edges are a function of two vertices that returns a cost. We will see an example of this methodology in a second.\n\\\nFor those that are used to the mathematical description of graphs, a graph G = {V, E} is defined as a set of vertices, V, and a collection of edges (which is not necessarily a set), E. An edge can then be defined as (u, v) where u and v are elements of V. There are a few technical terms that it would be useful to discuss at this point as well:\n\\\nOrder – The number of vertices in a graph\n\\\nSize – The number of edges in a graph\n<br/><br/>\n<a name=\"Singlylinkedlists\" id=\"Singlylinkedlists\"></a>\n### Singly linked lists\nAn example of one of the simplest types of graphs is a singly linked list! Now we can start to see the power of the graph data structure, as it can represent very complicated relationships, but also something as simple as a list.\n\\\nA singly linked list has one “head” node, and each node has a link to the next node. So the structure looks like this:\n<br/>\n```\nstructure node\n[node] link;\n[data]\nend\n\nnode head;\n```\n\\\nA simple example would be:\n<br/>\n```\nnode B, C;\nhead.next = B;\nB.next = C;\nC.next = null;\n```\n\\\nThis would be represented graphically as head -> B -> C -> null. I’ve used null here to represent the end of a list.\n\\\nGetting back to the concept of a cost function, our cost function would look as follows:\n<br/>\n```\ncost(X, Y) := if (X.link = Y) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nThis cost function represents the fact that we can only move directly to the link node from our current node. Get used to seeing cost functions because anytime that you encounter a graph problem you will be dealing with them in some form or another! A question that you may be asking at this point is “Wait a second, the cost from A to C would return not possible, but I can get to C from A by stepping through B!” This is a very valid point, but the cost function simply encodes the direct cost from a node to another. We will cover how to find distances in generic graphs later on.\n\\\nNow that we have seen an example of the one of the simplest types of graphs, we will move to a more complicated example.\n<br/><br/>\n<a name=\"Trees\" id=\"Trees\"></a>\n### Trees\nThere will be a whole section written on trees. We are going to cover them very briefly as a stepping-stone along the way to a full-fledged graph. In our list example above we are somewhat limited in the type of data we can represent. For example, if you wanted to start a family tree (a hierarchal organization of children to parents, starting from one child) you would not be able to store more than one parent per child. So we obviously need a new type of data structure. Our new node structure will look something like this:\n<br/>\n```\nstructure node\n[node] mother, father;\n[string] name\nend\n\nnode originalChild;\n```\n\\\nWith a cost function of:\n<br/>\n```\ncost(X, Y) := if ((X.mother = Y) or (X.father = Y)) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nHere we can see that every node has a mother and father. And since node is a recursive structure definition, every mother has mother and father, and every father has a mother and father, and so on. One of the problems here is that it might be possible to form a loop if you actually represented this data structure on a computer. And a tree clearly cannot have a loop. A little mind exercise will make this clear: a father of a child is also the son of that child? It’s starting to make my head hurt already. So you have to be very careful when constructing a tree to make sure that it is truly a tree structure, and not a more general graph. A more formal definition of a tree is that it is a connected acyclic graph. This simply means that there are no cycles in the graph and every node is connected to at least one other node in the graph.\n\\\nAnother thing to note is that we could imagine a situation easily where the tree requires more than two node references, for example in an organizational hierarchy, you can have a manager who manages many people then the CEO manages many managers. Our example above was what is known as a binary tree, since it only has two node references. Next we will move onto constructing a data structure that can represent a general graph!\n<br/><br/>\n<a name=\"Graphs\" id=\"Graphs\"></a>\n### Graphs\nA tree only allows a node to have children, and there cannot be any loops in the tree, with a more general graph we can represent many different situations. A very common example used is flight paths between cities. If there is a flight between city A and city B there is an edge between the cities. The cost of the edge can be the length of time that it takes for the flight, or perhaps the amount of fuel used.\n\\\nThe way that we will represent this is to have a concept of a node (or vertex) that contains links to other nodes, and the data associated with that node. So for our flight path example we might have the name of the airport as the node data, and for every flight leaving that city we have an element in neighbors that points to the destination.\n<br/>\n```\nstructure node\n[list of nodes] neighbors\n[data]\nend\n\ncost(X, Y) := if (X.neighbors contains Y) return X.neighbors[Y];\nelse “Not possible”\n\nlist nodes;\n```\n\\\nThis is a very general way to represent a graph. It allows us to have multiple edges from one node to another and it is a very compact representation of a graph as well. However the downside is that it is usually more difficult to work with than other representations (such as the array method discussed below).\n<br/><br/>\n<a name=\"Arrayrepresentation\" id=\"Arrayrepresentation\"></a>\n### Array representation\nRepresenting a graph as a list of nodes is a very flexible method. But usually on topcoder we have limits on the problems that attempt to make life easier for us. Normally our graphs are relatively small, with a small number of nodes and edges. When this is the case we can use a different type of data structure that is easier to work with.\n\\\nThe basic concept is to have a 2 dimensional array of integers, where the element in row i, at column j represents the edge cost from node i to j. If the connection from i to j is not possible, we use some sort of sentinel value (usually a very large or small value, like -1 or the maximum integer). Another nice thing about this type of structure is that we can represent directed or undirected edges very easily.\n\\\nSo for example, the following connection matrix:\n<br/>\n```\nA B C\nA 0 1 5\nB -1 0 1\nC -1 -1 0\n```\n\\\nWould mean that node A has a 0 weight connection to itself, a 1 weight connection to node B and 5 weight connection to node C. Node B on the other hand has no connection to node A, a 0 weight connection to itself, and a 1 weight connection to C. Node C is connected to nobody. This graph would look like this if you were to draw it:\n<br/><div style=\"text-align:center;\">\n![graph](//images.ctfassets.net/piwi0eufbb2g/39urFkSmHSQE5Y9thpTSbl/89c592184413c140e1b8706429dff7d1/graph.gif)\n</div>\nThis representation is very convenient for graphs that do not have multiple edges between each node, and allows us to simplify working with the graph.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Introduction%20to%20Graphs%20and%20Their%20Data%20Structures%20part%202:%20Searching%20a%20Graph)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"7dpViJNiGS7Fflpf8x767t"}}],"upvotes":19,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}},{"sys":{"type":"Link","linkType":"Entry","id":"ypU3M6AxrYYmErQqodsVr"}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2FyFPuf9ftL4DguU4YFcoe","type":"Entry","createdAt":"2020-02-19T12:59:58.263Z","updatedAt":"2022-07-11T04:33:32.572Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":148,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Find a Solution","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["SRM","Flood Fill","Problem","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"30 min","content":"[Discuss this article in the forums.](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505843)\n<br/>\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#straightforward\">Straight-forward problems that don’t require a special technique</a>\n<a href=\"#bfs\">Breadth First Search (BFS)</a>\n<a href=\"#floodfill\">Flood Fill</a><\n<a href=\"#bruteNback\">Brute Force and Backtracking</a>\n<a href=\"#bruteforce\">Brute Force</a>\n<a href=\"#backtracking\">Backtracking</a>\n<a href=\"#dp\">Dynamic Programming</a>\n<a href=\"#harddrills\">Hard Drills</a>\n<a href=\"#maximumflow\">Maximum Flow</a>\n<a href=\"#optimal\">Optimal Pair Matching</a>\n<a href=\"#lp\">Linear Programming (Simplex)</a>\n<a href=\"#conclusion\">Conclusion</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nWith many Topcoder problems, the solutions may be found instantly just by reading their descriptions. This is possible thanks to a collection of common traits that problems with similar solutions often have. These traits serve as excellent hints for experienced problem solvers that are able to observe them. The main focus of this article is to teach the reader to be able to observe them too.\n\\\n<a name=\"straightforward\" id=\"straightforward\"></a> __Straight-forward problems that don’t require any special technique (e.g. simulation, searching, sorting etc.)__\n\tIn most cases, these problems will ask you to perform some step by step, straight-forward tasks. Their constraints are not high, and not too low. In most cases the first problems (the easiest ones) in topcoder Single Rounds Matches are of this kind. They test mostly how fast and properly you code, and not necessarily your algorithmic skills.\n\\\nMost simple problems of this type are those that ask you just to execute all steps described in the statement.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BusinessTasks](http://community.topcoder.com/stat?c=problem_statement&pm=1585&rd=6535) – SRM 236 Div 1:__\nN tasks are written down in the form of a circular list, so the first task is adjacent to the last one. A number n is also given. Starting with the first task, move clockwise (from element 1 in the list to element 2 in the list and so on), counting from 1 to n. When your count reaches n, remove that task from the list and start counting from the next available task. Repeat this procedure until one task remains. Return it.\n</div>\n\\\nFor N&lt;=1000 this problem is just a matter of coding, no special algorithm is needed – do this operation step by step until one item is left. Usually these types of problems have a much smaller N, and so we’ll not consider cases where N is very big and for which complicated solution may be needed. Remember that in topcoder competitions even around 100 millions sets of simple operations (i.e. some multiplications, attributions or if statements) will run in allowed time.\n\\\nThis category of problems also includes those that need some simple searches.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[TallPeople](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2923&amp;rd=5854) – SRM 208 Div 1:__\nA group of people stands before you arranged in rows and columns. Looking from above, they form an R by C rectangle of people. Your job is to return 2 specific heights – the first is computed by finding the shortest person in each row, and then finding the tallest person among them (the \"tallest-of-the-shortest\"); and the second is computed by finding the tallest person in each column, and then finding the shortest person among them (the \"shortest-of-the-tallest\").\n</div>\n\\\nAs you see this is a really simple search problem. What you have to do is just to follow the steps described in the statement and find those 2 needed heights. Other TC problems may ask you to sort a collection of items by respecting certain given rules. These problems may be also included in this category, because they too are straight-forward – just sort the items respecting the rules! You can do that with a simple O(N^2) sorting algorithm, or use standard sorting algorithm that exist in your coding language. It’s just a matter of coding.\n<br/>\n__Other example(s):__\n\t__[MedalTable](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2922&amp;rd=5855) – SRM 209 Div 1__.\n<br/>\n\\\n<a name=\"bfs\" id=\"bfs\"></a> __Breadth First Search (BFS)__\n\nProblems that use BFS usually ask to find the fewest number of steps (or the shortest path) needed to reach a certain end point (state) from the starting one. Besides this, certain ways of passing from one point to another are offered, all of them having the same cost of 1 (sometimes it may be equal to another number). Often there is given a N x M table (formed of N lines and M columns) where certain cells are passable and others are impassable, and the target of the problem is to find the shortest time/path needed to reach the end point from the start one. Such tables may represent mazes, maps, cities, and other similar things. These may be considered as classical BFS problems. Because BFS complexity is in most cases linear (sometimes quadratic, or N logN), constraints of N (or M) could be high – even up to 1 million.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[SmartWordToy](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3935&amp;rd=6532) – SRM 233 Div 1:__\nA word composed of four Latin lowercase letters is given. With a single button click you can change any letter to the previous or next letter in alphabetical order (for example ‘c’ can be changed to ‘b’ or ‘d’). The alphabet is circular, thus ‘a’ can become ‘z’, and ‘z’ can become ‘a’ with one click.<br/>\nA collection of constraints is also given, each defining a set of forbidden words. A constraint is composed of 4 strings of letters. A word is forbidden if each of its characters is contained in corresponding string of a single constraint, i.e. first letter is contained in the first string, the second letter – in the second string, and so on. For example, the constraint \"lf a tc e\" defines the words \"late\", \"fate\", \"lace\" and \"face\".<br/>\nYou should find the minimum number of button presses required to reach the word finish from the word start without passing through forbidden words, or return -1 if this is not possible.\n</div>\n\\\n__Problem hints:__\n* Words can be considered as states. There are at most 26^4 different words composed of 4 letters (thus a linear complexity will run in allowed time).\n* There are some ways to pass from one state to another.\n* The cost of passing from a state to another is always 1 (i.e. a single button click).\n* You need to find the minimum number of steps required to reach the end state from start state.\n\nEverything indicates us that it’s a problem solved by the help of a BFS. Similar things can be found in any other BFS problems. Now let’s see an interesting case of BFS problems.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[CaptureThemAll](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2915&amp;rd=5853) – SRM 207 Div 2 (3rd problem):__\nHarry is playing a chess game. He has one knight, and his opponent Joe has a queen and a rook. Find the minimum number of steps that Harry’s knight has to jump so that it captures both the queen and the rook.\n</div>\n\n__Problem hints:__ At first sight this may seem like dynamic programming or backtracking. But as always, take a look into the text of the statement. After a while you should observe the following things: \n\n* A table is given.\n* The knight can jump from one cell to some of its neighbors.\n* The cost of passing from a cell to another is always 1 (just one jump).\n* You need to find the minimum number of steps (jumps).\n\nGiven this information we can see that the problem can be easily solved by the help of BFS. Don’t get confused by the fact that connected points are represented by unconnected cells. Think of cells as points in a graph, or states (whatever you want) – and in order to pass from one point to another, the knight should be able to jump from the first to the second point.\n\nNotice again that the most revealing hint about the BFS solution is the cost of 1 for any jump.\n\nTrain yourself in finding the hints of a BFS problem in following examples:\n\n__Other example(s):__\n__[RevolvingDoors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3064&amp;rd=5869) – SRM 223 Div 1__.\n__[WalkingHome](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3444&amp;rd=5868) – SRM 222 Div 1__.\n__[TurntableService](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3117&amp;rd=5865) – SRM 219 Div 1__.\n<br/>\n\\\n<a name=\"floodfill\" id=\"floodfill\"></a> __Flood Fill__\nSometimes you may encounter problems that are solved by the help of Flood Fill, a technique that uses BFS to find all reachable points. The thing that makes them different from BFS problems described above is that a minimum path/cost is not needed.\nFor example, imagine a maze where 1 represents impassable cells and 0 passable cells. You need to find all cells that are reachable from the upper-left corner. The solution is very simple – take one-by-one a visited vertex, add its unvisited neighbors to the queue of visited vertices and proceed with the next one while the queue is still populated. Note that in most cases a DFS (Depth First Search) will not work for such problems due to stack overflows. Better use a BFS. For inexperienced users it may seem harder to implement, but after a little training it becomes a \"piece of cake\". A good example of such problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[grafixMask](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2998&amp;rd=5857) – SRM 211 Div 1:__\nA 400 x 600 bitmap is given. A set of rectangles covers certain parts of this bitmap (the corners of rectangles have integer coordinates). You need to find all contiguous uncovered areas, including their sizes.\n</div>\n\n__Problem hints:__ What do we have here?\n* A map (table)\n* Certain points are impassable (those covered by given rectangles)\n* Contiguous areas need to be found\n\nIt is easy to understand that a problem with such a statement needs a Flood Fill. Usually problems using it are very easy to detect.\n\\\n<a name=\"bruteNback\" id=\"bruteNback\"></a> __Brute Force and Backtracking__\nI have placed these 2 techniques in the same category because they are very similar.  Both do the same thing – try all possible cases (situations) and choose the best one, or count only those that are needed (depending on the problem). Practically, Backtracking is just more advanced and optimized than Brute Force. It usually uses recursion and is applied to problems having low constraints (for example N&lt;=20). </p>\n\\\n<a name=\"bruteforce\" id=\"bruteforce\"></a>\n__Brute Force__\nThere are many problems that can be solved by the help of a simple brute force. Note that the limits must not be high. How does a brute force algorithm work? Actually, it tries all possible situations and selects the best one. It’s simple to construct and usually simple to implement. If there is a problem that asks to enumerate or find all possible ways (situations) of doing a certain thing, and that doesn’t have high limits – then it’s most probably a brute force problem.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[GeneralChess](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2430&amp;rd=5072) – SRM 197 Div 1:__\nYou are given some knights (at most 8), with their positions on the table (-10000&lt;=x, y&lt;=10000). You need to find all positions to place another one, so that it threatens all given pieces. \n</div>\n\n__Problem hints:__ Well, this is one of the easiest examples. So which are the hints of this statement?\n* You need to find all possible situations (positions) that satisfy a certain rule (threatens all given pieces).\n* The limits are very low – only 8 knights are at most given.\n\nIt’s a common Brute Force problem’s statement. Note that x and y limits are not relevant, because you need only try all positions that threaten one of the knights. For each of these positions see if the knight placed at that position threatens all others too.\n\nAnother interesting problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[LargestCircle](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3005&amp;rd=5858) – SRM 212 Div 2 (3rd problem):__\nGiven a regular square grid, with some number of squares marked, find the largest circle you can draw on the grid that does not pass through any of the marked squares. The circle must be centered on a grid point (the corner of a square) and the radius must be an integer. Return the radius of the circle.\n<br/> The size of the grid is at most 50.\n</div>\n\n__Problem hints:__ And again one of the most important hints is the low limit of the size of the grid – only 50. This problem is possible to be solved with the help of the Brute Force because for each cell you can try to find the circle whose center is situated in that cell and that respects the rules. Among all of these circles found, select the one that has the greatest radius.\n\nComplexity analysis: there are at most 50×50 cells, a circle’s radius is an integer and can be at most 25 units, and you need a linear time (depending on your implementation) for searching the cells situated on the border of the circle. Total complexity is low and thus you can apply a simple Brute Force here.\n\n__Other example(s):__\n__[Cafeteria](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3080&amp;rd=6518) - SRM 229 Div 1__\n__[WordFind](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3972&amp;rd=6521) - SRM 232 Div 1__\n\n<a name=\"backtracking\" id=\"backtracking\"></a> __Backtracking__\nThis technique may be used in many types of problems.  Just take a look at the limits (N, M and other main parameters). They serve as the main hint of a backtrack problem. If these are very small and you haven’t found a solution that’s easier to implement – then just don’t waste your time on searching it and implement a straight-forward backtracking solution.\n\nUsually problems of this kind ask you to find (similarly to Brute Force):\n1. Every possible configuration (subset) of items. These configurations should respect some given rules.\n2. The \"best\" configuration (subset) that respects some given rules.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BridgeCrossing](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1599&amp;rd=4535) – SRM 146 Div 2 (3rd problem):__\nA group of people is crossing an old bridge. The bridge cannot hold more than two people at once. It is dark, so they can’t walk without a flashlight, and they only have one flashlight! Furthermore, the time needed to cross the bridge varies among the people in the group. When people walk together, they always walk at the speed of the slowest person. It is impossible to toss the flashlight across the bridge, so one person always has to go back with the flashlight to the others. What is the minimum amount of time needed to get all the people across the bridge?\n<br/> There are at most 6 people.\n</div>\n\n__Problem hints:__\n* First look at the constraints – there are at most ONLY 6 people! It’s enough for generating all possible permutations, sets etc.\n* There are different possible ways to pass the people from one side to another and you need to find the best one.\n\nThis is of course a problem solved with a backtracking: at the beginning choose any 2 people to pass the bridge first, and after that at each step try to pass any of those that have been left on the start side. From all these passages select the one that needs the smallest amount of time. Note that among persons that have passed over the bridge, the one having the greatest speed should return (it’s better than returning one having a lower speed). This fact makes the code much easier to implement. After having realized these things – just code the solution. There may be others – but you will lose more time to find another than to code this one.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[MNS](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – SRM 148 Div 1:__\n9 numbers need to be arranged in a magic number square. A magic number square is a square of numbers that is arranged such that every row and column has the same sum. You are given 9 numbers that range from 0 to 9 inclusive. Return the number of distinct ways that they can be arranged in a magic number square. Two magic number squares are distinct if they differ in value at one or more positions. \n</div>\n\n__Problem hints:__ Only 9 numbers are given at most; and every distinct way (configuration) to arrange the numbers so that they form a magic number square should be found.\n\nThese are the main properties of a Backtracking problem. If you have observed them – think about the code. You can generate all permutations of numbers and for each of them check if it forms a magic square. If so – add it to the answer. Note that it must be unique. A possible way to do that – is to have a list of earlier found configurations, thus for each new magic square check if it exists in that list and if it doesn’t – add it to the answer. There will not be many distinct magic squares, thus no additional problems will appear when applying this method.\n\n__Other example(s):__\n\n__[WeirdRooks](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3998&amp;rd=6533) - SRM 234 Div 1__\n\\\n<a name=\"dp\" id=\"dp\"></a> __Dynamic Programming__\nQuite a few problems are solved with the help of this technique. Knowing how to detect this type of problem can be very valuable.  However in order to do so, one has to have some experience in dynamic programming. Usually a DP problem has some main integer variables (e.g. N) which are neither too small, nor too big – so that a usual DP complexity of N^2, N^3 etc. fits in time. Note that in the event that N is very small (for TC problems usually less than 30) – then it is likely the problem is not a DP one. Besides that there should exist states and one or more ways (rules) to reach one greater state from another lower one.  In addition, greater states should depend only upon lower states. What is a so-called state? It’s just a certain configuration or situation. To better understand dynamic programming, you may want to read [this article](http://community.topcoder.com/tc?module=Static&amp;d1=tutorials&amp;d2=dynProg).\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nLet’s analyze a simple classic DP problem:<br/>\nGiven a list of N coins with their values (V1, V2, … ,VN), and the total sum S. Find the minimum number of coins the sum of which is S (you can use as many coins of one type as you want), or report that it’s not possible to select coins in such a way that they sum up to S.<br/>\nLet N &lt;= 1,000 and S &lt;= 1,000.\n</div>\n\n__Problem hints:__\n* Two main integer variables are given (N and S). These are neither too small, nor are they too big (i.e. a complexity of N*S fits in time).\n* A state can be defined as the minimum number of coins needed to reach a certain sum.\n* A sum (state) i depends only on lower sums (states) j (j&lt;i).\n* By adding a coin to a certain sum – another greater sum is reached. This is the way to pass from one state to another.\n\nThus all properties of a DP problem are uncovered in this statement. Let’s see another (slightly harder) DP problem:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[ZigZag](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – 2003 TCCC Semifinals 3:__\nA sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a zig-zag sequence. Given a sequence of integers, return the length of the longest subsequence that is a zig-zag sequence. A subsequence is obtained by deleting some number of elements (possibly zero) from the original sequence, leaving the remaining elements in their original order. Assume the sequence contains between 1 and 50 elements, inclusive. \n</div>\n\n__Problem hints:__\n* There are N numbers given (1&lt;=N&lt;=50), thus N isn’t too small, nor too big.\n* A state (i,d) can be defined as the length of the longest zig-zag subsequence ending with the i-th number, for which the number before the last one is smaller than it for d=0, and bigger for d=1.\n* A state i (i.e. a subsequence ending with the i-th number) depends only on lower states j (j&lt;i).\n* By adding a number to the end of a subsequence – another bigger (greater) subsequence is created. This is the way to pass from one state to another.\n\nAs you can see – this statement has almost the same traits (pattern) as in the previous problem. The most difficult part in identifying a DP problem statement is observing/seeing the states with the properties described above. Once you can do that, the next step is to construct the algorithm, which is out of the scope of this article.\n\n__Other example(s):__\n__[ChessMetric](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1592&amp;rd=4482) - 2003 TCCC Round 4__\n__[AvoidRoads](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1889&amp;rd=4709) - 2003 TCO Semifinals 4__\n__[FlowerGarden](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1918&amp;rd=5006) - 2004 TCCC Round 1__\n__[BadNeighbors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2402&amp;rd=5009) - 2004 TCCC Round 4__\n\\\n<a name=\"harddrills\" id=\"harddrills\"></a> __Hard Drills:__\n<a name=\"maximumflow\" id=\"maximumflow\"></a> __Maximum Flow__\n\nIn many cases it’s hard to detect a problem whose solution uses maximum flow.  Often you have to create/define graphs with capacities based on the problem statement.\n\nHere are some signs of a Maximum Flow problem:\n* Take a look at the constraints, they have to be appropriate for a O(N^3) or O(N^4) solution, i.e. N shouldn’t be greater than 500 in extreme cases (usually it’s less than 100).\n* There should be a graph with edges having capacities given, or you should be able to define/create it from data given in the statement.\n* You should be finding a maximum value of something.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nSample problem:<br/>\nYou are given a list of water pipes, each having a certain maximum water flow capacity. There are water pipes connected together at their extremities. <br/>\nYou have to find the maximum amount of water that can flow from start junction to end junction in a unit of time. <br/>\nLet N&lt;=100. <br/>\n</div>\n\nAs you can see – it’s a straight-forward maximum flow problem: water pipes represent edges of the graph, their junctions – vertices; and you have to find the maximum value of amount of water that can flow from start to end vertex in a unit of time.\n\\\n<a name=\"optimal\" id=\"optimal\"></a> __Optimal Pair Matching:__\nThese problems usually have a list of items (from a set A) for which other items (from a set B) should be assigned under some rules, so that all (or a maximum possible number of) items from set A have to each be assigned to a certain item from set B.\n\n__Mixed:__\nSome problems need other techniques in addition to network flows.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Parking](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3530&amp;rd=6535) - SRM 236 Div 1:__\nN cars and M parking lots are given. They are situated on a rectangular surface (represented by a table), where certain cells are impassable. You should find a way to assign each car to a parking lot, so that the greatest of the shortest distances from each car to its assigned parking lot is as small as possible. Each parking lot can have at most one car assigned to it. \n</div>\n__Problem hints:__ By reading this problem one can simply understand the main idea of the solution – it should be something similar to optimal pair matching, because each car (point from a set A) should be assigned to a parking lot (point from a set B) so that all are assigned and that there is at most one car assigned to a parking lot. Additionally, there can be cars that can’t reach certain parking lots, thus some pairs of points (one point from A and the other from B) are not connected. However a graph should be created for optimal pair matching. The way to make it is clear – an edge exists between a car and a parking lot if only there is a path between them, and its cost is equal to the shortest distance needed for the car to reach the parking lot. The next step of the solution is a binary search on the longest edge. Although it may be out of the scope of this article, I will provide a short explanation: At each step delete those edges of the initial graph that have costs greater than a certain value C (Note that you’ll have to save the initial graph’s state in order to repeat this step again for other C values). If it’s possible in this case to assign all the cars to parking lots – then take a smaller C, and repeat the same operation. If not – take a greater C. After a complete binary search, the smallest C for which a complete assignment is possible will be found. This will be the answer.\n\\\n<a name=\"lp\" id=\"lp\"></a> __Linear Programming (Simplex)__\nMost of the common traits of problems solved with the help of the linear programming technique are:\n* You are given collection of items having different costs/weights. There is a certain quantity of each item that must be achieved.\n* A list of sets is given. These sets are composed of some of the available items, having certain quantities of each of them. Each set has a certain cost. \n* The goal of the problem is to find an optimal combination (the cheapest one) of these sets so that the sum of quantities of each of the items they have is exactly the one needed to achieve.\n\nAt first it may seem confusing, but let’s see an example:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Mixture](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3942&amp;rd=6520) - SRM 231 Div 1:__\nA precise mixture of a number of different chemicals, each having a certain amount, is needed. Some mixtures of chemicals may be purchased at a certain price (the chemical components for the mixture might not be available in pure form). Each of them contains certain amounts of some of the chemicals. You need not purchase the available mixtures in integral amounts. Hence if you purchase a 1.5 of a mixture having a price of 3 and amounts of \"2 0 1\", you’ll pay 4.5 and get \"3 0 1.5\" amounts of chemicals. Your task is to determine the lowest price that the desired mixture can be achieved. \n</div>\n__Problem hints:__\n* A collection of items (chemicals).\n* A list of sets (available mixtures), each containing certain amounts of each of the items, and having a certain cost.\n* You need to find the lowest price of the desired collection of items achieved by the combination of the available sets. More than that – you can take also non-integral amounts of mixtures.\n\nThese are exactly the traits described above.\n\\\n<a name=\"conclusion\" id=\"conclusion\"></a>\n__Conclusion__\nIf you have found this article interesting and you have learned new things from it – train yourself on any of the problems in the topcoder Algorithm Arena. Try hard to see the hints and determine the type of the solution by carefully reading through the problem statement. Remember, there are still many problems that may not be included properly in any of the categories described above and may need a different approach.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":27,"downvotes":1}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"21xFsUG23DmIKt4KcRWADZ","type":"Entry","createdAt":"2020-02-22T13:37:10.481Z","updatedAt":"2024-09-05T12:29:06.073Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":259,"revision":100,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Line Sweep Algorithms","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Java","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=515054)\n\nA previous series of [articles](https://www.topcoder.com/thrive/articles/Geometry%20Concepts%20part%201:%20Basic%20Concepts) covered the basic tools of computational geometry. In this article I’ll explore some more advanced algorithms that can be built from these basic tools. They are all based on the simple but powerful idea of a sweep line: a vertical line that is conceptually “swept” across the plane. In practice, of course, we cannot simulate all points in time and so we consider only some discrete points.\n\nIn several places I’ll refer to the Euclidean and Manhattan distances. The Euclidean distance is the normal, everyday distance given by Pythagoras’ Theorem. The Manhattan distance between points (x1, y1) and (x2, y2) is the distance that must be travelled while moving only horizontally or vertically, namely |x1 – x2| + |y1 - y2|. It is called the Manhattan distance because the roads in Manhattan are laid out in a grid and so the Manhattan distance is the distance that must be travelled by road (it is also called the “taxicab distance,” or more formally the L1 metric).\n\nIn addition, a [balanced binary tree](https://www.topcoder.com/thrive/articles/An%20Introduction%20to%20Binary%20Search%20and%20Red-Black%20Trees) is used in some of the algorithms. Generally you can just use a set in C++ or a TreeSet in Java, but in some cases this is insufficient because it is necessary to store extra information in the internal nodes.\n\n### Closest pair \nGiven a set of points, find the pair that is closest (with either metric). Of course, this can be solved in O(N2) time by considering all the pairs, but a line sweep can reduce this to O(N log N).\n\nSuppose that we have processed points 1 to N - 1 (ordered by X) and the shortest distance we have found so far is h. We now process point N and try to find a point closer to it than h. We maintain a set of all already-processed points whose X coordinates are within h of point N, as shown in the light grey rectangle. As each point is processed, it is added to the set, and when we move on to the next point or when h is decreased, points are removed from the set. The set is ordered by y coordinate. A balanced binary tree is suitable for this, and accounts for the log N factor.\n\n<center>\n<img src=\"http://images.ctfassets.net/piwi0eufbb2g/QBKnjI8xjQIg3Jj1V9qe1/a71f79c28504113da1a9dbda2f909c0f/closest.png\" />\n</center>\n\nTo search for points closer than h to point N, we need only consider points in the active set, and furthermore we need only consider points whose y coordinates are in the range yN - h to yN + h (those in the dark grey rectangle). This range can be extracted from the sorted set in O(log N) time, but more importantly the number of elements is O(1) (the exact maximum will depend on the metric used), because the separation between any two points in the set is at least h. It follows that the search for each point requires O(log N) time, giving a total of O(N log N).\n\n### Line segment intersections\nWe’ll start by considering the problem of returning all intersections in a set of horizontal and vertical line segments. Since horizontal lines don’t have a single X coordinate, we have to abandon the idea of sorting objects by X. Instead, we have the idea of an event: an X coordinate at which something interesting happens. In this case, the three types of events are: start of a horizontal line, end of a horizontal line, and a vertical line. As the sweep line moves, we’ll keep an active set of horizontal lines cut by the sweep line, sorted by Y value (the red lines in the figure).\n\n<center>\n  ![linesvh](//images.ctfassets.net/piwi0eufbb2g/PFqt8LSeQTyGjke7kr4Kn/83701bdb8d7f8c72233997cb5dfc5b69/linesvh.png)\n</center>\n\nTo handle either of the horizontal line events, we simply need to add or remove an element from the set. Again, we can use a balanced binary tree to guarantee O(log N) time for these operations. When we hit a vertical line, a range search immediately gives all the horizontal lines that it cuts. If horizontal or vertical segments can overlap there is some extra work required, and we must also consider whether lines with coincident endpoints are considered to intersect, but none of this affects the computational complexity.\n\nIf the intersections themselves are required, this takes O(N log N + I) time for I intersections. By augmenting the binary tree structure (specifically, by storing the size of each sub-tree in the root of that sub-tree), it is possible to count the intersections in O(N log N) time.\n\nIn the more general case, lines need not be horizontal or vertical, so lines in the active set can exchange places when they intersect. Instead of having all the events pre-sorted, we have to use a priority queue and dynamically add and remove intersection events. At any point in time, the priority queue contains events for the end-points of line-segments, but also for the intersection points of adjacent elements of the active set (providing they are in the future). Since there are O(N + I) events that will be reached, and each requires O(log N) time to update the active set and the priority queue, this algorithm takes O(N log N + I log N) time. The figure below shows the future events in the priority queue (blue dots); note that not all future intersections are in the queue, either because one of the lines isn’t yet active, or because the two lines are not yet adjacent in the active list.\n\n<center>\n  ![lines](//images.ctfassets.net/piwi0eufbb2g/3JTURzWJosKNh2eLdLs0tG/9c05d9cbed4d6b4fb9682109fc54d176/lines.png)\n</center>\n\n### Area of the union of rectangles\nGiven a set of axis-aligned rectangles, what is the area of their union? Like the line-intersection problem, we can handle this by dealing with events and active sets. Each rectangle has two events: left edge and right edge. When we cross the left edge, the rectangle is added to the active set. When we cross the right edge, it is removed from the active set.\n\n<center>\n  ![rects](//images.ctfassets.net/piwi0eufbb2g/xa5RnaseHw5gjQrAOjr4P/bf56efda5c065f77d092710c46c1cd48/rects.png)\n</center>\n\nWe now know which rectangles are cut by the sweep line (red in the diagram), but we actually want to know the length of sweep line that is cut (the total length of the solid blue segments). Multiplying this length by the horizontal distance between events gives the area swept out between those two events.\n\nWe can determine the cut length by running the same algorithm in an inner loop, but rotated 90 degrees. Ignore the inactive rectangles, and consider a horizontal sweep line that moves top-down. The events are now the horizontal edges of the active rectangles, and every time we cross one, we can simply increment or decrement a counter that says how many rectangles overlap at the current point. The cut length increases as long as the counter is non-zero. Of course, we do not increase it continuously, but rather while moving from one event to the next.\n\nWith the right data structures, this can be implemented in O(N2) time (hint: use a boolean array to store the active set rather than a balanced binary tree, and pre-sort the entire set of horizontal edges). In fact the inner line sweep can be replaced by some clever binary tree manipulation to reduce the overall time to O(N log N), but that is more a problem in data structures than in geometry, and is left as an exercise for the reader. The algorithm can also be adapted to answer similar questions, such as the total perimeter length of the union or the maximum number of rectangles that overlap at any point.\n\n### Convex hull\nThe convex hull of a set of points is the smallest convex polygon that surrounds the entire set, and has a number of practical applications. An efficient method that is often used in challenges is the Graham scan [2], which requires a sort by angle. This isn’t as easy as it looks at first, since computing the actual angles is expensive and introduces problems with numeric error. A simpler yet equally efficient algorithm is due to Andrew [1], and requires only a sort by X for a line sweep (although Andrew’s original paper sorts by Y and has a few optimizations I won’t discuss here).\n\nAndrew’s algorithm splits the convex hull into two parts, the upper and lower hull. Usually these meet at the ends, but if more than one points has minimal (or maximal) X coordinate, then they are joined by a vertical line segment. We’ll describe just how to construct the upper hull; the lower hull can be constructed in similar fashion, and in fact can be built in the same loop.\n\nTo build the upper hull, we start with the point with minimal X coordinate, breaking ties by taking the largest Y coordinate. After this, points are added in order of X coordinate (always taking the largest Y value when multiple points have the same X value). Of course, sometimes this will cause the hull to become concave instead of convex:\n\n<center>\n  ![uhull](//images.ctfassets.net/piwi0eufbb2g/iX9yhQdJHJ6x1jXVpYwn3/f49d46ed536fcc71dd5951f940fe92fa/uhull.png)\n</center>\n\nThe black path shows the current hull. After adding point 7, we check whether the last triangle (5, 6, 7) is convex. In this case it isn’t, so we delete the second-last point, namely 6. The process is repeated until a convex triangle is found. In this case we also examine (4, 5, 7) and delete 5 before examining (1, 4, 7) and finding that it is convex, before proceeding to the next point. This is essentially the same procedure that is used in the Graham scan, but proceeding in order of X coordinate rather than in order of the angle made with the starting point. It may at first appear that this process is O(N2) because of the inner backtracking loop, but since no point can be deleted more than once it is in fact O(N). The algorithm over-all is O(N log N), because the points must initially be sorted by X coordinate.\n\n### Manhattan minimum spanning tree \nWe can create even more powerful algorithms by combining a line sweep with a divide-and-conquer algorithm. One example is computing the minimum spanning tree of a set of points, where the distance between any pair of points is the Manhattan distance. This is essentially the algorithm presented by Guibas and Stolfi [3].\n\nWe first break this down into a simpler problem. Standard MST algorithms for general graphs (e.g., Prim’s algorithm) can compute the MST in O((E + N) log N) time for E edges. If we can exploit geometric properties to reduce the number of edges to O(N), then this is merely O(N log N). In fact we can consider, for each point P, only its nearest neighbors in each of the 8 octants of the plane (see the figure below). The figure shows the situation in just one of the octants, the West-Northwest one. Q is the closest neighbour (with the dashed line indicating points at the same Manhattan distance as Q), and R is some other point in the octant. If PR is an edge in a spanning tree, then it can be removed and replaced by either PQ or QR to produce a better spanning tree, because the shape of the octant guarantees that |QR| = |PR|. Thus, we do not need to consider PR when building the spanning tree.\n\n<center>\n  ![octants](//images.ctfassets.net/piwi0eufbb2g/5CCfXOgbKPyavwlhCdfQmW/1f393c0e52220f20583f4f95ecc104c8/octants.png)\n</center>\n\nThis reduces the problem to that of finding the nearest neighbour in each octant. We’ll just consider the octant shown; the others are no different and can be handled by symmetry. It should be clear that within this octant, finding the nearest neighbour is equivalent to just finding the point with the largest value of x - y, subject to an upper bound on x + y and a lower bound on y, and this is the form in which we’ll consider the problem.\n\nNow imagine for the moment that the lower bound on y did not exist. In this case we could solve the problem for every P quite easily: sweep through the points in increasing order of x + y, and Q will be the point with the largest x - y value of those seen so far. This is where the divide-and-conquer principle comes into play: we partition the point set into two halves with a horizontal line, and recursively solve the problem for each half. For points P in the upper half, nothing further needs to be done, because points in the bottom half cannot play Q to their P. For the bottom half, we have to consider that by ignoring the upper half so far we may have missed some closer points. However, we can take these points into account in a similar manner as before: walk through all the points in x + y order, keeping track of the best point in the top half (largest x - y value), and for each point in the bottom half, checking whether this best top-half point is better than the current neighbour.\n\nSo far I have blithely assumed that any set of points can be efficiently partitioned on Y and also walked in x + y order without saying how this should be done. In fact, one of the most beautiful aspects of this class of divide-and-conquer plus line-sweep algorithms is that it has essentially the same structure as a merge sort, to the point that a merge-sort by x + y can be folded into the algorithm in such a way that each subset is sorted on x + y just when this is needed (the points initially all being sorted on Y). This gives the algorithm a running time of O(N log N).\n\nThe idea of finding the closest point within an angle range can also be used to solve the Euclidean MST problem, but the O(N log N) running time is no longer guaranteed in the worst cases, because the distance is no longer a linear equation. It is actually possible to compute the Euclidean MST in O(N log N) time, because it is a subset of the Delaunay triangulation.\n\n### Sample problems\n\n[BoxUnion](http://community.topcoder.com/stat?c=problem_statement&pm=4463&rd=6536)\nThis is the union of area of rectangles problem above. In this instance there are at most three rectangles which makes simpler solutions feasible, but you can still use this to practice.\n\n[CultureGrowth](http://community.topcoder.com/stat?c=problem_statement&pm=3996&rd=7224)\nWhile written in a misleading fashion, the task is just to compute the area of the convex hull of a set of points.\n\n[PowerSupply](http://community.topcoder.com/stat?c=problem_statement&pm=5969)\nFor each power line orientation, sweep the power line in the perpendicular direction. Consumers are added D units ahead of the sweep and dropped D units behind the sweep. In fact, the low constraints mean that the connected set can be computed from scratch for each event.\n\n[ConvexPolygons](http://community.topcoder.com/stat?c=problem_statement&pm=4559&rd=7225)\nThe events of interest are the vertices of the two polygons, and the intersection points of their edges. Between consecutive events, the section cut by the sweep line varies linearly. Thus, we can sample the cut area at the mid-point X value of each of these regions to get the average for the whole region. Sampling at these mid-points also eliminates a lot of special-case handling, because the sweep line is guaranteed not to pass anywhere near a vertex. Unlike the solution proposed in the [match editorial](http://community.topcoder.com/tc?module=Static&d1=match_editorials&d2=srm250), the only geometric tool required is line-line intersection.\n\n### Conclusion\nLike dynamic programming, the sweep line is an extremely powerful tool in an algorithm competitor’s toolkit because it is not simply an algorithm: it is an algorithm pattern that can be tailored to solve a wide variety of problems, including other textbooks problems that I have not discussed here (Delaunay triangulations, for example), but also novel problems that may have been created specifically for a contest. In Topcoder the small constraints often mean that one can take shortcuts (such as processing each event from scratch rather than incrementally, and in arbitrary order), but the concept of the sweep line is still useful in finding a solution.\n\n### References\n\nA. M. Andrew. 1979. Another efficient algorithm for convex hulls in two dimensions. Information Processing Letters 9(5) pp 216-219.\n\nR. L. Graham. 1972. An efficient algorithm for determining the convex hull of a finite planar set. Information Processing Letters 1(4) pp 132-133.\n\nLeonidas J. Guibas and Jorge Stolfi. 1983. On computing all north-east nearest neighbors in the L1 metric. Information Processing Letters 17(4) pp 219-223.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7irvPmUqeUZHDFMgz0piRj","type":"Entry","createdAt":"2020-02-21T10:26:10.811Z","updatedAt":"2020-02-21T10:26:10.811Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"bmerry"}}],"upvotes":41,"downvotes":3}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28yQ5Q5q8RxRZQhUMmB7ir","type":"Entry","createdAt":"2021-01-26T06:54:02.129Z","updatedAt":"2024-08-28T04:22:31.363Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":61,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Introduction to Streaming: Spark & Databricks","slug":"introduction-to-streaming-spark-and-databricks","type":"Article","trackCategory":["Data Science"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"55HiOMbEVXarc2fnfuAOuN","type":"Entry","createdAt":"2019-09-18T07:37:47.286Z","updatedAt":"2019-09-18T07:37:47.286Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Machine Learning Tools & Libraries","trackParent":"Data Science"}}],"tags":["Spark","Azure","Data Bricks"],"creationDate":"2021-01-26","readTime":"20min","content":"> “Information is the oil of the twenty-first century, and analytics is the combustion engine.” – Peter Sondergaard\n\nThis article will talk about streaming techniques using Spark and Databricks. Databricks is a software platform that executes over Apache Spark. It helps in creating a workspace to execute Spark data frames using the data from AWS S3. The data source can be AWS Kinesis, Kafka stream, flat files, and message queue.\n\n### Introduction to Streaming: Using Databricks\n\nDatabricks was created by Apache Spark founders. This platform helps data engineers, scientists, and analysts to perform data engineering, data analysis, and data processing. It has features related to interactive notebook creation, Spark runtime, and Big Data SQL query engine. It has ETL, analytics, and machine learning modules. Databricks can interact with other Azure services like Event Hub and Cosmos DB. Clusters that can be auto-terminated and auto-scaled can be created on the Databricks workspace and virtual machine nodes can be assigned to the cluster for execution. Spark Structured Streaming and Delta Lake are the important components in the Databricks platform.\n\nNow let us look at streaming data use cases where data can come from different sources. A producer application will be pushing the data for the consumer application to process the data.\n\n### Databricks Streaming Architecture \n\nDatabricks supports Jupyter Notebooks and they can be versioned on github and Azure DevOps. Databricks is based on Apache Spark with other open-source packages. Developers can spring up clusters using Spark for big data processing. Auto-scaling and auto-termination features are provided by Azure Databricks.\n\n![image](//images.ctfassets.net/piwi0eufbb2g/57XUvfkZ9xnvR9svpH6C4W/6201016771c925fbdfe150d594a410b6/image.png)\n\nThe streaming component has features to handle data from csv and transform to json. Event Hub can access the data and execute transformations related to IOT Hub.  Routing can have rules for pushing the data to different sources. Data can be sent to a database (Cosmos DB) and SQL queries can be executed on the database.\n\n### Data Frames & Data Sets\n\nDatabricks platform can handle data sets and create data frames from them. Data frames are immutable table data structures that can have the result persisted in themselves. Transformations can be performed on the data frame like sorting, filtering, grouping, and selecting.\n\nThe sample data frame used in this article is shown below in the notebook:\n![image](//images.ctfassets.net/piwi0eufbb2g/6g6bPO8IPVdW8rkOlsmr2s/409747143bbb648dcfd192cda3030f32/image.png)\n\n### Databricks Data Lake\n\nDatabricks platform has support for creation of Data Lake. Data Lake has structured, unstructured and non tabular data persisted in a repository. It has features for object storage and transforming different data formats such as images, videos, binary files, and flat files. It can be used for aggregating data from enterprise different locations and creating reports and dashboards using that data. The advantage is persisting the data as it is without new schema creations and transformations.\n\n### Databricks Account Creation\n\nA Databricks account can be created on a trial or pay as you go basis. The pay as you go model charges you for the usage of underlying virtual machines.\n\nYou can start creating the Databricks account as shown below:\n![image](//images.ctfassets.net/piwi0eufbb2g/23klcRNVFXDi7GQmDOHeWZ/b7783b57a2db896e081b02d8f21eb4f7/image.png)\n\nYou can see the workspace created for your streaming data.\n![image](//images.ctfassets.net/piwi0eufbb2g/4bfhNa6HwjRqZysxVvWD5V/8ccb7aa7e0a8f3f3e05b0e1f0d31ab0a/image.png)\n\nThe left menu has items for cluster creation and notebook creation.\n![image](//images.ctfassets.net/piwi0eufbb2g/1U0IWPjViqILWDaw1fuklZ/ba226dab120d80556d829b12344a3df9/image.png)\n\n### Cluster Creation\n\nYou can create a cluster as shown below:\n![image](//images.ctfassets.net/piwi0eufbb2g/4GOPADol7gGsIl3C0ipiun/af7c1c5847a9e76930e140149ede9683/image.png)\n\n### Input Data Creation\n\nYou can create a notebook in the cluster created above:\n![image](//images.ctfassets.net/piwi0eufbb2g/mut3YDQRER9a9C4bFNtGK/6cd351bf2724cecddbb66ff49e4b727c/image.png)\n\nAfter creating the notebook, you can start writing the code related to data processing.\n\n### Data Stream Processing\n\nA data sample from SanFranscisco Fire Calls is used in this notebook. The data from AWS S3 is mounted to the Azure file system.\n![image](//images.ctfassets.net/piwi0eufbb2g/5vXqb3uTNqYFG2wYVqD6h5/e43332c597c0137c790dbc7ff487b4d9/image.png)\n\nSpark session is initialized below:\n![image](//images.ctfassets.net/piwi0eufbb2g/48E9jMdPP4YTzdrI25fcT3/fc529ddc8eb0834c3038e3229c861b9a/image.png)\n\nAfter creating the data frame, the query is executed for getting the first five rows.\n![image](//images.ctfassets.net/piwi0eufbb2g/6TkQboVfoj2hQ7ZiDCj0nQ/a0215f18f841f42d8d88f5d7f3a8db87/image.png)\n\nYou can print the columns in the data frame as shown below:\n![image](//images.ctfassets.net/piwi0eufbb2g/WCUkHKV4Ikeq9IPpPErI3/eb4488c3a533730990c2506b3e4bf54f/image.png)\n\nYou can print the total count of the rows in the dataframe. The below snapshot shows the top seven call types printed in the dataframe.\n![image](//images.ctfassets.net/piwi0eufbb2g/zjYSCF15pXBkKWZFjwrxz/c59725bb0f8fe9f643bce29a5cb1e23a/image.png)\n\nThe below snapshot shows how to print distinct call types - top twenty-five rows\n![image](//images.ctfassets.net/piwi0eufbb2g/6pKaThAVAJlnoi7bbchyBZ/463fe8e9ca12e2763a9d24183a92c2e3/image.png)\n\nYou can group the data by call types and sort the data in ascending order by count column. This is shown below:\n![image](//images.ctfassets.net/piwi0eufbb2g/4DpfpbxyScoFgBDeW9NvU4/7ed4f85427253b43a94e17234be53c9a/image.png)\n\n### Data Aggregation\n\nData can be aggregated from multiple data sources and from various formats using transformations and joins. The output can be stored in different destinations in the Databricks platform. You can use aggregators for summing up data in a data set to calculate the output.  An aggregator has input type, intermediate type, and output type elements in the interface.\n\n### Azure Databricks - Data Warehousing\n\nThe Databricks platform can engineer data with Azure Data Factory, Azure Data Lake Storage, and Azure Synapse Analytics. Azure Databricks has features related to data warehousing and providing dashboards and reports. Databricks platform provides a transactional storage layer for data management with reliability and scalability. Power BI can be integrated with Databricks for analytic capabilities. Workspaces are secured with features such as compliant and private analytics workspaces. Big data sets are executed with continuous integration, continuous deployment tools (CI/CD) and DevOps tools.\n![image](//images.ctfassets.net/piwi0eufbb2g/22HVF5jcdu958ETy7FoUyj/f9044d85772d48aefe26faeca0733564/image.png)\n\nYou can access the notebook at this link : https://github.com/bhagvanarch/databricks/blob/main/Databricks\\_Streaming.ipynb\n\nIn the next part of the series, we will look at Job Processing with DataBricks.\n\n__References__:\n1. [Azure DataBricks Platform](https://docs.microsoft.com/en-us/azure/databricks/)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ZZoOM5Y5M4PxOkDSspB9Q","type":"Asset","createdAt":"2021-01-26T06:41:44.609Z","updatedAt":"2021-01-26T06:41:57.563Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"binary-2957504 960 720","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2ZZoOM5Y5M4PxOkDSspB9Q/7a9a7a8014161e59af955a14bbd8c619/binary-2957504_960_720.jpg","details":{"size":150332,"image":{"width":760,"height":760}},"fileName":"binary-2957504_960_720.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"26IApFU2X6pFV4vm9UgqMO","type":"Entry","createdAt":"2019-09-18T07:37:45.247Z","updatedAt":"2019-10-15T16:12:49.080Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Bhagvan Kommadi","tcHandle":"bhagvanarch"}}],"upvotes":2,"downvotes":0}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3jODTYN5EVcDyy5NL25DLI","type":"Entry","createdAt":"2022-10-18T11:23:23.796Z","updatedAt":"2024-08-10T19:30:44.703Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":102,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Create a Basic Browser GraphiQL Tool using React.js","slug":"create-a-basic-browser-graphiql-tool-using-react-js","type":"Article","trackCategory":["Development"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5XNV8gKk9DbppF4W0TPY76","type":"Entry","createdAt":"2019-08-27T06:08:26.689Z","updatedAt":"2021-09-02T10:58:56.367Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Front-End Development","trackParent":"Development"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}}],"tags":["JavaScript","ReactJS","GraphQL"],"creationDate":"2022-10-14","readTime":"9min","content":"GraphiQL is an interactive development environment. It's a tool built into many GraphiQL graphical services that allow you to interact with your app data and GraphQL APIs. We will create a basic browser GraphiQL tool using React.js.\n\n### Prerequisites\nIt is important to have these prerequisites in order to follow along with this tutorial:\n- [Node.js runtime](https://nodejs.org/en/download/) is installed on your local machine. We need Node.js to create React applications.\n- We will build a GraphiQL tool with React.js and demonstrate how to use it with a GraphQL API. Therefore, you need to create a GraphQL API that GraphiQL will use. A GraphQL API can be implemented using different technologies. You need to have one running.\n\n### An Overview\nWhenever you create a GraphQL API, GraphQL provides an extendable playground to execute and a GraphQL schema for the created API. However, take a scenario where you have a CMS such as WordPress. You need to generate API data to separate the presentation layer.\n\nIn this case, an API plays a big role in helping users fetch data from the CMS. Therefore, you need to create a GraphQL interface that will allow these users to generate GraphQL-based queries using GraphiQL.\n\nThis helps bridge modern frontend stacks with content management with systems such as CMS. GraphQL queries allow you to have access to multiple root resources with a single request. Below is a basic example of a GraphiQL tool.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/W6SYOcT6kxkZZM3BOXcdS/7ddbb58409a4a4beada29fb2ceec89df/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss1.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/W6SYOcT6kxkZZM3BOXcdS/7ddbb58409a4a4beada29fb2ceec89df/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss1.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/W6SYOcT6kxkZZM3BOXcdS/7ddbb58409a4a4beada29fb2ceec89df/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss1.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n\n### Create React App\nWe will use the above GraphQL API to integrate with a React GraphiQL tool. Let's dive in and create GraphiQL using React.js. First, create a basic React.js application using the following command as such:\n`npx create-react-app client`\n\nThe abovementioned command will generate a new React application with a new directory `client`. Change the directory to created `client` folder:\n`cd client`\n\nStart the development server:\n`npm start`\n\nYou can now view the created React app in the browser `http://localhost:3000`\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4e3fXkECeQC1S3rJel7Ptw/6762384cc80af3fffc0926fe44bf209d/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss2.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4e3fXkECeQC1S3rJel7Ptw/6762384cc80af3fffc0926fe44bf209d/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss2.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4e3fXkECeQC1S3rJel7Ptw/6762384cc80af3fffc0926fe44bf209d/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss2.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n#### Install Frontend Packages\nTo create a GraphiQL tool, we need the following packages:\n- [GraphQL](https://www.npmjs.com/package/graphql) - Used to build GraphQL type schema and serve GraphQL queries.\n- [GraphiQL](https://www.npmjs.com/package/graphiql) - It allows you to create an in-browser GraphQL IDE to design interactive GraphQL components for frontend frameworks.\nTo get these libraries, use the following command. If yarn is your dependency manager, you may also utilize it.\n`npm install graphql graphiql`\nFor yarn, use:\n`npm install graphql graphiql`\n\n#### Creating and Rendering the GraphiQL UI with React\nLet's create a UI for interactive GraphQL queries. Head to your React app `src/app.js` file and implement the GraphiQL tool as described in the following steps:\n- __Import the dependencies and the peer dependencies as follows:__\n```js\nimport React from 'react';\n// import GraphiQL  to have access to GraphiQL  tools\nimport GraphiQL from 'graphiql';\n//Import graphql features that you want to use in your GraphiQL \nimport { getIntrospectionQuery, buildClientSchema } from 'graphql';\n// Add the css for styling enhancements\nimport 'graphiql/graphiql.min.css';\n```\n\n- __Send requests to the server using fetch.__ In this case, make sure you add the GraphQL URL that executes the GraphQL route of your server.\n\n```js\nconst fetcher = async (graphQLParams) => {\n  const data = await fetch(\n    // This is an endpoint that points to your running GraphQL server\n    'http://localhost:4000/graphql',\n    {\n//headers Post method\n      method: 'POST',\n// Add the headers needed to access the above server\n      headers: {\n        Accept: 'application/json',\n        'Content-Type': 'application/json',\n      },\n\t// specify the origin credentials for both applications to be able to communicate\n      body: JSON.stringify(graphQLParams),\n// The origin data sharing policy\n      credentials: 'same-origin',\n    },\n  );\n// return the origin of the data being shared\n  return data.json().catch(() => data.text());\n}\n```\n\n- __Create a class React component.__\n```js\nclass App extends React.Component {\n}\n```\n\nInside this component, create a GraphiQL component as follows:\n\n- __Define the state.__ Here, create the state for the GraphQL schema and query as follows:\n```js\n_graphiql;\nstate = { schema: null, query: '# Hola!' };\n_handleEditQuery = (query) => this.setState({ query });\ncomponentDidMount() {\n    this.updateSchema();\n}\n```\n\n- __Execute the GraphQL from the server and sever the result of the server JSON response.__\n```js\nexecuteQuery = async (graphQLParams) => {\n// Handle the response from the graphql server\n    const response = await fetch('http://localhost:4000/graphql', {\n//headers Post method\n        method: 'POST',\n// Add the headers needed to access the above server\n        headers: {\n            Accept: 'application/json',\n            'Content-Type': 'application/json',\n        },\n   // specify the origin credentials for both applications to be able to communicate\n        credentials: 'same-origin',\n   // json body\n        body: JSON.stringify(graphQLParams),\n    });\n// save the response from the server\n    const result = await response.json();\n// return the saved results of the above response\n    return result;\n}\n```\n\n- Using an async method, fetch the schema from the response result executed by the executeQuery function. In this case, create an async method and fetch the schema inside a try and catch block as follows:\n\nCreate the `updateSchema()` function.\n```js\nasync updateSchema() {\n    try {\n    }\n}\n```\n\nInside this function, try to block fetch the schema using introspection query.\n\n```js\nconst { data } = await this.executeQuery({ query: getIntrospectionQuery() });\n```\n\nUse the data we got back from GraphQL to build a client schema.\n```js\nconst schema = buildClientSchema(data);\n```\n\nUpdate our component with the new schema.\n\n```js\nthis.setState({ schema });\n```\n\nLog any errors.\n```\nthis.setState({ error: null });\n```\n\nFinally, close the catch block inside updateSchema() to catch errors as follows:\n```js\ncatch (error) {\n    console.error('Error occurred when updating the schema:');\n    console.error(error);\n    this.setState({ error });\n}\n```\n\n- Render the GraphQL data on the browser. This references the `_graphiql` and fetches the execute the GraphQL requests from the server.\n\nAdditionally, you can add the Prettify, History, and Explorer toolbar to GraphiQL. Here they are represented as dummies. Go ahead and implement them if your GraphiQL needs such functionalities.\n```js\nrender() {\n    return (\n        <div className=\"graphiql-container\">\n            <GraphiQL\n                ref={ref => (this._graphiql = ref)}\n                fetcher={fetcher}\n            >\n                <GraphiQL.Toolbar>\n                    <GraphiQL.Button\n                        title=\"Prettify Query (Shift-Ctrl-P)\"\n                        label=\"Prettify\"\n                    />\n                    <GraphiQL.Button\n                        label=\"History\"\n                        title=\"Show History\"\n                    />\n                    <GraphiQL.Button\n                        label=\"Explorer\"\n                        title=\"Construct a query with the GraphiQL explorer\"\n                    />\n                </GraphiQL.Toolbar>\n            </GraphiQL>\n        </div>\n    );\n}\n```\n\n- Finally, export the App component.\n```js\nexport default App;\n```\n\n### Testing\nLet's test if this tool is working as expected. At this point:\n- Ensure your GraphQL server is running.\n- Ensure the React app is running and open the app in the browser using the URL `http://localhost:3000`. You will be served with the GraphiQL tool we have just created.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3kQpreXaArNzFX3SAjCzoQ/abfc94fdd982edaf1956a1b9b07530b7/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss3.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3kQpreXaArNzFX3SAjCzoQ/abfc94fdd982edaf1956a1b9b07530b7/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss3.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3kQpreXaArNzFX3SAjCzoQ/abfc94fdd982edaf1956a1b9b07530b7/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss3.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nLet's test if the React GraphiQL tool can interact with the API data. We will execute a query to fetch posts from the database as follows:\n```\nquery Query {\n  posts {\n    title\n    description\n  }\n}\n```\n\nAdd this query to the GraphiQL tool.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2sFeH2ZqPcG051LOWvmRvK/d9d7f9c3984fcf5133a032a432ade5fa/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss4.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2sFeH2ZqPcG051LOWvmRvK/d9d7f9c3984fcf5133a032a432ade5fa/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss4.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2sFeH2ZqPcG051LOWvmRvK/d9d7f9c3984fcf5133a032a432ade5fa/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss4.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nThen hit the play button.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/agBmwmfBUXnBDFOy49eqA/c497ca2c9763ad39c391a88360777ae7/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss5.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/agBmwmfBUXnBDFOy49eqA/c497ca2c9763ad39c391a88360777ae7/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss5.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/agBmwmfBUXnBDFOy49eqA/c497ca2c9763ad39c391a88360777ae7/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js_-_ss5.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nAnd there you have it. The frontend tool you created can directly interact with your server, deploy it, and allow users to interact with the content managed by your API.\n\n### Conclusion\nGraphQL uses a mechanism that queries data and then displays that data with the GraphQL schema. This uses GraphiQL. You might want to query data from your application. A good example is how WordPress uses [wpGraphQL](https://www.wpgraphql.com/) to fetch WordPress-driven data.\n\nThis guide helped you create a GraphiQL tool to perform such GraphQL tasks. This provides extendable GraphQL features within your application.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6bvUg0VyRhu4vaVuwEsnf9","type":"Asset","createdAt":"2022-10-14T15:38:29.516Z","updatedAt":"2022-10-14T15:38:29.516Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"Create a Basic Browser GraphiQL Tool using React.js","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6bvUg0VyRhu4vaVuwEsnf9/f93570c88415793d8e403023acf9a627/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js.jpg","details":{"size":61935,"image":{"width":640,"height":425}},"fileName":"Create a Basic Browser GraphiQL Tool using React.js.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2Sp9m6GVboExtjXPfmLLPL","type":"Entry","createdAt":"2022-06-14T17:47:28.502Z","updatedAt":"2022-06-14T17:47:28.502Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Joseph Chege","tcHandle":"kimkimani"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7fJQUX22AQzwU0enuvpLIf","type":"Entry","createdAt":"2022-02-17T19:04:28.824Z","updatedAt":"2022-02-21T14:19:06.073Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Layering GraphQL over REST","slug":"layering-graphql-over-rest","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}}],"tags":["GraphQL","REST"],"creationDate":"2022-02-17","readTime":"9min","content":"GraphQL is quickly supplanting REST as the standard for which data is changed, brought, and queried between the server-end and frontend. Technical developers are seeking to analyze and procure its advantages in their brown-field ventures.\n\nThere are many advantages of GraphQL, here are just a few:\n\n1.  Querying numerous assets or resources and fetching the precise information and data you need in one request. Conversely, if we do the exact thing using REST it costs us multiple requests to filter the data.\n\n2.  A modern era of ergonomic dev tools from API to the frontend with famous platforms like Apollo Engine, Client, and Server.\n\n3.  Enhanced performance, particularly on gadgets with moderate internet connections, through the diminished size of the payload and fewer round trips to the backend.\n\nThe most perfect way to integrate product architecture with GraphQl is to deploy it as a layer between existing APIs and applications.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3pmPJlnJ4iLwUZEAjtCjdC/7a558aaf4ffd873f171bf62c5ebcc502/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3pmPJlnJ4iLwUZEAjtCjdC/7a558aaf4ffd873f171bf62c5ebcc502/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3pmPJlnJ4iLwUZEAjtCjdC/7a558aaf4ffd873f171bf62c5ebcc502/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### Layering GraphQL on Top of MVRP API\nTo layer GraphQL over our existing API we'll utilize Apollo Server. It has built-in features and support for GraphQL environment, schema sewing, effective error handling tools, data uploads, schema mandates, and simply observing integration. Let’s jump into building our schema!\n\nIn this, we use the schema first development approach. This is an advanced approach for planning and building cutting edge user interfaces that includes the frontend/client-side and backend/server-side groups concurring on a schema to begin with, which serves as a contract between the frontend and the backend ahead of any API building process. Let’s build a basic GraphQL scheme that portrays the shape of the information from the REST API.\n\nOnce we begin to build our GraphQL schema there’s a gigantic allure to form literal mappings over REST API or existing database collections data response fields. Whereas this mapping may be a quick way to urge up and running, we unequivocally recommend building the schema based on how the GraphQL API will be utilized by the client-end. This way, we'll plan a schema that reflects how client-side developers are fetching it, without compelling ourselves to the precise shape of the information returned by our existing APIs.\n\nThe schema underneath builds up a contract that depicts precisely how we ought to bring information into our user interface or frontend. Commendable of note are the two fields of schema, “manufactureYear”, and “vehicleStatus”, named differently from the attributes: “productionYear” and “status”, returned as a response from the REST API.\n\n```js\nimport { gql, AppoloServer } from 'apollo-server';\n\nconst typeDefs = gql`\ntype Car {\n    id: Int!\n    model: String!\n    color: String!\n    plateNumber: String!\n    chasisNumber: String!\n    manufactureYear: Int!\n    vehicleStatus: String!\n    expiryDate: String!\n    issueDate: String!\n}\ntype Query {\n    cars: [Car]\n    car(plateNumber: String!): Car\n}\n`;\n```\n\nOur GraphQL schema depicts how it’s utilized on the client-side user interface. Now, check out the Query block:\ncars: \\[Car\\] - this query returns full details of all cars present in the database.\ncar(plateNumber: String!): Car - this query returns details of only one car matching with plateNumber argument.\n\n### Data Sources\nWhen conveying GraphQL as a layer between existing APIs, services, and our applications, “Apollo Data Sources” give the finest involvement for caching and fetching information from REST endpoints. It’s a modern pattern for stacking information from a specific service, with built-in support for deduplication, error handling, and caching. To ship the data sources out of the box “Apollo Server” is used as the GraphQL layer.\nNow, we have to install apollo-datasource-rest.\n\n`npm install apollo-datasource-rest`\n\nWe create a file named dataSource.js with a class named MVRP (it can be anything) and extend RESTDataSource class as given below-\n\n```js\nimport { RESTDataSource } from 'apollo-datasource-rest';\n\nexport class MVRP extends RESTDataSource {\n    constructor() {\n        super();\n        this.base_url = 'https://mvrp.herokuapp.com/api/';\n    }\n\n    async fetchAllCars() {\n        return this.get('cars');\n    }\n\n    async fetchCar(plateNumber) {\n        const result = await this.get('car', {\n        plateNumber\n        });\n\n        return result[0];\n    }};\n```\n\nHere, base_url is allotted to the root domain of the API within the constructor of our DataSource class. fetchCar(plateNumber)and fetchAllCars() functions get data from the /car and /car?plateNumber endpoints respectively, and both functions invoke the HTTP GET request.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7fSG7idnmJAPzpmeZ44SrX","type":"Asset","createdAt":"2022-02-17T19:02:55.677Z","updatedAt":"2023-09-21T14:44:33.218Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":2,"locale":"en-US"},"fields":{"title":"GraphQL article banner image","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7fSG7idnmJAPzpmeZ44SrX/f9cbaaa4f13d2e583c9a314218943c16/Banner_Thrive__1_.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive (1).png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2b56J83mO6xWOJwhZJ5uuC","type":"Entry","createdAt":"2021-10-18T06:57:25.136Z","updatedAt":"2021-10-18T06:57:25.136Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kunal Jain","tcHandle":"kunalkj_"}}],"upvotes":1,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"4CmGkGPOwKztbCNNqDWLmm"}},{"sys":{"type":"Link","linkType":"Entry","id":"3K3D6N5OeawF9nZwr07MGt"}},{"sys":{"type":"Link","linkType":"Entry","id":"7o6p5UjHg80yvob06jXFz0"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"57kU8FPeNjrUIUZWB7pNiI","type":"Entry","createdAt":"2022-09-20T10:06:18.560Z","updatedAt":"2022-09-25T11:07:44.711Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":99,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"React Developer Hacking Tips","slug":"react-developer-hacking-tips","type":"Article","trackCategory":["Development"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5XNV8gKk9DbppF4W0TPY76","type":"Entry","createdAt":"2019-08-27T06:08:26.689Z","updatedAt":"2021-09-02T10:58:56.367Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Front-End Development","trackParent":"Development"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}}],"tags":["ReactJS","JavaScript"],"creationDate":"2022-09-20","readTime":"7min","content":"### How to use React Developer Tools\nCritical tools aid in using React features, available on browsers such as Chrome and Firefox. The tools on Chrome and Firefox help to scrutinize React applications to reveal tree components of React such as checking the state, props, and hooks.\n\nInstallation of React developer tools on the browsers:\n- Add to Chrome React developer tool -([https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi))\n- Extension for Firefox React developer tool ([https://addons.mozilla.org/en-US/firefox/addon/react-devtools/](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/))\n\nThe diagram below shows how to initiate installation:\n\n<picture><source srcset=\"https://images.ctfassets.net/piwi0eufbb2g/4gpUQsT1nAqpsVd9UPXYpo/728b3e76797b380ab9e143027da70464/React_Developer_Hacking_Tips_-_ss1.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"https://images.ctfassets.net/piwi0eufbb2g/4gpUQsT1nAqpsVd9UPXYpo/728b3e76797b380ab9e143027da70464/React_Developer_Hacking_Tips_-_ss1.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"https://images.ctfassets.net/piwi0eufbb2g/4gpUQsT1nAqpsVd9UPXYpo/728b3e76797b380ab9e143027da70464/React_Developer_Hacking_Tips_-_ss1.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nOnce the developer tool is installed, click on the right of the Chrome browser, then click __“Inspect”__ where the __Profiler__ and __Components__ section is listed. They are shown as follows:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1NwycP5V1CsrP5CAUBygVY/10f4d6c0be170ca3a8a93f8881954a35/React_Developer_Hacking_Tips_-_ss2.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1NwycP5V1CsrP5CAUBygVY/10f4d6c0be170ca3a8a93f8881954a35/React_Developer_Hacking_Tips_-_ss2.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1NwycP5V1CsrP5CAUBygVY/10f4d6c0be170ca3a8a93f8881954a35/React_Developer_Hacking_Tips_-_ss2.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nThe __profiler__ helps to record the application interaction by having two components that create an interaction. The __components__ help to show the current React tree component with __state__, __context__ and __props__. \n\nSelecting the tree component of React shows a reference to props passed and the parent components, which are displayed by clicking the component names. Clicking on the eye icon on the developer tools helps to inspect the DOM element. Hover around the UI of the browser to see the React component being rendered. Also, use the bug icon for the component data logging in the console. \n\n#### Identifying components and context to debug the application \nOpen the __App.js__ file in the React application in which the user can insert a class of __wrapper__ with a __div__ and create an `<label>` element around an `<textarea>` element.\n\n```  \n#Open the App.js file\nnano src/components/App/App.css\n```\n\nThe App.js is indicated below:\n```js\nimport React from ‘react’;\nimport ‘./App.css’\n\nfunction App() {\n  return(\n    <div className=”wrapper”>\n     <label htmlFor=”text”>\n       Add Your Text Here:\n       <br>\n       <textarea \n         id=”text”\n         name=”text”\n         rows=”10”\n         cols=”100”\n       >\n       </textarea>\n      </label>\n     </div>\n  )\n}\n\nexport default App;\n```\n\nAdding the textarea provides the input area in which the __context__ inside is a generic name. After adding the content, the React Developer Tools show the prop and context.\n\nAfter rendering the components they can be traced using the React Developer Tools profiler to track the rendered component and re-rendering of the application, in which the user is able to do the following:\n- Optimize metrics\n- Identify inefficient components\n- Reduce render time and increase application speed. \n- Any re-rendered components are highlighted when the changes are made, and all data is stored on a hook at the administrator level. Also, the function in the App.js helps to re-render the context change or props.\n\nThe Developer Tools browser extension helps to traverse the application components by exploring the bugs using the real-data, component states without console debuggers. Similarly, the profiler helps to inspect the components' reactions to each other. \n\n### What does a React developer do?\nThe React developer is able to design and create JavaScript applications, both web and mobile, with focus on front-end development. React.js serves as a  toolkit for developers which helps to rewrite code and configure data.  React developers are tasked with the following responsibilities to state the front-end development : \n- Development of front-end characteristics - React developers have the ability to put together UI elements such as images, icons, long-pressing, drag, and drop features. \nReact developers write code by translating wireframes into code. Most of the code interacts with writing HTML tags and CSS selectors. \n- Utilize application functions - Both in browsers and devices, the React application runs efficiently with cross-platform scalability.\n- React developers are involved in software testing to test the interface developed stages. \n- React developers work with clients and end-users to understand the UI features via the software development. \n- React developers interact and consult with back-end engineers to partner in user-facing and server interactions without an error. \n\n### How to become a React developer\n- React is a library for front-end development. React is JavaScript based, used to develop both the front-end and back-end of the application. Therefore the React application works closely with back-end development for server development. \n- Despite developing the front-end UI, the server-side frameworks use Node.js, Python, and Django. \n- Gain necessary skills such as programming, styling, and markup languages such as HTML and CSS. \n- Code repositories such as GitHub and Bitbucket are used by developers to manage and track code history by mastering the Git control system version. \n- Get a resume inclusive of the right skills and a great portfolio. \n\n### The pros of ReactJs\n- ReactJS helps to develop dynamic web applications using HTML and CSS. \n- ReactJS aids in effective performance using the virtual DOM, in which the DOM helps the API, such as after HTML, XHTML and XML. \n- Numerous components are used to create web applications while using ReactJS.\n- ReactJS is SEO friendly compared to other JavaScript frameworks. \n- ReactJS operates on both server and virtual DOM and is used to render and return a response on the web page. \n- Familiarity with JavaScript helps developers to work easily with ReactJS.\n\n### Why React developers love Node\nThe ease of Node.js, efficient performance, and quick development is suitable for interacting with React.js. There are more reasons why Node is used, such as:\n- Node is light-weight and has easy to install packages using the NPM package manager using the NPM registry. While using NPM, CLI developers easily install the packages.\n- Developers (both back-end, front-end, and testers) use the same language for development. \n- Due to easy access to packages, Node.js developers easily perform tasks and thus are very productive. \n- The developers with JavaScript skills easily navigate through development of applications that are easy and fast to prototype. \n- It is quick to develop familiarity with React and tools are readily available compared to other languages. \n- The same functional programming language is used in client and server side which makes it effective and conducive to use other languages such as Typescript. \n- Node.js is easy to write and can be read by humans. \n- Node.js is used to develop back-end/servers, WebApps and APIs.\n- Node.js is highly scalable compared to other servers. \n- Quick compilation with Node modules, Webpack with Node interacting together with React application. \n- Node.js has a high server load for web applications with requests and load balance. \n- Node.js promotes code reusability by developing JSON APIs for web applications.\n\nBesides React.js working closely with Node.js, it is used in the following areas: Authentication, write middlewares, Internet of Things, script and automation, create workers, support writing back-end and mobile apps, create CLI and tools in remote system monitoring. \n\n__NB:__ There are fault measures that come along with Node.js such as problems in performance monitoring, deployment, downtimes, and ways to improve performance.\n\n### How to use React Native for web development\nReact Native can be used for web development that can run in iOS, Android, and web using web standard technologies. With the foundation of React, React Native is built to handle web development with custom UI APIs such as view and text. React Native bridges the gap using API platforms to build web applications. For instance, `<view>` helps to render UI views which are compatible with web browsers. \n\n__NB:__ Not all React Native components can help develop web applications because most components are mobile-oriented for use with mobile APIs. Unlike React, React Native uses CSS in JavaScript for styles in development. The React Native has a directory library that stores all the packages ([https://reactnative.directory/?web=true](https://reactnative.directory/?web=true)). The web support packages help in web support and in the integrations for both mobile and web.\n\nThere are few ways in which React Native  can be used for web application development, such as :\n- Create React App\n- Expo\n\n#### Expo\nExpo is a universal framework for the development and support of iOS, Android, and web applications using the Expo for web ([https://docs.expo.dev/workflow/web/](https://docs.expo.dev/workflow/web/)). Expo for web helps to build well optimized web applications and provide universal SDK for both mobile and web applications. The first step is to install and add using the Expo CLI as follows:\n```\n//Inside the terminal\nnpx expo install react-dom react-native-web @expo/webpack-config\n\n//install to start the dev server\nyarn add expo\n```\n\nDevelopers can initialize the project by the following:\n```\n//with npm initialize the project\nnpx expo-cli init (app-name)\ncd (app-name)\n\n//install react-native-web and react-dom\nnpm install react-dom react-native-web\n```\n\nDeveloper can also start the dev server as indicated below:\n```\n//Start the webpack dev server\nnpx expo start –web\n\n//The app host will start the secure login: https://localhost:19006\n```\n\n#### Create React App\nTo bootstrap the web React application, the creation of a React App using the standard way. It comes with in-built support such as react-native and react-native-web in which React Native for the web application is bootstrapped with Create React App (CRA) as indicated below:\n\n```\n//application initialization\nnpx create-react-app (app-name)\n\ncd (app-name)\n\n//install react-native-web and react-dom\nnpm install react-native-web\n\n//start the server\nnpm start\n```\n\nCRA helps in optimizing the webpack configuration and package liaising for customizing and enhancing React Native with webpack and babel. CRA helps to support React Native for web application development. The webpack configurations are added in the __webpack.config.js__ file. The webpack uses JSX code and ES2015 to load babel but can also be installed as indicated below:\n```\n//install the dependencies\nnpm i webpack babel-loader babel-present-react babel-present-es2015\nnpm i webpack-dev-server –save-dev\n```\n\nAlso the resolver for the babel can be found here: [https://www.npmjs.com/package/babel-plugin-module-resolver](https://www.npmjs.com/package/babel-plugin-module-resolver).\n\n#### Benefits of React Native for web development\nReact Native helps in the following ways:\n- It is time saving and cost effective\n- Fast application development for both web browsers and mobile applications all in one codebase.\n- Supports accessibility using HTML and APIs\n- Use of RTL layouts reliable styles to help read and write.\n- With the existence of React DOM incremental adoption is enabled. \n- Build global applications.\n- Supports third-party application development.\n- React Native develops applications for both iOS and Android with a single codebase. \n\n### How to be a good React developer\nTo be a good and competent React developer you should have the skills listed below:\n- Have skills in HTML and CSS - The developer should be able to write semantic HTML tags and write CSS selectors, CSS reset, work with flexbox and media queries for well responsive web principles. \n- The developer should have skills in JSX and be able to interact with HTML, which acts as the top layer in React.createElement() API to build the entire application.\n- Understand JavaScript and ES6 with important skills such as arrays, objects, scoping, array methods, functions, event handling and DOM manipulation, using “this” keyword, callback functions, and understand the “class” keyword.\n- The React developer should be able to use Git to track changes with add, commit, push and pull, merge conflicts, and branch strategies.\n- A React developer should have skills in Node, npm, and Yarn, which is a package manager in npm\n- The developer should have Redux skills which helps to handle asynchronous states and updates for scalable applications. \n- The developer should be able to use prop-types.\n- The React developer should build applications and keep them in a portfolio to re-learn about more features and projects.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"PGvqAWgEvqP6KRy8s8xhg","type":"Asset","createdAt":"2022-09-20T00:07:20.001Z","updatedAt":"2022-09-20T00:07:20.001Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"React Developer Hacking Tips","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/PGvqAWgEvqP6KRy8s8xhg/fd6b3be44f998718b98498dfb07eafe6/React_Developer_Hacking_Tips.jpg","details":{"size":38891,"image":{"width":640,"height":427}},"fileName":"React Developer Hacking Tips.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1Gih7PRzBW0uTm7VCeS9mm","type":"Entry","createdAt":"2021-09-21T09:34:07.920Z","updatedAt":"2021-09-21T09:34:07.920Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Robinson Muiru","tcHandle":"Rokit12"}}],"upvotes":1,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6pnNzqoNsO1OZT3HLaeqOn"}},{"sys":{"type":"Link","linkType":"Entry","id":"6KP9iCELCsLWTSWirplWs2"}},{"sys":{"type":"Link","linkType":"Entry","id":"4UBqynTuBZ75IS4nkPPrOp"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3JP5vlO2F1eAwNQeUELBdB","type":"Entry","createdAt":"2022-09-14T06:52:18.262Z","updatedAt":"2022-09-14T06:52:18.262Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":58,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Want to become a ReactJs Developer? Here's what you need to know ","slug":"want-to-become-a-reactjs-developer-heres-what-you-need-to-know","type":"Article","trackCategory":["Development"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5XNV8gKk9DbppF4W0TPY76","type":"Entry","createdAt":"2019-08-27T06:08:26.689Z","updatedAt":"2021-09-02T10:58:56.367Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Front-End Development","trackParent":"Development"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}}],"tags":["ReactJS","JavaScript"],"creationDate":"2022-09-13","readTime":"9min","content":"React is a must-have skill for all front-end developers these days. It is a free, open-source, component-based JavaScript library that helps you build robust and beautiful user interfaces. It has the latest functionalities like hooks, redux, reducers, etc, that make using it very easy yet powerful. It does have a steep, although fulfilling, learning curve. React enables us to build intricate user interfaces out of discrete, little chunks of code known as \"components.\" Components are what we see on our screens. They can be tied together or used individually to form a webpage or a website's front end. React will effectively update and re-render our components as our data changes. But what is rendering? Rendering is a method that tells React what to display, therefore when our data changes the component re-runs and updates according to our changed data. Data can be passed from one component to another using props. A component can also keep an internal state data called the state. The component is re-rendered whenever the state's data changes.\n\n### How to use React developer tools\nThe React Developer tool is a very useful Chrome extension that helps the developer to debug and inspect React components, states, props, hooks, etc. It makes understanding where what is implemented very easy. It can also be used to determine if a particular website uses ReactJs or not. \n\nHow to add React Developer tools to Chrome extension  \n\nTo add the extension for Chrome follow this link: [https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi/related?hl=en-US](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi/related?hl=en-US) \n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1KfJ3BbRHi5oyi90reotTo/4f4431102fe45a9242acf89b5aaec70d/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1KfJ3BbRHi5oyi90reotTo/4f4431102fe45a9242acf89b5aaec70d/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1KfJ3BbRHi5oyi90reotTo/4f4431102fe45a9242acf89b5aaec70d/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\n- Click on \"Add extension\" \n- If you want to want to manage the extensions you can go to Extensions in the tools menu of your browser\n\n### How to determine if a website/application uses ReactJs using the extension\n\nTo do that we need to go to the extensions tool in the upper right corner of the tools menu.\n- If the icon of the React Developer tool extension is colorful then the website uses ReactJs.\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4SOWGomGFvo4gItmWMX48G/1a8a7f54943bb6b348a0a21b469d08ca/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4SOWGomGFvo4gItmWMX48G/1a8a7f54943bb6b348a0a21b469d08ca/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4SOWGomGFvo4gItmWMX48G/1a8a7f54943bb6b348a0a21b469d08ca/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\n- If it does not show a colorful icon then it does not use ReactJS.\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4FRXmDsB70DXYKJlAWhkfp/ed68a52dd26c96b9b28414f87d14460e/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4FRXmDsB70DXYKJlAWhkfp/ed68a52dd26c96b9b28414f87d14460e/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4FRXmDsB70DXYKJlAWhkfp/ed68a52dd26c96b9b28414f87d14460e/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\n### How to use the extension\nWhen you open the Chrome browser dev tools after installing the React Developer tools, you'll see two additional panels: Components and Profiler. Chrome Devtools may be accessed by right-clicking, selecting inspect from the dropdown menu, or typing Ctrl+Shift+I.\n\n__Components tab:__ The components tab's primary function is to display the React application's organizational structure. The structure demonstrates how each component is nested. We also learn more helpful details about the parts, for instance, functions, state, context, and props.\n\nWe can easily locate a component by clicking on the structure and it will highlight the component that it renders. \n\nBelow is an example of a simple to-do list React app. \n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7GC34pGUpBb9wMProiDtwt/5cde691c9a961b06ea3ae374f55948ba/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7GC34pGUpBb9wMProiDtwt/5cde691c9a961b06ea3ae374f55948ba/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/7GC34pGUpBb9wMProiDtwt/5cde691c9a961b06ea3ae374f55948ba/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\nIn the image above, when the div consisting of the input element is clicked on, it highlights the same in the rendered webpage. \n\nWe want to know what's going on inside our components most of the time. We can view a lot of helpful information about the component using React developer tools. As we use the program, we can also watch how the information changes. As an illustration, the props have changed here. \n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1GGI5CFg6AaMliePJwQXat/1fb716d85504cd3118cd7afec4974e57/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1GGI5CFg6AaMliePJwQXat/1fb716d85504cd3118cd7afec4974e57/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1GGI5CFg6AaMliePJwQXat/1fb716d85504cd3118cd7afec4974e57/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\nAs illustrated above, when we update the to-do list with two inputs, it is passed as a prop into the ColumnList component, which is then rendered on the webpage. We can see the props in the lower section in the above image. \n\n__Profile tab:__ Profiler demonstrates how long it takes for each of our app's components to render. We can determine which component is making our application sluggish. Of course, it should also perform better. Additionally, it displays if the component was rerendered and the cause of the rendering. If our app isn't performing any pointless re-renders, it's worth checking. And if they are, we can probably improve them, enhancing the speed of our React website.\n\n### What does a React developer do?\nOn the client side, React developers create web applications or employ React Native to create mobile apps. JavaScript, HTML, and CSS are essential front-end technologies that must be used for this. The tasks of React developers are versatile and can involve various stages and parts of application development.\n\n- __Developing front-end components:__ The development of UI components including icons, pictures, and motion functionality may fall under the purview of React developers. Swiping, long-pressing, and drag-and-drop are a few examples. The primary duty is to provide responsive interactive technology for dynamic websites.\n- __Working with different teams:__ They must collaborate with the client, backend developer, product, and UI teams to more fully grasp how to implement their vision for the app through software development.\n- __Testing and optimizing the software:__ React developers are also in charge of planning and building new features and ensuring cross-platform capabilities. They guarantee that the program will function effectively across a range of browsers and platforms. Before the application goes live, they must test and debug the interface software.\n\n### Why do React developers love Node?\nNode.js enables the creation of scalable and quick back-end RESTful APIs. The front-end library React, on the other hand, produces interactive user interfaces. You can quickly create sophisticated and scalable web apps using both technologies. When utilized together, they may save critical development time and help make your web app code efficient and scalable.\n\nThe most often used platform for hosting and operating web servers for React apps is Node. After all, the Node Package Manager (NPM) command-line interface CLI allows you to install any package using NPM. Because NPM CLI is trustworthy package management, installing a package from among the many that are listed in the registry is quite simple.\n\nAdditionally, Webpack and other modules are used by Node to convert a React application into a single file that is simple to compile. It is quite simple to combine your multi-file React application into a single file for production and compile JSX (using Babel) while doing so thanks to the Webpack Node package.\n\nThere are many other advantages to picking Nodejs:\n- JavaScript, which you are currently using, and Node use the same. You don't need to spend money or effort learning additional languages. True code sharing between server-side and client-side code is made possible by using the same programming language.\n- Due to React.js' high level of code reuse and availability of rapid code sharing, developing JavaScript Object Notation (JSON) APIs for the web is competent. Additionally, Node.js effectively enables this.\n- NodeJS is a good option since you don't need to worry about multithreading for a web app in today's architecture. Since the NodeJS web application you create should be stateless (you will connect to backend services via APIs), autoscaling (load balancing) them horizontally for redundancy and capacity is simple.\n\n### Can we use React Native for web development?\nFor creating genuine, natively rendered mobile applications for iOS and Android, use the JavaScript framework React Native. Although it is built on React, Facebook's JavaScript toolkit for creating user interfaces, it targets mobile platforms as opposed to browsers. But can we use it for developing web applications? Yes! React Native was primarily created for mobile apps, but it has now evolved into a cross-platform framework that enables the creation of online applications that use native API components. In fact, React Native for Windows is being used by the Windows 11 Settings app to speed up the delivery of new features and capabilities to customers while maintaining the same high level of visual quality as Windows 11. Both the Windows SDK and the macOS 10.14 SDK are supported by React Native for Windows + macOS. For all Windows 10 and later compatible devices, such as PCs, tablets, 2-in-1s, Xbox, mixed reality devices, etc., as well as the macOS desktop and laptop ecosystems, you may utilize JavaScript to create native Windows apps using this. But unfortunately, its community is still young and growing and there could be a struggle to find solutions to some of your queries.\n\n### How to be a good React developer\nParticularly if you are new to web programming, you should make sure that you have a strong foundation in vanilla JavaScript before learning React particularly. Some developers believe that launching straight into React is OK, but new developers will be more successful if they're prepared to approach learning JavaScript strategically. Learning the language should come first, followed by learning certain libraries, such as React, and then going on to learning frameworks, such as vue or angular. You may feel confident in your abilities to work with React after you are at an advanced level with the JavaScript language, which covers DOM manipulation, and are familiar with ES6.\nA few things are essential to becoming a good React developer:\n- __Reading the documentation:__ Go over every page of their documentation. Every active React developer relies on it since it is the finest online resource. It will familiarize you with the principles you need, be up to date, and, most importantly, provide you with a ton of examples to work with.\n- __Asking questions:__ It's OK to conduct a web search when you need information or run into a coding problem. All React developers perform this task by searching on StackOverflow or Github, for example. Owning your own inquiries is also crucial.\n- __Developing web apps:__ Similar to any other language or framework, you continually practise. After mastering the fundamentals of React, you continue to explore the many components of the framework. Build bigger and bigger projects, and each time you need something, look for anything new you can use.\n- __Deploying your work:__ Make sure to list all of these projects on your resume after developing larger applications. You must first deploy them on the web to achieve that. React apps are relatively easy to deploy. Simple hosting services like Netlify or Heroku, which are both free and easy as pie, are all you need to learn how to utilize. \n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"13xehp2Kyjd978mQjPk2mK","type":"Asset","createdAt":"2022-09-13T16:53:42.698Z","updatedAt":"2022-09-14T06:52:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Want to become a ReactJs Developer? Here-s what you need to know","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/13xehp2Kyjd978mQjPk2mK/fadf465eb8afc41030cf76f5c08c1c00/Want_to_become_a_ReactJs_Developer.png","details":{"size":57946,"image":{"width":599,"height":355}},"fileName":"Want_to_become_a_ReactJs_Developer.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3LNgj1WupzipANkmqToJW9"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3PkxXmLvXuh8SVwAV3kCx8"}},{"sys":{"type":"Link","linkType":"Entry","id":"5hSMpw9QA7W62VqgaiJVAo"}},{"sys":{"type":"Link","linkType":"Entry","id":"5U3eSvS9cwc4WWxhoMzhNE"}}],"openExternalLinksInNewTab":true}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4xGaY8n7TtVlO6VRAchgtX","type":"Entry","createdAt":"2020-02-19T13:20:21.395Z","updatedAt":"2024-08-07T16:36:23.022Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":106,"revision":15,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Planning an Approach to a Topcoder Problem Part 1","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":[" Div I","Problem Writing","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"\\\n[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505845&amp;mc=4)\n\\\nPlanning an approach is a finicky art; it can stump the most seasoned coders as much as it stumps the newer ones, and it can be extremely hard to put into words. It can involve many calculations and backtracks, as well as foresight, intuition, creativity, and even dumb luck, and when these factors don’t work in concert it can inject a feeling of helplessness in any coder. Sometimes it’s this feeling of helplessness that discourages coders from even attempting the Div I Hard. There are even coders that stop competing because they abhor that mental enfeeblement that comes with some problems. However, if one stays diligent, the solution is never really out of the mind’s reach. This tutorial will attempt to flesh out the concepts that will enable you to pick an approach to attack the problems with a solid plan.\n<br><br>\n### Pattern Mining and the Wrong Mindset\nIt is easy to fall into the trap of looking at the algorithm competition as a collection of diverse yet classifiable story problems. For those that have done a lot of story problems, you know that there are a limited number of forms of problems (especially in classes where the professor tends to be repetitious), and when you read a problem in a certain form, your mind says, \"Oh, this is an X problem, so I find the numbers that fit the problem and plug and chug.\" There are many times when this kind of pattern mining pays off; after a number of topcoder Single Round Matches, most coders will recognize a set of common themes and practice against them, and this method of problem attack can be successful for many matches.\n\\\nHowever, this approach is perilous. There are times when you skim the problem statement and assume it’s of type Q, then start coding and discover that your code passes none of the examples. That’s when you reread the problem and find out that this problem is unique to your experience. At that point, you are paralyzed by your practice; being unable to fit any of your problem types to the problem you are unable to proceed. You’ll see this often when there’s a really original problem that comes down the pipe, and a lot of seasoned coders fail the problem because they are blinded by their experience.\n\\\nPattern mining encourages this kind of mindset that all of the problem concepts have been exhausted, when in reality this is impossible. Only by unlearning what you have learned (to quote a certain wise old green midget) and by relearning the techniques of critical thought needed to plan an approach can your rating sustainably rise.\n<br><br>\n### Coding Kata\nHere’s your first exercise: take any problem in the Practice Rooms that you haven’t done. Fight through it, no matter how long it takes, and figure it out (use the editorial from the competition as a last resort). Get it to pass system tests, and then note how long you took to solve it. Next, clear your solution out, and try to type it in again (obviously cutting and pasting will ruin the effect). Again, get it to pass system tests. Note how long it took you to finish the second time. Then, clear it out and do the problem a third time, and again get it to pass system tests. Record this final time.\n\\\nThe time it takes for your first pass is how long it takes you when you have no expectations of the problem and no approach readily in mind. Your time on the second pass is usually the first time minus the amount of time it took you to understand the problem statement. (Don’t be surprised at the number of bugs you’ll repeat in the second pass.) That final recorded time is your potential, for you can solve it this fast in competition if you see the correct approach immediately after reading it. Let that number encourage you; it really is possible to solve some of these problems this quickly, even without super fast typing ability. But what you should also learn from the third pass is the feeling that you knew a working strategy, how the code would look, where you would tend to make the mistakes, and so on. That’s what it feels like to have the right approach, and that feeling is your goal for future problems in competition.\n\\\nIn most martial arts, there’s a practice called kata where the martial artist performs a scripted series of maneuvers in order, usually pretending to defend (or sometimes actually defending) against an onslaught of fighters, also scripted to come at the artist predictably. At first this type of practice didn’t make any sense, because it didn’t seem realistic to the chaotic nature of battle. Furthermore it seems to encourage the type of pattern mining mentioned in the previous section.  Only after triple-coding many problems for a while can one comprehend the true benefit of this coding kata.  The kata demonstrates to its practitioners the mental experience of having a plan, encouraging the type of discipline it takes to sit and think the problem through. This plan of attack is your approach, and it carries you through your coding, debugging, and submission.\n<br><br>\n### Approach Tactics\nNow that you know what an approach feels like and what its contents are, you’ll realize that you know a lot of different types of these approaches. Do you give them names? \"Oh, I used DP (dynamic programming) on that problem.\" \"Really, I could have done that one greedy?\" \"Don’t tell me that the brute-force solution would have passed in time.\" Really, the name you give an approach to a problem is a misnomer, because you can’t classify every problem as a type like just greedy or just brute-force. There are an infinite number of problem types, even more solution types, and even within each solution type there are an infinite number of different variations. This name is only a very high level summary of the actual steps it takes to get to the solution.\n\\\nIn some of the better match editorials there is a detailed description of one approach to solving the code. The next time you look at a match summary, and there is a good write-up of a problem, look for the actual steps and formation of the approach. You start to notice that there is a granularity in the steps, which suggests a method of cogitation. These grains of insight are approach tactics, or ways to formulate your approach, transform it, redirect it, and solidify it into code that get you closer to the solution or at least point you away from the wrong solution. When planning your approach, the idea is that you will use whatever approach tactics are at your disposal to decide on your approach, the idea being that you are almost prewriting the code in your head before you proceed. It’s almost as if you are convincing yourself that the code you are about to write will work.\n\\\nCoders with a math background may recognize this method of thinking, because many of these approach tactics are similar to proof writing techniques. Chess players may identify it with the use of tactics to look many moves ahead of the current one. Application designers may already be acquainted with this method when working with design patterns. In many other problem solving domains there is a similar parallel to this kind of taxonomy.\n\\\nTo practice this type of critical thinking and to decide your preferences among approach tactics, it is very useful to record the solutions to your problems, and to write up a post-SRM analysis of your own performance. Detail in words how each of your solutions work so that others could understand and reproduce the approach if they wanted to just from your explanations. Not only will writing up your approaches help you to understand your own thoughts while coding, but this kind of practice also allows you to critique your own pitfalls and work on them in a constructive manner. Remember, it is difficult to improve that which you don’t understand.\n<br><br>\n### Breaking Down a Problem\nLet’s talk about one of the most common approach tactics: breaking down a problem. This is sometimes called top-down programming: the idea is that your code must execute a series of steps in order, and from simple decisions decide if other steps are necessary, so start by planning out what your main function needs before you think about how you’ll do the subfunctions. This allows you to prototype the right functions on the fly (because you only code for what you need and no further), and also it takes your problem and fragments it into smaller, more doable parts.\n\\\nA good example of where this approach is useful is in MatArith from Round 2 of the 2002 topcoder Invitational. The problem requires you to evaluate an expression involving matrices. You know that in order to get to the numbers you’ll need to parse them (because they’re in String arrays) and pass those values into an evaluator, change it back into a String array and then you’re done. So you’ll need a print function, a parse function and a new calc function. Without thinking too hard, if you imaging having all three of these functions written already the problem could be solved in one line:\n\n```\npublic String[] calculate(String[] A, String[] B, String[] C, String eval){\n   return print(calc(parse(A),parse(B),parse(C),eval));\n}\n```\n\nThe beauty of this simplest approach tactic is the guidance of your thoughts into a functional hierarchy. You have now fragmented your work into three steps: making a parse function, a print function, and then a calc function, breaking a tough piece of code into smaller pieces. If you break down the code fine enough, you won’t have to think hard about the simplest steps, because they’ll become atomic (more on this below). In fact the rest of this particular problem will fall apart quickly by successive partitioning into functions that multiply and add the matrices, and one more that reads the eval statement correctly and applies the appropriate functions.\n\\\nThis tactic really works well against recursive problems. The entire idea behind recursive code is that you are breaking the problem into smaller pieces that look exactly like the original, and since you’re writing the original, you’re almost done. This approach tactic also plays into the hands of a method of thinking about programs called functional programming. There are several articles on the net and even a topcoder article written by radeye that talk more about this concept in depth, but the concept is that if properly fragmented, the code will pass all variable information between functions, and no data needs to be stored between steps, which prevents the possibility of side-effects (unintended changes to state variables between steps in code) that are harder to debug.\n<br><br>\n### Plan to Debug\nWhenever you use an approach you should always have a plan to debug the code that your approach will create. This is the dark underbelly of every approach tactic. There is always a way that a solution may fail, and by thinking ahead to the many ways it can break, you can prevent the bugs in the code before you type them. Furthermore, if you don’t pass examples, you know where to start looking for problems. Finally, by looking for the stress points in the code’s foundation, it becomes easier to prove to yourself that the approach is a good one.\n\\\nIn the case of a top-down approach, breaking a problem down allows you to isolate sections of the code where there may be problems, and it will allow you to group tests that break your code into sections based on the subfunction they seem to exploit the most. There is also an advantage to breaking your code into functions when you fix a bug, because that bug is fixed in every spot where the code is used. The alternative to this is when a coder copy/pastes sections of code into every place it is needed, making it harder to propagate a fix and makes the fix more error prone. Also, when you look for bugs in a top-down approach, you should look for bugs inside the functions before you look between the calls to each function. These parts make up a debugging strategy: where to look first, how to test what you think is wrong, how to validate pieces and move on. Only after sufficient practice will a debugging strategy become more intuitive to your method of attack.\n<br><br>\n### Atomic Code\nIf you arrive at a section of code that you cannot break down further this is atomic code. Hopefully you know how to code each of these sections, and these form the most common forms of atomic code. But, don’t be discouraged when you hit a kernel of the problem that you don’t know how to code; these hard-to-solve kernels are in fact what make the problem interesting, and sometimes being able to see these in advance can make the big difference between solving the problem early with the right approach and heading down the wrong path with the wrong approach, wasting a lot of time in the process.\n\\\nThe most common type of atomic code you’ll write is in the form of primitives. I’ve always been a proponent of knowing the library of your language of choice. This is where that knowledge is of utmost importance. What better way to save yourself time is there in both planning your approach and coding your solution when you know that a possibly difficult section of your code is in fact atomic and solved using a library function or class?\n\\\nThe second type of atomic code you’ll write are what I call language techniques. These are usually snippets of code committed to memory that perform a certain operation in the language, like locating the index of the first element in an array with the minimum value, or parsing a String into tokens separated by whitespace. These techniques are equally essential to planning an approach, because if you know how to do these fundamental operations intuitively, it makes more tasks in your search for a top-down approach atomic, thus making the search for the right approach shorter. In addition, it makes the segments of the code in these atomic segments less error prone. Furthermore, if you are asked to perform a task similar to one that you already know a language technique for, it makes it much easier to mutate the code to fit the situation (for example: searching for the index of the first maximal element in an array based on some heuristic is easy if you already know how to type up similar tasks). Looking for these common language techniques should become an element of your daily practice, and any atomic code should fly off your fingers as soon as you think about it.\n\\\nAs an aside, I must address the use of code libraries. I know that this is a contested topic, and many successful coders out there make use of a (sometimes encyclopedic) library as a pre-inserted segment of code before they start coding. This is totally legal (although changes to the rules after the [2004 topcoder Open](https://tco04.topcoder.com) may affect their future legality), and there are obvious advantages to using a library, mainly through the ability to declare more parts of your top-down approach atomic, and by being able to more quickly construct bottom-up fragments of code (as discussed below). It is my opinion, however, that the disadvantages of using library code outweigh the advantages. On a small note, library code executed through functions can sometimes slow your coding, because you have to make the input match the prototype of the code you’re trying to use. Library code is mostly non-mutatable, so if your library is asked to do something that isn’t expressly defined, you find yourself fumbling over a language technique or algorithm that should already be internalized. It is also possible that your library code isn’t bug-free, and debugging your library mid-competition is dangerous because you may have to propagate that change to code you’ve already submitted and also to the template before you open any more problems. Also, library use is not allowed in onsite competition. Finally, the use of library code (or macros for that manner) get you used to leaning on your library instead of your instincts of the language, making the use of normal primitives less intuitive and the understanding of other coder’s solutions during challenge phase not as thorough. If used in moderation your library can be powerful, but it is not the ultimate weapon for all terrain.\n\\\nThere may be a point where you hit a piece of atomic code that you are unable to fragment. This is when you have to pull out the thinking cap and start analyzing your current approach. Should I have broken up the tasks differently? Should I store my intermediate values differently? Or maybe this is the key to the problem that makes the problem hard? All of these things must be considered before you pound the keys. Even at these points where you realize that you’re stuck, there are ways to manipulate the problem at hand to come to an insight on how to proceed quickly, and these ways comprise the remaining approach tactics. \n\\\n__[…continue to Section 2](https://www.topcoder.com/community/data-science/data-science-tutorials/planning-an-approach-to-a-topcoder-problem-part-2/)__","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7grGsA4QB6NKhy18BmMCHX","type":"Entry","createdAt":"2020-02-19T13:03:26.091Z","updatedAt":"2020-02-19T13:03:26.091Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"leadhyena_inran","tcHandle":"leadhyena_inran"}}],"upvotes":6,"downvotes":1,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"zu5gDtaZVfEijvYd3J00I","type":"Entry","createdAt":"2020-02-19T13:25:37.391Z","updatedAt":"2022-06-29T23:13:30.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":82,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Planning an Approach to a Topcoder Problem Part 2","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":[" Div I","Problem Writing","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"\\\n[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505845&amp;mc=4)\n\\\n__[…read Section 1](https://www.topcoder.com/thrive/articles/%20Planning%20an%20Approach%20to%20a%20Topcoder%20Problem%20Part%201)__\n<br><br>\n### Bottom Up Programming\nThis technique is the antithesis to breaking down a program, and should be the first thing you start doing when you get stuck. Bottom-up programming is the process of building up primitive functions into more functional code until the solution becomes as trivial as one of the primitives. Sometimes you know that you’ll need certain functions to form a solution and if these functions are atomic or easy to break down, you can start with these functions and build your solution upward instead of breaking it down.\n\\\nIn the case of MatArith, the procedure to add and multiply matrices was given in the problem statement making it easy to follow directions and get two functions to start with. From there you could make a smaller evalMult function that multiplied matrices together using a string evaluation and variable names, then a similar evalAdd that treats each term as a block and you have an approach to solve the problem.\n\\\nIn general, it’s a very good strategy to code up any detailed procedure in the problem statement before tackling the actual problem. Examples of these are randomizer functions, any data structures you’re asked to simulate, and any operations on mathematical objects like matrices and complex numbers. You’ll find that by solving these smaller issues and then rereading the problem statement that you will understand what needs to be done much better. And sometimes, if you’re really stuck, it doesn’t hurt to write a couple atomic pieces of code that you know that you’ll need in order to convince your mind to break down the problem towards those functions. As you can see, your path to the right approach need not be linear as long as it follows your train of thought. \n\\\nAlso, in case of a hidden bug, keep in mind that any code that you write using this approach tactic should be scanned for bugs before your top-down code, because you tend to write this code first and thus at a stage where you understand the problem less than when you finish the code. This is a good rule of thumb to follow when looking for errors in your code; they usually sit in the older sections of the code, even if older is only decided by minutes or even seconds.\n<br><br>\n### Brute Force\nAny time the solution requires looking for an optimal configuration or a maximal number or any other choice of one of a finite set of objects, the simplest way to solve the problem is to try all configurations. Any time the solution requires calculating a massive calculation requiring many steps, the best way to solve it is to do every calculation as asked for in the problem. Any time the problem asks you to count the number of ways something can be done, the best way to solve it is to try every way and make a tally. In other words, the first approach to consider in any possibly time-intensive problem is the most obvious one, even if it is horribly inefficient.\n\\\nThis approach tactic, called brute force, is so called because there is no discerning thought about the method of calculation of the return value. Any time you run into this kind of an optimization problem the first thing you should do is try to figure in your head the worst possible test cases and if 8 seconds is enough time to solve each one. If so, brute force can be a very speedy and usually less error prone approach. In order to utilize brute force, you have to know enough about the programming environment to calculate an estimate how much time any calculation will take. But an estimate is just a guess, and any guess could be wrong. This is where your wisdom is forced to kick in and make a judgment call. And this particular judgment call has bitten many a coder that didn’t think it could be done brute force and couldn’t debug a fancier approach, and likewise those that didn’t figure correctly the worst of the cases to be tested for time.\n\\\nIn general, if you can’t think of a way to solve the problem otherwise, plan to use brute force. If it ends up that you are wrong, and there is a test case that takes too long, keep the brute force solution around, and while recoding the more elegant solution, use the brute-force solution to verify that your elegant code is correct in the smaller cases, knowing that its more direct approach is a good verification of these cases (being much less error-prone code).\n<br><br>\n### A Place for Algorithms\nWell-known and efficient algorithms exist for many standard problems, much like basic approaches exist for many standard word problems in math, just like standard responses exist for most common opening moves in chess. While in general it’s a bad idea to lean heavily upon your knowledge of the standard algorithms (it leads down the path of pattern mining and leaves you vulnerable to more original problems), it’s a very good idea to know the ones that come up often, especially if you can apply them to either an atomic section of code or to allow them to break your problem down.\n\\\nThis is not the place to discuss algorithms (there are big books to read and other tutorials in this series to follow that will show you the important stuff), but rather to discuss how algorithms should be used in determining an approach. It is not sufficient to know how to use an algorithm in the default sense; always strive to know any algorithms you have memorized inside and out. For example, you may run into a problem like CityLink (SRM 170 Div I Med), which uses a careful mutation of a basic graph algorithm to solve in time, whereby just coding the regular algorithm would not suffice. True understanding of how the algorithm works allows the insight needed to be able to even conceive of the right mutation.\n\\\nSo, when you study algorithms, you need to understand how the code works, how long it will take to run, what parts of the code can be changed and what effect any changes will have on the algorithm. It’s also extremely important that you know how to code the algorithm by memory before you try to use it in an approach, because without the experience of implementing an algorithm, it becomes very hard to tell whether your bugs are being caused by a faulty implementation or faulty input into the implementation. It’s also good to practice different ways to use the algorithms creatively to solve different problems, to see what works and what doesn’t. Better for an experiment with code to fall flat on its face in practice than during a competition. This is why broad-based algorithmic techniques (like divide-and-conquer, dynamic programming, greedy algorithms) are better to study first before you study your more focused algorithms because the concepts are easier to manipulate and easier to implement once you understand the procedure involved.\n<br><br>\n### Manipulating the Domain\nThis situation will become more and more familiar: you find yourself trudging through the planning stages of a problem because of the sheer amount of work involved in simulating the domain of the problem. This may be due to the inappropriateness of the presented domain, and there are times when manipulating the domain of the problem to something more convenient will create an easier or more recognizable problem. The classic example of this is the game of Fifteen (used as a problem in SRM 172). In the game of Fifteen, you have numbers from 1 to 9 of which you may claim one per turn, and if exactly three of your numbers add to 15 before exactly three of your opponent’s numbers adds to 15, then you win. For this problem, you can manipulate the domain by placing the numbers in the configuration of a 3×3 magic square (where every row, column, and diagonal add up to the same sum, in this case 15). Instantly you realize that the game of Fifteen is just the game Tic-Tac-Toe in disguise, making the game easier to play and program a solution for, because the manipulation of the domain transformed the situation of a game where you have no prior knowledge into one where you have a lot more knowledge. Some mathematicians think of this as the ABA<sup>-1</sup> approach, because the algebra suggests the proper process: first you transform the domain, then you perform your action, then (the A<sup>-1</sup>) you reverse your transformation.  This approach is very common in solving complex problems like diagonalizing matrices and solving the Rubik’s Cube.\n\\\nMost commonly this approach tactic is used to simplify basic calculations. A good example of this type of approach is HexagonIntersections from SRM 206. In this problem it was needed to find the number of tiled hexagons that touched a given line. The problem became much easier if you \"slanted\" the grid by transforming the numbers involved so that the hexagons involved had sides parallel to the x and y axis and the problem still had the same answer, thereby simplifying calculations.\n\\\nExtreme care must be taken while debugging if you manipulate the domain. Remember that the correct procedure to domain manipulation is to first manipulate the domain, then solve the problem, and then correct the domain. When you test the code, remember that either the domain must be properly reversed by the transformation before the result is returned, or the reversal must not affect the answer. Also, when looking at values inside the domain manipulation, remember that these are transformed values and not the real ones. It’s good to leave comment lines around your transformed section of code just to remind yourself of this fact.\n<br><br>\n### Unwinding the Definitions\nThis approach tactic is an old mathematician’s trick, relating to the incessant stacking of definitions upon definitions, and can be used to unravel a rather gnarly problem statement to get at the inner intended approach to the problem. The best way to do this is with code. When you read the definition of something you have never encountered before, try to think how you would code it. If the code asks you to find the simplest *grozmojt* in a set of integers, first figure out how your code would verify that something was a *grozmojt* and then figure out how to search for it, regardless if you even need to verify that something was a *grozmojt* in the solution. This is very similar to the bottom-up programming above, but taken at the definition level instead of the procedural one.\n\\\nSimulation problems fall under similar tactics, and create one of those times when those predisposed to object oriented coding styles run up the scores. The best way to manage a simulation problem is to create a simulation object that can have actions performed on it from a main function. That way you don’t worry if you passed enough state into a given function or not; since all of the information in the simulation is coming along with you, the approach becomes very convenient and reaches atomic code very quickly. This is also the correct approach to take if an algorithm needs to be simulated to count the steps needed in the algorithm (like MergeSort) or the number of objects deallocated in the execution of another algorithm (like ImmutableTrees). In these situations, the elegance of the code is usually sacrificed in the name of correctness and thoroughness, also making the approach easier to plan ahead for.\n<br><br>\n### The Problem is Doable\nAn old geometry puzzle goes like this: you have a pair of concentric circles and the only length you are given is the length of a chord of the outer circle (call the chord length x) that is tangent to the inner circle, and you are asked for the area between the circles. You respond: \"Well, if the problem is doable then the inner circle’s radius is irrelevant to the calculation, so I’ll declare it to be 0. Because the area of the inner circle is 0, or degenerates to the center of the outer circle, the chord of the outer circle passes through the center and is thus the diameter, and thus the area of the outer circle is Pi(x/2)<sup>2</sup>.\" Note that a proper geometric proof of this fact is harder to do; the sheer fact that a solution exists actually makes the problem easier. Since the writer had to write a solution for the problem, you know it’s always solvable, and this fact can be used to your advantage in an SRM.\n\\\nThis approach tactic broadens into the concept that the writer is looking for a particular type of solution, and sometimes through edits of the original problem statement this approach is given away (especially if the original problem is considered too hard for the level it’s at). Look for lowered constraints like arrays of size 20 (which many a seasoned coder will tell you is almost a codeword that the writer is looking for a brute force solution), or integers limited to between 1 and 10000 (allowing safe multiplication in ints without overflow). By leaning on the constraints you are acting similarly to the situation above, by not allowing the complexities of the problem that were trimmed off by the constraints to complicate your approach.\n\\\nSometimes the level of the problem alone will give a hint to what solution is intended. For example, look at FanFailure (from SRM 195 Div I Easy). The problem used the language of subsets and maximal and minimal, so you start to think maybe attack with brute force, and then you see the constraints opened up to 50 for the array size. 2<sup>50</sup> distinct subsets rules out brute force (better to find this out in the approach than in the code, right?) and you could look to fancier algorithms… but then you realize that this is a Div I Easy and probably isn’t as hard as it looks so you think through the greedy algorithm and decide that it probably works. This choice wouldn’t have been so obvious had it not been a Div I Easy.\n\\\nKeep in mind that these invisible cues are not objective and can’t be used to reason why an approach will work or not; they are there only to suggest what the writer’s mind was thinking. Furthermore, if the writer is evil or particularly tricky, cues of this nature may be red herrings to throw these tactics astray. As long as you temper this approach tactic with solid analysis before you go on a wild goose chase, this \"circular reasoning\" can be used to great advantage. \n<br><br>\n### Case Reduction\nSometimes the simplest problems to state are the ones that provide the most difficulty. With these types of problems it’s not unusual that the solution requires that you break up the problem not into steps but into cases. By breaking a problem up into cases of different sets of inputs you can create subproblems that can be much easier to solve. Consider the problem TeamPhoto (SRM 167 Div I Medium). This problem is simple to state, but abhorrent to solve. If you break up the problem into a series of cases, you find that where the entire problem couldn’t alone be solved by a greedy algorithm, each of the different cases could be, and you could take the best case from those optimal configurations to solve the problem.\n\\\nThe most common use of case reduction involves removing the boundary cases so that they don’t mess up a naï¿½ve solution. A good example of this is BirthdayOdds (SRM 174 Div I Easy); many people hard coded if(daysInYear==1)return 2; to avoid the possible problems with the boundary case, even if their solution would have handled it correctly without that statement. By adding that level of security, it became easier to verify that the approach they chose was correct.\n<br><br>\n### Plans Within Plans\nAs illustrated above, an approach isn’t easily stated, and is usually glossed over if reduced to a one-word label. Furthermore, there are many times when there exist levels to a problem, each of which needs to be solved before the full solution comes to light. One clear example of this is the problem MagicianTour (SRM 191 Div I Hard). There are definitely two delineated steps to this problem: the first step requires a graph search to find all connected components and their 2-coloring, and the second step requires the DP knapsack algorithm. In cases like this, it’s very helpful to remember that sometimes more than one approach tactic needs to be applied to the situation to get at the solution. Another great example is TopographicalImage (SRM 209 Div I Hard) which asks for the lowest angle that places a calculated value based on shortest path under a certain limit. To solve, note that looking for this lowest value can be approached by binary search, but there are plans within plans, and the inner plan is to apply Floyd-Warshall’s All Pairs Shortest Paths algorithm to decide if the angle is satisfactory.\n\\\nRemember also that an approach isn’t just \"Oh, I know how to break this down… Let’s go!\" The idea of planning your approach is to strategically think about: the steps in your code, how an algorithm is to be applied, how the values are to be stored and passed, how the solution will react to the worst case, where the most probable nesting places are for bugs. The idea is that if the solution is carefully planned, there is a lower chance of losing it to a challenge or during system tests. For each approach there are steps that contain plans for their steps.\n<br><br>\n### Tactical Permutation\nThere is never a right approach for all coders, and there are usually at least two ways to do a problem. Let’s look at an unsavory Division One Easy called OhamaLow (SRM 206 Div I Easy). One of the more popular ways to approach this problem is to try all combinations of hands, see if the hand combination is legal, sort the hand combination, and compare it to the best hand so far. This is a common brute-force search strategy. But it’s not the entire approach. Remember that there are plans within plans. You have to choose an approach on how to form each hand (this could be done recursively or using multiple for-loops), how to store the hands (int arrays, Strings, or even a new class), and how to compare them. There are many different ways to do each of these steps, and most of the ways to proceed with the approach will work. As seen above as well as here, there are many times where more than one approach will do the job, and these approaches are considered permutable. In fact, one way to permute the top-level brute-force search strategy is to instead of considering all possible constructible hands and picking the best one, you can construct all possible final hands in best to worst order and stop when you have found one that’s constructible. In other words you take all 5 character substrings of \"87654321\" in order and see if the shared hand and player hand can make the chosen hand, and if so return that hand. This approach also requires substeps (how to decide if the hand can be formed, how to walk the possible hands, and so on) but sometimes (and in this case it is better) you can break it down faster.\n\\\nThe only way you get to choose between two approaches is if you are able to come up with both of them. A very good way to practice looking for multiple approaches to problems is to try to solve as many of the problems in the previous SRM using two different approaches. By doing this, you stretch your mind into looking for these different solutions, increasing your chances of finding the more elegant solution, or the faster one to type, or even the one that looks easier to debug.\n<br><br>\n### Backtracking from a Flawed Approach\nAs demonstrated in the previous section, it is very possible for there to exist more than one way to plan an approach to a problem. It may even hit you in the middle of coding your approach how to more elegantly solve the problem. One of the hardest disciplines to develop while competing in topcoder Single Round Matches is the facility to stick to the approach you’ve chosen until you can prove without a shadow of a doubt that you made a mistake in the approach and the solution will not work. Remember that you are not awarded points for code elegance, or for cleverness, or for optimized code. You are granted points solely on the ability to quickly post correct code. If you come up with a more elegant solution than the one you’re in the middle of typing up, you have to make the split second analysis of how much time you’ll lose for changing your current approach, and in most cases it isn’t worth it.\n\\\nThere is no easy answer to planning the right approach the first time. If you code up a solution and you know it is right but has bugs this is much easier to repair than the sudden realization that you just went the entirely wrong direction. If you get caught in this situation, whatever you do, don’t erase your code! Relabel your main function and any subfunctions or data structures that may be affected by further changes. The reason is because while you may desire a clean slate, you must accept that some of your previous routines may be the same, and retracing your steps by retyping the same code can be counterproductive to your thinking anew. Furthermore, by keeping the old code you can test against it later looking for cases that will successfully challenge other coders using the same flawed approach.\n<br><br>\n### Conclusion\nPlanning an approach is not a science, although there is a lot of rigor in the thought involved. Rather, it is mainly educated guesswork coupled with successful planning. By being creative, economical, and thorough about your thought process you can become more successful and confident in your solutions and the time you spend thinking the problem through will save you time later in the coding and debugging. This ability to plan your code before the fingers hit the keys only develops through lots of practice, but this diligence is rewarded with an increasing ability to solve problems and eventually a sustained rating increase.\n\\\n__Mentioned in this writeup:__\n\tTCI ’02 Round 2 Div I Med – [MatArith](http://community.topcoder.com/stat?c=problem_statement&amp;pm=511&amp;rd=4335)\n\tSRM 170 Div I Med – [CityLink](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1864&amp;rd=4655)\n\tSRM 172 Div I Med – [Fifteen](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1850&amp;rd=4665)\n\tSRM 206 Div I Hard – [HexagonIntersections](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2920&amp;rd=5852)\n\tSRM 195 Div I Easy – [FanFailure](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2235&amp;rd=5070)\n\tSRM 167 Div I Med – [TeamPhoto](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1614&amp;rd=4640\")\n\tSRM 174 Div I Easy – [BirthdayOdds](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1848&amp;rd=4675)\n\tSRM 191 Div I Hard – [MagicianTour](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2346&amp;rd=4775)\n\tSRM 210 Div II Hard – [TopographicalImage](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2932&amp;rd=5856)\n\tSRM 206 Div I Easy – [OmahaLow](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2435&amp;rd=5852)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7grGsA4QB6NKhy18BmMCHX","type":"Entry","createdAt":"2020-02-19T13:03:26.091Z","updatedAt":"2020-02-19T13:03:26.091Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"leadhyena_inran","tcHandle":"leadhyena_inran"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"4xGaY8n7TtVlO6VRAchgtX","circular":true}}],"journeyPrevious":{"sys":{"type":"Link","linkType":"Entry","id":"4xGaY8n7TtVlO6VRAchgtX","circular":true}}}}],"journeyNext":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"zu5gDtaZVfEijvYd3J00I","type":"Entry","createdAt":"2020-02-19T13:25:37.391Z","updatedAt":"2022-06-29T23:13:30.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":82,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Planning an Approach to a Topcoder Problem Part 2","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":[" Div I","Problem Writing","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"\\\n[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505845&amp;mc=4)\n\\\n__[…read Section 1](https://www.topcoder.com/thrive/articles/%20Planning%20an%20Approach%20to%20a%20Topcoder%20Problem%20Part%201)__\n<br><br>\n### Bottom Up Programming\nThis technique is the antithesis to breaking down a program, and should be the first thing you start doing when you get stuck. Bottom-up programming is the process of building up primitive functions into more functional code until the solution becomes as trivial as one of the primitives. Sometimes you know that you’ll need certain functions to form a solution and if these functions are atomic or easy to break down, you can start with these functions and build your solution upward instead of breaking it down.\n\\\nIn the case of MatArith, the procedure to add and multiply matrices was given in the problem statement making it easy to follow directions and get two functions to start with. From there you could make a smaller evalMult function that multiplied matrices together using a string evaluation and variable names, then a similar evalAdd that treats each term as a block and you have an approach to solve the problem.\n\\\nIn general, it’s a very good strategy to code up any detailed procedure in the problem statement before tackling the actual problem. Examples of these are randomizer functions, any data structures you’re asked to simulate, and any operations on mathematical objects like matrices and complex numbers. You’ll find that by solving these smaller issues and then rereading the problem statement that you will understand what needs to be done much better. And sometimes, if you’re really stuck, it doesn’t hurt to write a couple atomic pieces of code that you know that you’ll need in order to convince your mind to break down the problem towards those functions. As you can see, your path to the right approach need not be linear as long as it follows your train of thought. \n\\\nAlso, in case of a hidden bug, keep in mind that any code that you write using this approach tactic should be scanned for bugs before your top-down code, because you tend to write this code first and thus at a stage where you understand the problem less than when you finish the code. This is a good rule of thumb to follow when looking for errors in your code; they usually sit in the older sections of the code, even if older is only decided by minutes or even seconds.\n<br><br>\n### Brute Force\nAny time the solution requires looking for an optimal configuration or a maximal number or any other choice of one of a finite set of objects, the simplest way to solve the problem is to try all configurations. Any time the solution requires calculating a massive calculation requiring many steps, the best way to solve it is to do every calculation as asked for in the problem. Any time the problem asks you to count the number of ways something can be done, the best way to solve it is to try every way and make a tally. In other words, the first approach to consider in any possibly time-intensive problem is the most obvious one, even if it is horribly inefficient.\n\\\nThis approach tactic, called brute force, is so called because there is no discerning thought about the method of calculation of the return value. Any time you run into this kind of an optimization problem the first thing you should do is try to figure in your head the worst possible test cases and if 8 seconds is enough time to solve each one. If so, brute force can be a very speedy and usually less error prone approach. In order to utilize brute force, you have to know enough about the programming environment to calculate an estimate how much time any calculation will take. But an estimate is just a guess, and any guess could be wrong. This is where your wisdom is forced to kick in and make a judgment call. And this particular judgment call has bitten many a coder that didn’t think it could be done brute force and couldn’t debug a fancier approach, and likewise those that didn’t figure correctly the worst of the cases to be tested for time.\n\\\nIn general, if you can’t think of a way to solve the problem otherwise, plan to use brute force. If it ends up that you are wrong, and there is a test case that takes too long, keep the brute force solution around, and while recoding the more elegant solution, use the brute-force solution to verify that your elegant code is correct in the smaller cases, knowing that its more direct approach is a good verification of these cases (being much less error-prone code).\n<br><br>\n### A Place for Algorithms\nWell-known and efficient algorithms exist for many standard problems, much like basic approaches exist for many standard word problems in math, just like standard responses exist for most common opening moves in chess. While in general it’s a bad idea to lean heavily upon your knowledge of the standard algorithms (it leads down the path of pattern mining and leaves you vulnerable to more original problems), it’s a very good idea to know the ones that come up often, especially if you can apply them to either an atomic section of code or to allow them to break your problem down.\n\\\nThis is not the place to discuss algorithms (there are big books to read and other tutorials in this series to follow that will show you the important stuff), but rather to discuss how algorithms should be used in determining an approach. It is not sufficient to know how to use an algorithm in the default sense; always strive to know any algorithms you have memorized inside and out. For example, you may run into a problem like CityLink (SRM 170 Div I Med), which uses a careful mutation of a basic graph algorithm to solve in time, whereby just coding the regular algorithm would not suffice. True understanding of how the algorithm works allows the insight needed to be able to even conceive of the right mutation.\n\\\nSo, when you study algorithms, you need to understand how the code works, how long it will take to run, what parts of the code can be changed and what effect any changes will have on the algorithm. It’s also extremely important that you know how to code the algorithm by memory before you try to use it in an approach, because without the experience of implementing an algorithm, it becomes very hard to tell whether your bugs are being caused by a faulty implementation or faulty input into the implementation. It’s also good to practice different ways to use the algorithms creatively to solve different problems, to see what works and what doesn’t. Better for an experiment with code to fall flat on its face in practice than during a competition. This is why broad-based algorithmic techniques (like divide-and-conquer, dynamic programming, greedy algorithms) are better to study first before you study your more focused algorithms because the concepts are easier to manipulate and easier to implement once you understand the procedure involved.\n<br><br>\n### Manipulating the Domain\nThis situation will become more and more familiar: you find yourself trudging through the planning stages of a problem because of the sheer amount of work involved in simulating the domain of the problem. This may be due to the inappropriateness of the presented domain, and there are times when manipulating the domain of the problem to something more convenient will create an easier or more recognizable problem. The classic example of this is the game of Fifteen (used as a problem in SRM 172). In the game of Fifteen, you have numbers from 1 to 9 of which you may claim one per turn, and if exactly three of your numbers add to 15 before exactly three of your opponent’s numbers adds to 15, then you win. For this problem, you can manipulate the domain by placing the numbers in the configuration of a 3×3 magic square (where every row, column, and diagonal add up to the same sum, in this case 15). Instantly you realize that the game of Fifteen is just the game Tic-Tac-Toe in disguise, making the game easier to play and program a solution for, because the manipulation of the domain transformed the situation of a game where you have no prior knowledge into one where you have a lot more knowledge. Some mathematicians think of this as the ABA<sup>-1</sup> approach, because the algebra suggests the proper process: first you transform the domain, then you perform your action, then (the A<sup>-1</sup>) you reverse your transformation.  This approach is very common in solving complex problems like diagonalizing matrices and solving the Rubik’s Cube.\n\\\nMost commonly this approach tactic is used to simplify basic calculations. A good example of this type of approach is HexagonIntersections from SRM 206. In this problem it was needed to find the number of tiled hexagons that touched a given line. The problem became much easier if you \"slanted\" the grid by transforming the numbers involved so that the hexagons involved had sides parallel to the x and y axis and the problem still had the same answer, thereby simplifying calculations.\n\\\nExtreme care must be taken while debugging if you manipulate the domain. Remember that the correct procedure to domain manipulation is to first manipulate the domain, then solve the problem, and then correct the domain. When you test the code, remember that either the domain must be properly reversed by the transformation before the result is returned, or the reversal must not affect the answer. Also, when looking at values inside the domain manipulation, remember that these are transformed values and not the real ones. It’s good to leave comment lines around your transformed section of code just to remind yourself of this fact.\n<br><br>\n### Unwinding the Definitions\nThis approach tactic is an old mathematician’s trick, relating to the incessant stacking of definitions upon definitions, and can be used to unravel a rather gnarly problem statement to get at the inner intended approach to the problem. The best way to do this is with code. When you read the definition of something you have never encountered before, try to think how you would code it. If the code asks you to find the simplest *grozmojt* in a set of integers, first figure out how your code would verify that something was a *grozmojt* and then figure out how to search for it, regardless if you even need to verify that something was a *grozmojt* in the solution. This is very similar to the bottom-up programming above, but taken at the definition level instead of the procedural one.\n\\\nSimulation problems fall under similar tactics, and create one of those times when those predisposed to object oriented coding styles run up the scores. The best way to manage a simulation problem is to create a simulation object that can have actions performed on it from a main function. That way you don’t worry if you passed enough state into a given function or not; since all of the information in the simulation is coming along with you, the approach becomes very convenient and reaches atomic code very quickly. This is also the correct approach to take if an algorithm needs to be simulated to count the steps needed in the algorithm (like MergeSort) or the number of objects deallocated in the execution of another algorithm (like ImmutableTrees). In these situations, the elegance of the code is usually sacrificed in the name of correctness and thoroughness, also making the approach easier to plan ahead for.\n<br><br>\n### The Problem is Doable\nAn old geometry puzzle goes like this: you have a pair of concentric circles and the only length you are given is the length of a chord of the outer circle (call the chord length x) that is tangent to the inner circle, and you are asked for the area between the circles. You respond: \"Well, if the problem is doable then the inner circle’s radius is irrelevant to the calculation, so I’ll declare it to be 0. Because the area of the inner circle is 0, or degenerates to the center of the outer circle, the chord of the outer circle passes through the center and is thus the diameter, and thus the area of the outer circle is Pi(x/2)<sup>2</sup>.\" Note that a proper geometric proof of this fact is harder to do; the sheer fact that a solution exists actually makes the problem easier. Since the writer had to write a solution for the problem, you know it’s always solvable, and this fact can be used to your advantage in an SRM.\n\\\nThis approach tactic broadens into the concept that the writer is looking for a particular type of solution, and sometimes through edits of the original problem statement this approach is given away (especially if the original problem is considered too hard for the level it’s at). Look for lowered constraints like arrays of size 20 (which many a seasoned coder will tell you is almost a codeword that the writer is looking for a brute force solution), or integers limited to between 1 and 10000 (allowing safe multiplication in ints without overflow). By leaning on the constraints you are acting similarly to the situation above, by not allowing the complexities of the problem that were trimmed off by the constraints to complicate your approach.\n\\\nSometimes the level of the problem alone will give a hint to what solution is intended. For example, look at FanFailure (from SRM 195 Div I Easy). The problem used the language of subsets and maximal and minimal, so you start to think maybe attack with brute force, and then you see the constraints opened up to 50 for the array size. 2<sup>50</sup> distinct subsets rules out brute force (better to find this out in the approach than in the code, right?) and you could look to fancier algorithms… but then you realize that this is a Div I Easy and probably isn’t as hard as it looks so you think through the greedy algorithm and decide that it probably works. This choice wouldn’t have been so obvious had it not been a Div I Easy.\n\\\nKeep in mind that these invisible cues are not objective and can’t be used to reason why an approach will work or not; they are there only to suggest what the writer’s mind was thinking. Furthermore, if the writer is evil or particularly tricky, cues of this nature may be red herrings to throw these tactics astray. As long as you temper this approach tactic with solid analysis before you go on a wild goose chase, this \"circular reasoning\" can be used to great advantage. \n<br><br>\n### Case Reduction\nSometimes the simplest problems to state are the ones that provide the most difficulty. With these types of problems it’s not unusual that the solution requires that you break up the problem not into steps but into cases. By breaking a problem up into cases of different sets of inputs you can create subproblems that can be much easier to solve. Consider the problem TeamPhoto (SRM 167 Div I Medium). This problem is simple to state, but abhorrent to solve. If you break up the problem into a series of cases, you find that where the entire problem couldn’t alone be solved by a greedy algorithm, each of the different cases could be, and you could take the best case from those optimal configurations to solve the problem.\n\\\nThe most common use of case reduction involves removing the boundary cases so that they don’t mess up a naï¿½ve solution. A good example of this is BirthdayOdds (SRM 174 Div I Easy); many people hard coded if(daysInYear==1)return 2; to avoid the possible problems with the boundary case, even if their solution would have handled it correctly without that statement. By adding that level of security, it became easier to verify that the approach they chose was correct.\n<br><br>\n### Plans Within Plans\nAs illustrated above, an approach isn’t easily stated, and is usually glossed over if reduced to a one-word label. Furthermore, there are many times when there exist levels to a problem, each of which needs to be solved before the full solution comes to light. One clear example of this is the problem MagicianTour (SRM 191 Div I Hard). There are definitely two delineated steps to this problem: the first step requires a graph search to find all connected components and their 2-coloring, and the second step requires the DP knapsack algorithm. In cases like this, it’s very helpful to remember that sometimes more than one approach tactic needs to be applied to the situation to get at the solution. Another great example is TopographicalImage (SRM 209 Div I Hard) which asks for the lowest angle that places a calculated value based on shortest path under a certain limit. To solve, note that looking for this lowest value can be approached by binary search, but there are plans within plans, and the inner plan is to apply Floyd-Warshall’s All Pairs Shortest Paths algorithm to decide if the angle is satisfactory.\n\\\nRemember also that an approach isn’t just \"Oh, I know how to break this down… Let’s go!\" The idea of planning your approach is to strategically think about: the steps in your code, how an algorithm is to be applied, how the values are to be stored and passed, how the solution will react to the worst case, where the most probable nesting places are for bugs. The idea is that if the solution is carefully planned, there is a lower chance of losing it to a challenge or during system tests. For each approach there are steps that contain plans for their steps.\n<br><br>\n### Tactical Permutation\nThere is never a right approach for all coders, and there are usually at least two ways to do a problem. Let’s look at an unsavory Division One Easy called OhamaLow (SRM 206 Div I Easy). One of the more popular ways to approach this problem is to try all combinations of hands, see if the hand combination is legal, sort the hand combination, and compare it to the best hand so far. This is a common brute-force search strategy. But it’s not the entire approach. Remember that there are plans within plans. You have to choose an approach on how to form each hand (this could be done recursively or using multiple for-loops), how to store the hands (int arrays, Strings, or even a new class), and how to compare them. There are many different ways to do each of these steps, and most of the ways to proceed with the approach will work. As seen above as well as here, there are many times where more than one approach will do the job, and these approaches are considered permutable. In fact, one way to permute the top-level brute-force search strategy is to instead of considering all possible constructible hands and picking the best one, you can construct all possible final hands in best to worst order and stop when you have found one that’s constructible. In other words you take all 5 character substrings of \"87654321\" in order and see if the shared hand and player hand can make the chosen hand, and if so return that hand. This approach also requires substeps (how to decide if the hand can be formed, how to walk the possible hands, and so on) but sometimes (and in this case it is better) you can break it down faster.\n\\\nThe only way you get to choose between two approaches is if you are able to come up with both of them. A very good way to practice looking for multiple approaches to problems is to try to solve as many of the problems in the previous SRM using two different approaches. By doing this, you stretch your mind into looking for these different solutions, increasing your chances of finding the more elegant solution, or the faster one to type, or even the one that looks easier to debug.\n<br><br>\n### Backtracking from a Flawed Approach\nAs demonstrated in the previous section, it is very possible for there to exist more than one way to plan an approach to a problem. It may even hit you in the middle of coding your approach how to more elegantly solve the problem. One of the hardest disciplines to develop while competing in topcoder Single Round Matches is the facility to stick to the approach you’ve chosen until you can prove without a shadow of a doubt that you made a mistake in the approach and the solution will not work. Remember that you are not awarded points for code elegance, or for cleverness, or for optimized code. You are granted points solely on the ability to quickly post correct code. If you come up with a more elegant solution than the one you’re in the middle of typing up, you have to make the split second analysis of how much time you’ll lose for changing your current approach, and in most cases it isn’t worth it.\n\\\nThere is no easy answer to planning the right approach the first time. If you code up a solution and you know it is right but has bugs this is much easier to repair than the sudden realization that you just went the entirely wrong direction. If you get caught in this situation, whatever you do, don’t erase your code! Relabel your main function and any subfunctions or data structures that may be affected by further changes. The reason is because while you may desire a clean slate, you must accept that some of your previous routines may be the same, and retracing your steps by retyping the same code can be counterproductive to your thinking anew. Furthermore, by keeping the old code you can test against it later looking for cases that will successfully challenge other coders using the same flawed approach.\n<br><br>\n### Conclusion\nPlanning an approach is not a science, although there is a lot of rigor in the thought involved. Rather, it is mainly educated guesswork coupled with successful planning. By being creative, economical, and thorough about your thought process you can become more successful and confident in your solutions and the time you spend thinking the problem through will save you time later in the coding and debugging. This ability to plan your code before the fingers hit the keys only develops through lots of practice, but this diligence is rewarded with an increasing ability to solve problems and eventually a sustained rating increase.\n\\\n__Mentioned in this writeup:__\n\tTCI ’02 Round 2 Div I Med – [MatArith](http://community.topcoder.com/stat?c=problem_statement&amp;pm=511&amp;rd=4335)\n\tSRM 170 Div I Med – [CityLink](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1864&amp;rd=4655)\n\tSRM 172 Div I Med – [Fifteen](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1850&amp;rd=4665)\n\tSRM 206 Div I Hard – [HexagonIntersections](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2920&amp;rd=5852)\n\tSRM 195 Div I Easy – [FanFailure](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2235&amp;rd=5070)\n\tSRM 167 Div I Med – [TeamPhoto](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1614&amp;rd=4640\")\n\tSRM 174 Div I Easy – [BirthdayOdds](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1848&amp;rd=4675)\n\tSRM 191 Div I Hard – [MagicianTour](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2346&amp;rd=4775)\n\tSRM 210 Div II Hard – [TopographicalImage](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2932&amp;rd=5856)\n\tSRM 206 Div I Easy – [OmahaLow](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2435&amp;rd=5852)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7grGsA4QB6NKhy18BmMCHX","type":"Entry","createdAt":"2020-02-19T13:03:26.091Z","updatedAt":"2020-02-19T13:03:26.091Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"leadhyena_inran","tcHandle":"leadhyena_inran"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"4xGaY8n7TtVlO6VRAchgtX","circular":true}}],"journeyPrevious":{"sys":{"type":"Link","linkType":"Entry","id":"4xGaY8n7TtVlO6VRAchgtX","circular":true}}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3rAZrsBseux2curmx1if6s","type":"Entry","createdAt":"2020-02-20T12:38:07.258Z","updatedAt":"2024-08-07T14:00:23.815Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":571,"revision":58,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part one","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505848)\n<br/>\nIn this article I’ll try to introduce you to the area of computation complexity. The article will be a bit long before we get to the actual formal definitions because I feel that the rationale behind these definitions needs to be explained as well – and that understanding the rationale is even more important than the definitions alone.\n\\\nWhy is it important?\n\\\n__Example 1.__ Suppose you were assigned to write a program to process some records your company receives from time to time. You implemented two different algorithms and tested them on several sets of test data. The processing times you obtained are in Table 1.\n<br/>\n__Table 1. Runtimes of two fictional algorithms.__\n| # of records | 10    | 20    | 50    | 100   | 1000   | 5000   |\n|--------------|-------|-------|-------|-------|--------|--------|\n| algorithm 1  | 0.00s | 0.01s | 0.05s | 0.47s | 23.92s | 47min  |\n| algorithm 2  | 0.05s | 0.05s | 0.06s | 0.11s | 0.78s  | 14.22s |\n<br/>\nIn praxis, we probably could tell which of the two implementations is better for us (as we usually can estimate the amount of data we will have to process). For the company this solution may be fine. But from the programmer’s point of view, it would be much better if he could estimate the values in Table 1 __before__ writing the actual code – then he could only implement the better algorithm.\n\\\nThe same situation occurs during programming challenges: The size of the input data is given in the problem statement. Suppose I found an algorithm. Questions I have to answer before I start to type should be: Is my algorithm worth implementing? Will it solve the largest test cases in time? If I know more algorithms solving the problem, which of them shall I implement?\n\\\nThis leads us to the question: How to compare algorithms? Before we answer this question in general, let’s return to our simple example. If we extrapolate the data in Table 1, we may assume that if the number of processed records is larger than 1000, algorithm 2 will be substantially faster. In other words, if we consider all possible inputs, algorithm 2 will be better for almost all of them.\n\\\nIt turns out that this is almost always the case – given two algorithms, either one of them is almost always better, or they are approximately the same. Thus, this will be our definition of a better algorithm. Later, as we define everything formally, this will be the general idea behind the definitions.\n\\\nA neat trick\n\\\nIf you thing about Example 1 for a while, it shouldn’t be too difficult to see that there is an algorithm with runtimes similar to those in Table 2:\n<br/>\n__Table 2. Runtimes of a new fictional algorithm.__\n| # of records | 10    | 20    | 50    | 100   | 1000  | 5000   |\n|--------------|-------|-------|-------|-------|-------|--------|\n| algorithm 3  | 0.00s | 0.01s | 0.05s | 0.11s | 0.78s | 14.22s |\n<br/>\nThe idea behind this algorithm: Check the number of records. If it is small enough, run algorithm 1, otherwise run algorithm 2.\n\\\nSimilar ideas are often used in praxis. As an example consider most of the sort() functions provided by various libraries. Often this function is an implementation of QuickSort with various improvements, such as:\n- if the number of elements is too small, run InsertSort instead (as InsertSort is faster for small inputs)\n- if the pivot choices lead to poor results, fall back to MergeSort\n\n<br/>What is efficiency?\n\\\n__Example 2.__ Suppose you have a concrete implementation of some algorithm. (The example code presented below is actually an implementation of MinSort – a slow but simple sorting algorithm.)\n<br/>\n```\nfor (int i=0; i<N; i++)\nfor (int j=i+1; j<N; j++)\nif (A[i] > A[j])\nswap( A[i], A[j] );\n```\n\\\nIf we are given an input to this algorithm (in our case, the array A and its size N), we can exactly compute the number of steps our algorithm does on this input. We could even count the processor instructions if we wanted to. However, there are too many possible inputs for this approach to be practical.\n\\\nAnd we still need to answer one important question: What is it exactly we are interested in? Most usually it is the behavior of our program in the __worst possible case__ – we need to look at the input data and to determine an upper bound on how long will it take if we run the program.\n\\\nBut then, what is the worst possible case? Surely we can always make the program run longer simply by giving it a larger input. Some of the more important questions are: What is the worst input with 700 elements? __How fast__ does the maximum runtime grow when we increase the input size?\n\\\nFormal notes on the input size\n\\\nWhat exactly is this “input size” we started to talk about? In the formal definitions this is the size of the input written in some fixed finite alphabet (with at least 2 “letters”). For our needs, we may consider this alphabet to be the numbers 0…255. Then the “input size” turns out to be exactly the size of the input file in bytes.\n\\\nUsually a part of the input is a number (or several numbers) such that the size of the input is proportional to the number.\n\\\nE.g. in Example 2 we are given an int N and an array containing N ints. The size of the input file will be roughly 5N (depending on the OS and architecture, but always linear in N).\n\\\nIn such cases, we may choose that this number will represent the size of the input. Thus when talking about problems on arrays/strings, the input size is the length of the array/string, when talking about graph problems, the input size depends both on the number of vertices (N) and the number of edges (M), etc.\n\\\nWe will adopt this approach and use N as the input size in the following parts of the article.\n\\\nThere is one tricky special case you sometimes need to be aware of. To write a (possibly large) number we need only logarithmic space. (E.g. to write 123456, we need only roughly log<sub style=\"bottom: -.25em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">10</sub>(123456) digits.) This is why the naive primality test does not run in polynomial time – its runtime is polynomial in the __size__ of the number, but not in its __number of digits__! If you didn’t understand the part about polynomial time, don’t worry, we’ll get there later.\n\\\nHow to measure efficiency?\n\\\nWe already mentioned that given an input we are able to count the number of steps an algorithm makes simply by simulating it. Suppose we do this for all inputs of size at most __N__ and find the worst of these inputs (i.e. the one that causes the algorithm to do the most steps). Let f (__N__) be this number of steps. We will call this function the time complexity, or shortly the runtime of our algorithm.\n\\\nIn other words, if we have any input of size __N__, solving it will require at most f (__N__) steps.\n\\\nLet’s return to the algorithm from Example 2. What is the worst case of size __N__? In other words, what array with __N__ elements will cause the algorithm to make the most steps? If we take a look at the algorithm, we can easily see that:\n- the first step is executed exactly N times\n- the second and third step are executed exactly N(N – 1)/2 times\n- the fourth step is executed at most N(N – 1)/2 times\n\n<br/>Clearly, if the elements in A are in descending order at the beginning, the fourth step will always be executed. Thus in this case the algorithm makes 3N(__N__ – 1)/2 + __N__ = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N steps. Therefore our algorithm has f (__N__) = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N.\n\\\nAs you can see, determining the exact function f for more complicated programs is painful. Moreover, it isn’t even necessary. In our case, clearly the -0.5N term can be neglected. It will usually be much smaller than the 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> term and it won’t affect the runtime significantly. The result “f (__N__) is roughly equal to 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>” gives us all the information we need. As we will show now, if we want to compare this algorithm with some other algorithm solving the same problem, even the constant 1.5 is not that important.\n\\\nConsider two algorithms, one with the runtime N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, the other with the runtime 0.001N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>. One can easily see that for N greater than 1 000 the first algorithm is faster – and soon this difference becomes apparent. While the first algorithm is able to solve inputs with N = 20 000 in a matter of seconds, the second one will already need several minutes on current machines.\n\\\nClearly this will occur always when one of the runtime functions grows __asymptotically faster__ than the other (i.e. when N grows beyond all bounds the limit of their quotient is zero or infinity). Regardless of the constant factors, an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> will always be better than an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub> __on almost all inputs__. And this observation is exactly what we base our formal definition on.\n\\\nFinally, formal definitions\n\\\nLet f, g be positive non-decreasing functions defined on positive integers. (Note that all runtime functions satisfy these conditions.) We say that f (N) is O(g(N)) (read: f is big-oh of g) if for some c and N0 the following condition holds:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_1.png](https://images.ctfassets.net/b5f1djy59z3a/22I9okwtiQ8w86WCCuyy2a/6b44bf4a6736db87aa793e7837a3df89/Computational_Complexity_1.png)</div>\nIn human words, f (N) is O(g(N)), if for some c almost the entire graph of the function f is below the graph of the function c.g. Note that this means that f grows at most as fast as c.g does.\n\\\nInstead of “f (N) is O(g(N))” we usually write f (N) = O(g(N)). Note that this “equation” is __not symmetric__ – the notion \" O(g(N)) = f (N)\" has no sense and \" g(N) = O(f (N))\" doesn’t have to be true (as we will see later). (If you are not comfortable with this notation, imagine O(g(N)) to be a set of functions and imagine that there is a E instead of =.)\n\\\nWhat we defined above is known as the big-oh notation and is conveniently used to specify upper bounds on function growth.\n\\\nE.g. consider the function f (N) = 3N(N – 1)/2 + N = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N from Example 2. We may say that f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) (one possibility for the constants is c = 2 and N<sub style=\"bottom: -2.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">0</sub> = 0). This means that f doesn’t grow (asymptotically) faster than N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nNote that even the exact runtime function f doesn’t give an exact answer to the question “How long will the program run on my machine?” But the important observation in the example case is that the runtime function is quadratic. If we double the input size, the runtime will increase approximately to four times the current runtime, no matter how fast our computer is.\n\\\nThe f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) upper bound gives us almost the same – it guarantees that the growth of the runtime function is at most quadratic.\n\\\nThus, we will use the O-notation to describe the time (and sometimes also memory) complexity of algorithms. For the algorithm from Example 2 we would say “The time complexity of this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” or shortly “This algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”.\n\\\nIn a similar way we defined O we may define <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">.\n\\\nWe say that f (N) is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> (g(N)) if g(N) = O(f (N)), in other words if f grows at least as fast as g.\n\\\nWe say that f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> (g(N)) if f (N) = O(g(N)) and g(N) = O(f (N)), in other words if both functions have approximately the same rate of growth.\n\\\nAs it should be obvious,  is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> used to specify lower bounds and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> is used to give a tight asymptotic bound on a function. There are other similar bounds, but these are the ones you’ll encounter most of the time.\n\\\nSome examples of using the notation:\n- 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> -0.5N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- 47N log N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- N log N + 1 000 047N = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n- All polynomials of order k are O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>).\n- The time complexity of the algorithm in Example 2 is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- If an algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), it is also O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">5</sub>).\n- Each comparision-based sorting algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N log N).\n- MergeSort run on an array with N elements does roughly N log N comparisions. Thus the time complexity of MergeSort is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N). If we trust the previous statement, this means that MergeSort is an asymptotically optimal general sorting algorithm.\n- The algorithm in Example 2 uses <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) bytes of memory.\n- The function giving my number of teeth in time is O(1).\n- A naive backtracking algorithm trying to solve chess is O(1) as the tre of positions it will examine is finite. (But of course in this case the constant hidden behind the O(1) is unbelievably large.)\n- The statement “Time complexity of this algorithm is at least O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” is meaningless. (It says: “Time complexity of this algorithm is at least at most roughly quadratic.” The speaker probably wanted to say: “Time complexity of this algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).”)\n\n<br/>When speaking about the time/memory complexity of an algorithm, instead of using the formal <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(f (n))-notation we may simply state the class of functions f belongs to. E.g. if f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N), we call the algorithm linear. More examples:\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N): logarithmic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2): quadratic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3): cubic\n- f (N) = O(Nk) for some k: polynomial\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(2N): exponential\n\n<br/>For graph problems, the complexity <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N + M) is known as “linear in the graph size”.\n\\\nDetermining execution time from an asymptotic bound\n\\\nFor most algorithms you may encounter in praxis, the constant hidden behind the O (or <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">) is usually relatively small. If an algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), you may expect that the exact time complexity is something like 10N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, not 10<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">7</sub>N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nThe same observation in other words: if the constant is large, it is usually somehow related to some constant in the problem statement. In this case it is good practice to give this constant a name and to include it in the asymptotic notation.\n\\\nAn example: The problem is to count occurences of each letter in a string of N letters. A naive algorithm passes through the whole string once for each possible letter. The size of alphabet is fixed (e.g. at most 255 in C), thus the algorithm is linear in N. Still, it is better to write that its time complexity is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S|.N), where S is the alphabet used. (Note that there is a better algorithm solving this problem in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S| + N).)\n\\\nIn a topcoder contest, an algorithm doing 1 000 000 000 multiplications runs barely in time. This fact together with the above observation and some experience with topcoder problems can help us fill the following table:\n<br/>\n__Table 3. Approximate maximum problem size solvable in 8 seconds.__\n| complexity | maximum N   |\n|------------|-------------|\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N)        | 100 000 000 |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N)  | 40 000 000  |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2)       | 10 000      |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3)       | 500         |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N4)       | 90          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(2N)       | 20          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N!)       | 11          |\n<br/>\nA note on algorithm analysis\n\\\nUsually if we present an algorithm, the best way to present its time complexity is to give a . However, it is common practice to only give an O-bound - the other bound is usually trivial, O is much easier to type and better known. Still, don’t forget that O represents only an upper bound. Usually we try to find an O-bound that’s as good as possible.\n\\\n__Example 3.__ Given is a sorted array A. Determine whether it contains two elements with the difference D. Consider the following code solving this problem:\n<br/>\n```\nint j=0;\nfor (int i=0; i<N; i++) {\nwhile ( (j<N-1) && (A[i]-A[j] > D) )\nj++;\nif (A[i]-A[j] == D) return 1;\n}\n```\n\\\nIt is easy to give an O(N2) bound for the time complexity of this algorithm – the inner while-cycle is called N times, each time we increase j at most N times. But a more careful analysis shows that in fact we can give an O(N) bound on the time complexity of this algorithm – it is sufficient to realize that during the __whole execution__ of the algorithm the command “__j++__;” is executed no more than N times.\n\\\nIf we said “this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”, we would have been right. But by saying “this algorithm is O(N)” we give more information about the algorithm.\n\\\n__Conclusion__\n\\\nWe have shown how to write bounds on the time complexity of algorithms. We have also demonstrated why this way of characterizing algorithms is natural and (usually more-or-less) sufficient.\n\\\nThe next logical step is to show how to estimate the time complexity of a given algorithm. As we have already seen in Example 3, sometimes this can be messy. It gets really messy when recursion is involved. We will address these issues in the second part of this article.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20two)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":22,"downvotes":1,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7mQBfgaWnYKbVjOp2MeCxm","type":"Entry","createdAt":"2020-02-20T12:38:10.637Z","updatedAt":"2024-07-12T17:27:18.329Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":727,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part two","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[…read Section 1](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20one)\n<br/>\nIn this part of the article we will focus on estimating the time complexity for recursive programs. In essence, this will lead to finding the order of growth for solutions of recurrence equations. Don’t worry if you don’t understand what exactly is a recurrence solution, we will explain it in the right place at the right time. But first we will consider a simpler case – programs without recursion.\n\\\nNested loops\n\\\nFirst of all let’s consider simple programs that contain no function calls. The rule of thumb to find an upper bound on the time complexity of such a program is:\n- estimate the maximum number of times each loop can be executed,\n- add these bounds for cycles following each other.\n- multiply these bounds for nested cycles/parts of code,\n\n<br/>__Example 1.__ Estimating the time complexity of a random piece of code.\n<br/>\n```\nint result=0;                           //  1\nfor (int i=0; i<N; i++)                 //  2\nfor (int j=i; j<N; j++) {             //  3\nfor (int k=0; k<M; k++) {           //  4\nint x=0;                          //  5\nwhile (x<N) { result++; x+=3; }   //  6\n}                                   //  7\nfor (int k=0; k<2*M; k++)           //  8\nif (k%7 == 4) result++;           //  9\n}                                     // 10\n```\n\\\nThe time complexity of the while-cycle in line 6 is clearly O(N) – it is executed no more than N/3 + 1 times.\n\\\nNow consider the for-cycle in lines 4-7. The variable k is clearly incremented O(M) times. Each time the whole while-cycle in line 6 is executed. Thus the total time complexity of the lines 4-7 can be bounded by O(MN).\n\\\nThe time complexity of the for-cycle in lines 8-9 is O(M). Thus the execution time of lines 4-9 is O(MN + M) = O(MN).\n\\\nThis inner part is executed O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) times – once for each possible combination of i and j. (Note that there are only N(N + 1)/2 possible values for [i, j]. Still, O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) is a correct upper bound.)\n\\\nFrom the facts above follows that the total time complexity of the algorithm in Example 1 is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.MN) = O(MN<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>).\n\\\nFrom now on we will assume that the reader is able to estimate the time complexity of simple parts of code using the method demonstrated above. We will now consider programs using recursion (i.e. a function occasionally calling itself with different parameters) and try to analyze the impact of these recursive calls on their time complexity.\n\\\nUsing recursion to generate combinatorial objects\n\\\nOne common use of recursion is to implement a backtracking algorithm to generate all possible solutions of a problem. The general idea is to generate the solution incrementally and to step back and try another way once all solutions for the current branch have been exhausted.\n\\\nThis approach is not absolutely universal, there may be problems where it is impossible to generate the solution incrementally. However, very often the set of all possible solutions of a problem corresponds to the set of all combinatorial objects of some kind. Most often it is the set of all permutations (of a given size), but other objects (combinations, partitions, etc.) can be seen from time to time.\n\\\nAs a side note, it is always possible to generate all strings of zeroes and ones, check each of them (i.e. check whether it corresponds to a valid solution) and keep the best found so far. If we can find an upper bound on the size of the best solution, this approach is finite. However, this approach is everything but fast. Don’t use it if there is __any__ other way.\n\\\n__Example 2.__ A trivial algorithm to generate all permutations of numbers 0 to N – 1.\n<br/>\n```\nvector permutation(N);\nvector used(N,0);\n\nvoid try(int which, int what) {\n// try taking the number “what” as the “which”-th element\npermutation[which] = what;\nused[what] = 1; \n\nif (which == N-1)\noutputPermutation();\nelse\n// try all possibilities for the next element\nfor (int next=0; next<N; next++)\nif (!used[next])\ntry(which+1, next); \n\nused[what] = 0;\n} \n\nint main() {\n// try all possibilities for the first element\nfor (int first=0; first<N; first++)\ntry(0,first);\n}\n```\n\\\nIn this case a trivial __lower__ bound on the time complexity is the number of possible solutions. Backtracking algorithms are usually used to solve hard problems – i.e. such that we don’t know whether a significantly more efficient solution exists. Usually the solution space is quite large and uniform and the algorithm can be implemented so that its time complexity is close to the theoretical lower bound. To get an upper bound it should be enough to check how much additional (i.e. unnecessary) work the algorithm does.\n\\\nThe number of possible solutions, and thus the time complexity of such algorithms, is usually exponential – or worse.\n\\\nDivide&conquer using recursion\n\\\nFrom the previous example we could get the feeling that recursion is evil and leads to horribly slow programs. The contrary is true. Recursion can be a very powerful tool in the design of effective algorithms. The usual way to create an effective recursive algorithm is to apply the divide & conquer paradigm – try to split the problem into several parts, solve each part separately and in the end combine the results to obtain the result for the original problem. Needless to say, the “solve each part separately” is usually implemented using recursion – and thus applying the same method again and again, until the problem is sufficiently small to be solved by brute force.\n\\\n__Example 3.__ The sorting algorithm MergeSort described in pseudocode.\n<br/>\n```\nMergeSort(sequence S) {\nif (size of S <= 1) return S;\nsplit S into S_1 and S_2 of roughly the same size;\nMergeSort(S_1);\nMergeSort(S_2);\ncombine sorted S_1 and sorted S_2 to obtain sorted S;\nreturn sorted S;\n}\n```\n\\\nClearly O(N) time is enough to split a sequence with N elements into two parts (Depending on the implementation this may be even possible in constant time.) Combining the shorter sorted sequences can be done in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N): Start with an empty S. At each moment the smallest element not yet in S is either at the beginning of S<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">1</sub> or at the beginning of S<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>. Move this element to the end of S and continue.\n\\\nThus the total time to MergeSort a sequence with N elements is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) plus the time needed to make the two recursive calls.\n\\\nLet f (N) be the time complexity of MergeSort as defined in the previous part of our article. The discussion above leads us to the following equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_2](https://images.ctfassets.net/b5f1djy59z3a/wIFnLTP3tQAICqeQk4a04/5990cf2cef5f288cef54994219575d62/Computational_Complexity_2.png)</div>\nwhere p is a linear function representing the amount of work spent on splitting the sequence and merging the results.\n\\\nBasically, this is just a recurrence equation. If you don’t know this term, please don’t be afraid. The word “recurrence” stems from the latin phrase for “to run back”. Thus the name just says that the next values of f are defined using the previous (i.e. smaller) values of f.\n\\\nWell, to be really formal, for the equation to be complete we should specify some initial values – in this case, f (1). This (and knowing the implementation-specific function p) would enable us to compute the exact values of f.\n\\\nBut as you hopefully understand by now, this is not necessarily our goal. While it is theoretically possible to compute a closed-form formula for f (N), this formula would most probably be really ugly… and we don’t really need it. We only want to find a <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">-bound (and sometimes only an O-bound) on the growth of f. Luckily, this can often be done quite easily, if you know some tricks of the trade.\n\\\nAs a consequence, we won’t be interested in the exact form of p, all we need to know is that p(N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N). Also, we don’t need to specify the initial values for the equation. We simply assume that all problem instances with small N can be solved in constant time.\n\\\nThe rationale behind the last simplification: While changing the initial values does change the solution to the recurrence equation, it usually doesn’t change its asymptotic order of growth. (If your intuition fails you here, try playing with the equation above. For example fix p and try to compute f (8), f (16) and f (32) for different values of f (1).)\n\\\nIf this would be a formal textbook, at this point we would probably have to develop some theory that would allow us to deal with the floor and ceiling functions in our equations. Instead we will simply neglect them from now on. (E.g. we can assume that each division will be integer division, rounded down.)\n\\\nA reader skilled in math is encouraged to prove that if p is a polynomial (with non-negative values on N) and q(n) = p(n + 1) then q(n) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(n)). Using this observation we may formally prove that (assuming the f we seek is polynomially-bounded) the right side of each such equation remains asymptotically the same if we replace each ceiling function by a floor function.\n\\\nThe observations we made allow us to rewrite our example equation in a more simple way:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_3](https://images.ctfassets.net/b5f1djy59z3a/1PYsoE2tQMq6IIAIokIwyk/f12615b10713f1a5bb3f2c5e3228fe8c/Computational_Complexity_3.png)\n  <p>(1)</p></div>\nNote that this is not an equation in the classical sense. As in the examples in the first part of this article, the equals sign now reads “is asymptotically equal to”. Usually there are lots of different functions that satisfy such an equation. But usually all of them will have the same order of growth – and this is exactly what we want to determine. Or, more generally, we want to find the smallest upper bound on the growth of __all possible__ functions that satisfy the given equation.\n\\\nIn the last sections of this article we will discuss various methods of solving these “equations”. But before we can do that, we need to know a bit more about logarithms.\n\\\nNotes on logarithms\n\\\nBy now, you may have already asked one of the following questions: If the author writes that some complexity is e.g. O(N log N), what is the base of the logarithm? In some cases, wouldn’t O(N log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>N) be a better bound?\n\\\nThe answer: The base of the logarithm does not matter, all logarithmic functions (with base > 1) are asymptotically equal. This is due to the well-known equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_4](https://images.ctfassets.net/b5f1djy59z3a/4MgqQ4AXx6wEUE6Iy6QE2i/f23cf25e2c3da6b8ad786f00feedcf7d/Computational_Complexity_4.png)<p>(2)</p></div>\nNote that given two bases a, b, the number 1/log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>a is just a constant, and thus the function logaN is just a constant multiple of log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>N.\n\\\nTo obtain more clean and readable expressions, we always use the notation log N inside big-Oh expressions, even if logarithms with a different base were used in the computation of the bound.\n\\\nBy the way, sadly the meaning of log N differs from country to country. To avoid ambiguity where it may occur: I use log N to denote the decadic (i.e. base-10) logarithm, ln N for the natural (i.e. base-e) logarithm, lg N for the binary logarithm and log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>N for the general case.\n\\\nNow we will show some useful tricks involving logarithms, we will need them later. Suppose a, b are given constants such that a, b > 1.\n\\\nFrom (2) we get:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_5](https://images.ctfassets.net/b5f1djy59z3a/2JQOSNo87Y6O4IYE4m6iUk/bae14f9aba4c8ae910ef544c0e04d482/Computational_Complexity_5.png)</div>\nUsing this knowledge, we can simplify the term ![new47](//images.ctfassets.net/piwi0eufbb2g/64l938UvNmbNHGd0zrr1gY/84fc017979b0aeaec5d4b2d334d19958/new47.png)\n<br/><div style=\"text-align:center;\">![new48](//images.ctfassets.net/piwi0eufbb2g/2GTJRokW8hwUUuNsVpIP0w/eeef30852f48b2905333f84a3b353085/new48.png)<p>(3)</p></div>\nThe substitution method\n\\\nThis method can be summarized in one sentence: Guess an asymptotic upper bound on f and (try to) prove it by induction.\n\\\nAs an example, we will prove that if f satisfies the equation (1) then f (N) = O(N log N).\n\\\nFrom (1) we know that:\n<br/><div style=\"text-align:center;\">![new52](//images.ctfassets.net/piwi0eufbb2g/64F3kJwlYijHjxwZtMGLlO/0d2085183ebbd4b94a35294c5843142b/new52.png)</div>\nfor some c. Now we will prove that if we take a large enough (but constant) d then for almost all N we have f (N) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> dN lg N. We will start by proving the induction step.\n\\\nAssume that f (N/2) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> d (N/2)lg(N/2). Then\n<br/><div style=\"text-align:center;\">![new57](//images.ctfassets.net/piwi0eufbb2g/5UH5U0XZkXHghwJT7ZIuqI/b77447ab9d64755777bbe264a5e1ee0e/new57.png)</div>\nIn other words, the induction step will hold as long as d > c. We are always able to choose such d.\n\\\nWe are only left with proving the inequality for some initial value N. This gets quite ugly when done formally. The general idea is that if the d we found so far is not large enough, we can always increase it to cover the initial cases.\n\\\nNote that for our example equation we won’t be able to prove it for N = 1, because lg 1 = 0. However, by taking f (N) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> dN lg N, where d is some fixed constant. Conclusion: from (1) it follows that f (N) = O(N lg N).\n\\\nThe recursion tree\n\\\nTo a beginner, the previous method won’t be very useful. To use it successfully we need to make a good guess – and to make a good guess we need some insight. The question is, how to gain this insight? Let’s take a closer look at what’s happening, when we try to evaluate the recurrence (or equivalently, when we run the corresponding recursive program).\n\\\nWe may describe the execution of a recursive program on a given input by a rooted tree. Each node will correspond to some instance of the problem the program solves. Consider an arbitrary vertex in our tree. If solving its instance requires recursive calls, this vertex will have children corresponding to the smaller subproblems we solve recursively. The root node of the tree is the input of the program, leaves represent small problems that are solved by brute force.\n\\\nNow suppose we label each vertex by the amount of work spent solving the corresponding problem (excluding the recursive calls). Clearly the runtime is exactly the sum of all labels.\n\\\nAs always, we only want an asymptotic bound. To achieve this, we may “round” the labels to make the summation easier. Again, we will demonstrate this method on examples.\n\\\n__Example 4.__ The recursion tree for MergeSort on 5 elements.\n<br/><div style=\"text-align:center;\">![tree1](//images.ctfassets.net/piwi0eufbb2g/2vEZy2el9aDX9tbgXjLJAk/b030404573d5657cbb86750fe3a08baa/tree1.png)</div>\nThe recursion tree for the corresponding recurrence equation. This time, the number inside each vertex represents the number of steps the algorithm makes there.\n<br/><div style=\"text-align:center;\">![tree2](//images.ctfassets.net/piwi0eufbb2g/6WGTZYJ4ZAPZk4uINWognb/5d1fd8d1e6253ff3faff81d01c7a737c/tree2.png)</div>\nNote that in a similar way we may sketch the general form of the recursion tree for any recurrence. Consider our old friend, the equation (1). Here we know that there is a number c such that the number of operations in each node can be bound by (c times the current value of N). Thus the tree in the example below is indeed the worst possible case.\n\\\n__Example 5.__ A worst-case tree for the general case of the recurrence equation (1).\n<br/><div style=\"text-align:center;\">![tree3](//images.ctfassets.net/piwi0eufbb2g/6yuqtsqtBEBNfwqltHQvYD/cdb2212e850d26c840f29ec08f4f5ea1/tree3.png)</div>\nNow, the classical trick from combinatorics is to sum the elements in an order different from the order in which they were created. In this case, consider an arbitrary level of the tree (i.e. a set of vertices with the same depth). It is not hard to see that the total work on each of the levels is cN.\n\\\nNow comes the second question: What is the number of levels? Clearly, the leaves correspond to the trivial cases of the algorithm. Note that the size of the problem is halved in each step. Clearly after lg N steps we are left with a trivial problem of size 1, thus the number of levels is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N).\n\\\nCombining both observations we get the final result: The total amount of work done here is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(cN x log N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n\\\nA side note. If the reader doesn’t trust the simplifications we made when using this method, he is invited to treat this method as a “way of making a good guess” and then to prove the result using the substitution method. However, with a little effort the application of this method could also be upgraded to a full formal proof.\n\\\nMore recursion trees\n\\\nBy now you should be asking: Was it really only a coincidence that the total amount of work on each of the levels in Example 5 was the same?\n\\\nThe answer: No and yes. No, there’s a simple reason why this happened, we’ll discover it later. Yes, because this is not always the case – as we’ll see in the following two examples.\n\\\n__Example 6.__ Let’s try to apply our new “recursion tree” method to solve the following recurrence equation:\n<br/><div style=\"text-align:center;\">![new72](//images.ctfassets.net/piwi0eufbb2g/ogXKwD5HVzKuddBLbSXBo/8fb141a9199787a0d2697dab5ff95fc6/new72.png)</div>\n\\\nThe recursion tree will look as follows:\n<br/><div style=\"text-align:center;\">![tree5](//images.ctfassets.net/piwi0eufbb2g/3VSFRdCsKVE7i4o9nQu2es/82fd95adec8a5b0c4246eae5cc07eb29/tree5.png)</div>\nLet’s try computing the total work for each of the first few levels. Our results:\n<br/><br/>\n| level | 1   | 2   | 3   | … |\n|-------|-----|-----|-----|---|\n| <div style=\"position:relative;top:-15px\">work</div>  | <div style=\"position:relative;top:-15px\">cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img16](//images.ctfassets.net/piwi0eufbb2g/5SEkV4yJ3iaFb6r14yaFaR/2e6260b520c7b8eaa122444a08f89458/img16.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img17](//images.ctfassets.net/piwi0eufbb2g/DXuNYbKPMbilIdFTcBwGy/a20e3ae785add765324a40219ec21e0a/img17.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"position:relative;top:-15px\">…</div> |\n<br/>\nClearly as we go deeper in the tree, the total amount of work on the current level decreases. The question is, how fast does it decrease? As we move one level lower, there will be three times that many subproblems. However, their size gets divided by 2, and thus the time to process each of them decreases to one eighth of the original time. Thus the amount of work is decreased by the factor 3/8.\n\\\nBut this means that the entries in the table above form a geometric progression. For a while assume that this progression is infinite. Then its sum would be\n<br/><div style=\"text-align:center;\">![new77](//images.ctfassets.net/piwi0eufbb2g/75cy2reJFkT2KE2vKqsoOy/31a1ec1d2eb01a571b2a03e7069681d0/new77.png)</div>\nThus the total amount of work in our tree is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) (summing the infinite sequence gives us an upper bound). But already the first element of our progression is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>). It follows that the total amount of work in our tree is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) and we are done.\n\\\nThe important generalization of this example: If the amounts of work at subsequent levels of the recursion tree form a __decreasing geometric progression__, the total amount of work is asymptotically the same as the amount of work done in the root node.\n\\\nFrom this result we can deduce an interesting fact about the (hypothetical) algorithm behind this recurrence equation: The recursive calls didn’t take much time in this case, the most time consuming part was preparing the recursive calls and/or processing the results. (I.e. this is the part that should be improved if we need a faster algorithm.)\n\\\n__Example 7.__ Now let’s try to apply our new “recursion tree” method to solve the following recurrence equation:\n<br/><div style=\"text-align:center;\">![new80](//images.ctfassets.net/piwi0eufbb2g/5Wyw3RJnFzgqlA1hK4sUzc/2198e3c1fae6addeb2d98acfb81ff3ef/new80.png)</div>\nThe recursion tree will look as follows:\n<br/><div style=\"text-align:center;\">![tree4](//images.ctfassets.net/piwi0eufbb2g/7MI5X0xGKmQU6RR8oeYVQH/3732983f075cf331bbfb7a82d7adc98d/tree4.png)</div>\nAgain, let’s try computing the total work for each of the first few levels. We get:\n<br/><br/>\n| level | 1   | 2   | 3   | … |\n|-------|-----|-----|-----|---|\n| <div style=\"position:relative;top:-15px\">work</div>  | <div style=\"position:relative;top:-15px\">cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img21](//images.ctfassets.net/piwi0eufbb2g/5CgK58HEHtfnfntlZYPcEc/98c4c0da9d0db3a545b389c4722a446c/img21.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img22](//images.ctfassets.net/piwi0eufbb2g/7Gg1ALwlj3TsB3QpIHl0Wz/2512294d503f347bd15d6441c3004835/img22.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"position:relative;top:-15px\">…</div> |\n<br/>\nThis time we have the opposite situation: As we go deeper in the tree, the total amount of work on the current level increases. As we move one level lower, there will be five times that many subproblems, each of them one third of the previous size, the processing time is linear in problem size. Thus the amount of work increased by the factor 5/3.\n\\\nAgain, we want to compute the total amount of work. This time it won’t be that easy, because the most work is done on the lowest level of the tree. We need to know its depth.\n\\\nThe lowest level corresponds to problems of size 1. The size of a problem on level k is N/3<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>. Solving the equation 1 = N/3<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub> we get k = log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>N. Note that this time we explicitly state the base of the logarithm, as this time it will be important.\n\\\nOur recursion tree has log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>N levels. Each of the levels has five times more vertices than the previous one, thus the last level has ![new89](//images.ctfassets.net/piwi0eufbb2g/1SmukeDxdG1GuSarDmDkkl/10685198c4e0867b475b048d8fd00f70/new89.png) levels. The total work done on this level is then ![new90](//images.ctfassets.net/piwi0eufbb2g/1FRsvs2MIA65AdRcG5ydDy/9bc604ebdc3fa85864d4ea5172d079f4/new90.png).\n\\\nNote that using the trick (3) we may rewrite this as ![new91](//images.ctfassets.net/piwi0eufbb2g/t6ZL1kGPMuG1y0xkuKzMK/5c054ba80b76172fc8f026c7b78f8619/new91.png).\n\\\nNow we want to sum the work done on all levels of the tree. Again, this is a geometric progression. But instead of explicitly computing the sum, we now __reverse__ it. Now we have a __decreasing__ geometric progression…and we are already in the same situation as in the previous example. Using the same reasoning we can show that the sum is asymptotically equal to the largest element.\n\\\nIt follows that the total amount of work in our tree is ![new92](//images.ctfassets.net/piwi0eufbb2g/2L64R8CZ5vytan2FAbZi5o/0ed5a6a567481f00051246d880a4f470/new92.png) and we are done.\n\\\nNote that the base-3 logarithm ends in the exponent, that’s why the base is important. If the base was different, also the result would be asymptotically different.\n\\\nThe Master Theorem\n\\\nWe already started to see a pattern here. Given a recurrence equation, take the corresponding recurrence tree and compute the amounts of work done on each level of the tree. You will get a geometric sequence. If it decreases, the total work is proportional to work done in the root node. If it increases, the total work is proportional to the number of leaves. If it remains the same, the total work is (the work done on one level) times (the number of levels).\n\\\nActually, there are a few ugly cases, but almost often one of these three cases occurs. Moreover, it is possible to prove the statements from the previous paragraph formally. The formal version of this theorem is known under the name Master Theorem.\n\\\nFor reference, we give the full formal statement of this theorem. (Note that knowing the formal proof is not necessary to __apply__ this theorem on a given recurrence equation.)\n\\\nLet a <img src=\"https://images.ctfassets.net/piwi0eufbb2g/48JqWlli2r8Wq9kJYPgGrf/7936cc3cc0cf229c233fa6da8bc6efb4/img24.png\" style=\"position:relative; top: 15px;\"> 1 and b > 1 be integer constants. Let p be a non-negative non-decreasing function. Let f be any solution of the recurrence equation\n<br/><div style=\"text-align:center;\">![new95](//images.ctfassets.net/piwi0eufbb2g/3H3wLzjQSunZVkqx9Lt9qy/f352b06489eb0d1ec164a07875e3d718/new95.png)</div>\nThen\n<br/>\n1. If ![new96](//images.ctfassets.net/piwi0eufbb2g/M0Qqw1L1K8QxwyexHNCYL/36666284053af8cd8eed43569a0c35b6/new96.png) for some ![img26](//images.ctfassets.net/piwi0eufbb2g/7b4QExfhi9RQajtgPtSS7h/6d8083fdd1327d53a2a9646cc8b8a25b/img26.png) > 0 then ![new98](//images.ctfassets.net/piwi0eufbb2g/5gBXAJoTWJB3GafLfx8mAR/1e6574f91620b3cd6497a10b91736270/new98.png)\n2. If , then f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(N)log N).\n3. If  for some  > 0, and if ap(N/b)  cp(N) for some c < 1 and for almost all N, then f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(N)).\n\n<br/>Case 1 corresponds to our Example 7. Most of the time is spent making the recursive calls and it’s the number of these calls that counts.\n\\\nCase 2 corresponds to our Example 5. The time spent making the calls is roughly equal to the time to prepare the calls and process the results. On all levels of the recursion tree we do roughly the same amount of work, the depth of the tree is always logarithmic.\n\\\nCase 3 corresponds to our Example 6. Most of the time is spent on preparing the recursive calls and processing the results. Usually the result will be asymptotically equal to the time spent in the root node.\n\\\nNote the word “usually” and the extra condition in Case 3. For this result to hold we need p to be somehow “regular” – in the sense that for each node in the recursion tree the time spent in the node must be greater than the time spent in its chidren (excluding further recursive calls). This is nothing to worry about too much, most probably all functions p you will encounter in practice will satisfy this condition (if they satisfy the first condition of Case 3).\n\\\n__Example 8.__ Let f (N) be the time Strassen’s fast matrix multiplication algorithm needs to multiply two N x N square matrices. This is a recursive algorithm, that makes 7 recursive calls, each time multiplying two (N/2) x (N/2) square matrices, and then computes the answer in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) time.\n\\\nThis leads us to the following recurrence equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_3](https://images.ctfassets.net/b5f1djy59z3a/1PYsoE2tQMq6IIAIokIwyk/f12615b10713f1a5bb3f2c5e3228fe8c/Computational_Complexity_3.png)</div>\nUsing the Master Theorem, we see that Case 1 applies. Thus the time complexity of Strassen’s algorithm is . Note that by implementing the definition of matrix multiplication we get only a <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) algorithm.\n\\\n__Example 9.__ Occasionally we may encounter the situation when the problems in the recursive calls are not of the same size. An example may be the “median-of-five” algorithm to find the k-th element of an array. It can be shown that its time complexity satisfies the recurrence equation:\n<br/><div style=\"text-align:center;\">![new110](//images.ctfassets.net/piwi0eufbb2g/74WaKVRGFyA7jAPbFrEArc/5aadd01ab15764bf5c1ed78a6f029b88/new110.png)</div>\nHow to solve it? Can the recursion tree be applied also in such asymmetric cases? Is there a more general version of Master Theorem that handles also these cases? And what should I do with the recurrence f (N) = 4f (N/4) + <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N), where the Master Theorem doesn’t apply?\n\\\nWe won’t answer these questions here. This article doesn’t claim to be the one and only reference to computational complexity. If you are already asking these questions, you understand the basics you need for programming challenges – and if you are interested in knowing more, there are good books around that can help you.\n\\\nThanks for reading this far. If you have any questions, comments, bug reports or any other feedback, please use the Round tables. I’ll do my best to answer.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":12,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3rAZrsBseux2curmx1if6s","circular":true}}],"journeyPrevious":{"sys":{"type":"Link","linkType":"Entry","id":"3rAZrsBseux2curmx1if6s","circular":true}}}}],"journeyNext":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7mQBfgaWnYKbVjOp2MeCxm","type":"Entry","createdAt":"2020-02-20T12:38:10.637Z","updatedAt":"2024-07-12T17:27:18.329Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":727,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part two","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[…read Section 1](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20one)\n<br/>\nIn this part of the article we will focus on estimating the time complexity for recursive programs. In essence, this will lead to finding the order of growth for solutions of recurrence equations. Don’t worry if you don’t understand what exactly is a recurrence solution, we will explain it in the right place at the right time. But first we will consider a simpler case – programs without recursion.\n\\\nNested loops\n\\\nFirst of all let’s consider simple programs that contain no function calls. The rule of thumb to find an upper bound on the time complexity of such a program is:\n- estimate the maximum number of times each loop can be executed,\n- add these bounds for cycles following each other.\n- multiply these bounds for nested cycles/parts of code,\n\n<br/>__Example 1.__ Estimating the time complexity of a random piece of code.\n<br/>\n```\nint result=0;                           //  1\nfor (int i=0; i<N; i++)                 //  2\nfor (int j=i; j<N; j++) {             //  3\nfor (int k=0; k<M; k++) {           //  4\nint x=0;                          //  5\nwhile (x<N) { result++; x+=3; }   //  6\n}                                   //  7\nfor (int k=0; k<2*M; k++)           //  8\nif (k%7 == 4) result++;           //  9\n}                                     // 10\n```\n\\\nThe time complexity of the while-cycle in line 6 is clearly O(N) – it is executed no more than N/3 + 1 times.\n\\\nNow consider the for-cycle in lines 4-7. The variable k is clearly incremented O(M) times. Each time the whole while-cycle in line 6 is executed. Thus the total time complexity of the lines 4-7 can be bounded by O(MN).\n\\\nThe time complexity of the for-cycle in lines 8-9 is O(M). Thus the execution time of lines 4-9 is O(MN + M) = O(MN).\n\\\nThis inner part is executed O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) times – once for each possible combination of i and j. (Note that there are only N(N + 1)/2 possible values for [i, j]. Still, O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) is a correct upper bound.)\n\\\nFrom the facts above follows that the total time complexity of the algorithm in Example 1 is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.MN) = O(MN<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>).\n\\\nFrom now on we will assume that the reader is able to estimate the time complexity of simple parts of code using the method demonstrated above. We will now consider programs using recursion (i.e. a function occasionally calling itself with different parameters) and try to analyze the impact of these recursive calls on their time complexity.\n\\\nUsing recursion to generate combinatorial objects\n\\\nOne common use of recursion is to implement a backtracking algorithm to generate all possible solutions of a problem. The general idea is to generate the solution incrementally and to step back and try another way once all solutions for the current branch have been exhausted.\n\\\nThis approach is not absolutely universal, there may be problems where it is impossible to generate the solution incrementally. However, very often the set of all possible solutions of a problem corresponds to the set of all combinatorial objects of some kind. Most often it is the set of all permutations (of a given size), but other objects (combinations, partitions, etc.) can be seen from time to time.\n\\\nAs a side note, it is always possible to generate all strings of zeroes and ones, check each of them (i.e. check whether it corresponds to a valid solution) and keep the best found so far. If we can find an upper bound on the size of the best solution, this approach is finite. However, this approach is everything but fast. Don’t use it if there is __any__ other way.\n\\\n__Example 2.__ A trivial algorithm to generate all permutations of numbers 0 to N – 1.\n<br/>\n```\nvector permutation(N);\nvector used(N,0);\n\nvoid try(int which, int what) {\n// try taking the number “what” as the “which”-th element\npermutation[which] = what;\nused[what] = 1; \n\nif (which == N-1)\noutputPermutation();\nelse\n// try all possibilities for the next element\nfor (int next=0; next<N; next++)\nif (!used[next])\ntry(which+1, next); \n\nused[what] = 0;\n} \n\nint main() {\n// try all possibilities for the first element\nfor (int first=0; first<N; first++)\ntry(0,first);\n}\n```\n\\\nIn this case a trivial __lower__ bound on the time complexity is the number of possible solutions. Backtracking algorithms are usually used to solve hard problems – i.e. such that we don’t know whether a significantly more efficient solution exists. Usually the solution space is quite large and uniform and the algorithm can be implemented so that its time complexity is close to the theoretical lower bound. To get an upper bound it should be enough to check how much additional (i.e. unnecessary) work the algorithm does.\n\\\nThe number of possible solutions, and thus the time complexity of such algorithms, is usually exponential – or worse.\n\\\nDivide&conquer using recursion\n\\\nFrom the previous example we could get the feeling that recursion is evil and leads to horribly slow programs. The contrary is true. Recursion can be a very powerful tool in the design of effective algorithms. The usual way to create an effective recursive algorithm is to apply the divide & conquer paradigm – try to split the problem into several parts, solve each part separately and in the end combine the results to obtain the result for the original problem. Needless to say, the “solve each part separately” is usually implemented using recursion – and thus applying the same method again and again, until the problem is sufficiently small to be solved by brute force.\n\\\n__Example 3.__ The sorting algorithm MergeSort described in pseudocode.\n<br/>\n```\nMergeSort(sequence S) {\nif (size of S <= 1) return S;\nsplit S into S_1 and S_2 of roughly the same size;\nMergeSort(S_1);\nMergeSort(S_2);\ncombine sorted S_1 and sorted S_2 to obtain sorted S;\nreturn sorted S;\n}\n```\n\\\nClearly O(N) time is enough to split a sequence with N elements into two parts (Depending on the implementation this may be even possible in constant time.) Combining the shorter sorted sequences can be done in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N): Start with an empty S. At each moment the smallest element not yet in S is either at the beginning of S<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">1</sub> or at the beginning of S<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>. Move this element to the end of S and continue.\n\\\nThus the total time to MergeSort a sequence with N elements is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) plus the time needed to make the two recursive calls.\n\\\nLet f (N) be the time complexity of MergeSort as defined in the previous part of our article. The discussion above leads us to the following equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_2](https://images.ctfassets.net/b5f1djy59z3a/wIFnLTP3tQAICqeQk4a04/5990cf2cef5f288cef54994219575d62/Computational_Complexity_2.png)</div>\nwhere p is a linear function representing the amount of work spent on splitting the sequence and merging the results.\n\\\nBasically, this is just a recurrence equation. If you don’t know this term, please don’t be afraid. The word “recurrence” stems from the latin phrase for “to run back”. Thus the name just says that the next values of f are defined using the previous (i.e. smaller) values of f.\n\\\nWell, to be really formal, for the equation to be complete we should specify some initial values – in this case, f (1). This (and knowing the implementation-specific function p) would enable us to compute the exact values of f.\n\\\nBut as you hopefully understand by now, this is not necessarily our goal. While it is theoretically possible to compute a closed-form formula for f (N), this formula would most probably be really ugly… and we don’t really need it. We only want to find a <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">-bound (and sometimes only an O-bound) on the growth of f. Luckily, this can often be done quite easily, if you know some tricks of the trade.\n\\\nAs a consequence, we won’t be interested in the exact form of p, all we need to know is that p(N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N). Also, we don’t need to specify the initial values for the equation. We simply assume that all problem instances with small N can be solved in constant time.\n\\\nThe rationale behind the last simplification: While changing the initial values does change the solution to the recurrence equation, it usually doesn’t change its asymptotic order of growth. (If your intuition fails you here, try playing with the equation above. For example fix p and try to compute f (8), f (16) and f (32) for different values of f (1).)\n\\\nIf this would be a formal textbook, at this point we would probably have to develop some theory that would allow us to deal with the floor and ceiling functions in our equations. Instead we will simply neglect them from now on. (E.g. we can assume that each division will be integer division, rounded down.)\n\\\nA reader skilled in math is encouraged to prove that if p is a polynomial (with non-negative values on N) and q(n) = p(n + 1) then q(n) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(n)). Using this observation we may formally prove that (assuming the f we seek is polynomially-bounded) the right side of each such equation remains asymptotically the same if we replace each ceiling function by a floor function.\n\\\nThe observations we made allow us to rewrite our example equation in a more simple way:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_3](https://images.ctfassets.net/b5f1djy59z3a/1PYsoE2tQMq6IIAIokIwyk/f12615b10713f1a5bb3f2c5e3228fe8c/Computational_Complexity_3.png)\n  <p>(1)</p></div>\nNote that this is not an equation in the classical sense. As in the examples in the first part of this article, the equals sign now reads “is asymptotically equal to”. Usually there are lots of different functions that satisfy such an equation. But usually all of them will have the same order of growth – and this is exactly what we want to determine. Or, more generally, we want to find the smallest upper bound on the growth of __all possible__ functions that satisfy the given equation.\n\\\nIn the last sections of this article we will discuss various methods of solving these “equations”. But before we can do that, we need to know a bit more about logarithms.\n\\\nNotes on logarithms\n\\\nBy now, you may have already asked one of the following questions: If the author writes that some complexity is e.g. O(N log N), what is the base of the logarithm? In some cases, wouldn’t O(N log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>N) be a better bound?\n\\\nThe answer: The base of the logarithm does not matter, all logarithmic functions (with base > 1) are asymptotically equal. This is due to the well-known equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_4](https://images.ctfassets.net/b5f1djy59z3a/4MgqQ4AXx6wEUE6Iy6QE2i/f23cf25e2c3da6b8ad786f00feedcf7d/Computational_Complexity_4.png)<p>(2)</p></div>\nNote that given two bases a, b, the number 1/log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>a is just a constant, and thus the function logaN is just a constant multiple of log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>N.\n\\\nTo obtain more clean and readable expressions, we always use the notation log N inside big-Oh expressions, even if logarithms with a different base were used in the computation of the bound.\n\\\nBy the way, sadly the meaning of log N differs from country to country. To avoid ambiguity where it may occur: I use log N to denote the decadic (i.e. base-10) logarithm, ln N for the natural (i.e. base-e) logarithm, lg N for the binary logarithm and log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>N for the general case.\n\\\nNow we will show some useful tricks involving logarithms, we will need them later. Suppose a, b are given constants such that a, b > 1.\n\\\nFrom (2) we get:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_5](https://images.ctfassets.net/b5f1djy59z3a/2JQOSNo87Y6O4IYE4m6iUk/bae14f9aba4c8ae910ef544c0e04d482/Computational_Complexity_5.png)</div>\nUsing this knowledge, we can simplify the term ![new47](//images.ctfassets.net/piwi0eufbb2g/64l938UvNmbNHGd0zrr1gY/84fc017979b0aeaec5d4b2d334d19958/new47.png)\n<br/><div style=\"text-align:center;\">![new48](//images.ctfassets.net/piwi0eufbb2g/2GTJRokW8hwUUuNsVpIP0w/eeef30852f48b2905333f84a3b353085/new48.png)<p>(3)</p></div>\nThe substitution method\n\\\nThis method can be summarized in one sentence: Guess an asymptotic upper bound on f and (try to) prove it by induction.\n\\\nAs an example, we will prove that if f satisfies the equation (1) then f (N) = O(N log N).\n\\\nFrom (1) we know that:\n<br/><div style=\"text-align:center;\">![new52](//images.ctfassets.net/piwi0eufbb2g/64F3kJwlYijHjxwZtMGLlO/0d2085183ebbd4b94a35294c5843142b/new52.png)</div>\nfor some c. Now we will prove that if we take a large enough (but constant) d then for almost all N we have f (N) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> dN lg N. We will start by proving the induction step.\n\\\nAssume that f (N/2) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> d (N/2)lg(N/2). Then\n<br/><div style=\"text-align:center;\">![new57](//images.ctfassets.net/piwi0eufbb2g/5UH5U0XZkXHghwJT7ZIuqI/b77447ab9d64755777bbe264a5e1ee0e/new57.png)</div>\nIn other words, the induction step will hold as long as d > c. We are always able to choose such d.\n\\\nWe are only left with proving the inequality for some initial value N. This gets quite ugly when done formally. The general idea is that if the d we found so far is not large enough, we can always increase it to cover the initial cases.\n\\\nNote that for our example equation we won’t be able to prove it for N = 1, because lg 1 = 0. However, by taking f (N) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> dN lg N, where d is some fixed constant. Conclusion: from (1) it follows that f (N) = O(N lg N).\n\\\nThe recursion tree\n\\\nTo a beginner, the previous method won’t be very useful. To use it successfully we need to make a good guess – and to make a good guess we need some insight. The question is, how to gain this insight? Let’s take a closer look at what’s happening, when we try to evaluate the recurrence (or equivalently, when we run the corresponding recursive program).\n\\\nWe may describe the execution of a recursive program on a given input by a rooted tree. Each node will correspond to some instance of the problem the program solves. Consider an arbitrary vertex in our tree. If solving its instance requires recursive calls, this vertex will have children corresponding to the smaller subproblems we solve recursively. The root node of the tree is the input of the program, leaves represent small problems that are solved by brute force.\n\\\nNow suppose we label each vertex by the amount of work spent solving the corresponding problem (excluding the recursive calls). Clearly the runtime is exactly the sum of all labels.\n\\\nAs always, we only want an asymptotic bound. To achieve this, we may “round” the labels to make the summation easier. Again, we will demonstrate this method on examples.\n\\\n__Example 4.__ The recursion tree for MergeSort on 5 elements.\n<br/><div style=\"text-align:center;\">![tree1](//images.ctfassets.net/piwi0eufbb2g/2vEZy2el9aDX9tbgXjLJAk/b030404573d5657cbb86750fe3a08baa/tree1.png)</div>\nThe recursion tree for the corresponding recurrence equation. This time, the number inside each vertex represents the number of steps the algorithm makes there.\n<br/><div style=\"text-align:center;\">![tree2](//images.ctfassets.net/piwi0eufbb2g/6WGTZYJ4ZAPZk4uINWognb/5d1fd8d1e6253ff3faff81d01c7a737c/tree2.png)</div>\nNote that in a similar way we may sketch the general form of the recursion tree for any recurrence. Consider our old friend, the equation (1). Here we know that there is a number c such that the number of operations in each node can be bound by (c times the current value of N). Thus the tree in the example below is indeed the worst possible case.\n\\\n__Example 5.__ A worst-case tree for the general case of the recurrence equation (1).\n<br/><div style=\"text-align:center;\">![tree3](//images.ctfassets.net/piwi0eufbb2g/6yuqtsqtBEBNfwqltHQvYD/cdb2212e850d26c840f29ec08f4f5ea1/tree3.png)</div>\nNow, the classical trick from combinatorics is to sum the elements in an order different from the order in which they were created. In this case, consider an arbitrary level of the tree (i.e. a set of vertices with the same depth). It is not hard to see that the total work on each of the levels is cN.\n\\\nNow comes the second question: What is the number of levels? Clearly, the leaves correspond to the trivial cases of the algorithm. Note that the size of the problem is halved in each step. Clearly after lg N steps we are left with a trivial problem of size 1, thus the number of levels is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N).\n\\\nCombining both observations we get the final result: The total amount of work done here is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(cN x log N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n\\\nA side note. If the reader doesn’t trust the simplifications we made when using this method, he is invited to treat this method as a “way of making a good guess” and then to prove the result using the substitution method. However, with a little effort the application of this method could also be upgraded to a full formal proof.\n\\\nMore recursion trees\n\\\nBy now you should be asking: Was it really only a coincidence that the total amount of work on each of the levels in Example 5 was the same?\n\\\nThe answer: No and yes. No, there’s a simple reason why this happened, we’ll discover it later. Yes, because this is not always the case – as we’ll see in the following two examples.\n\\\n__Example 6.__ Let’s try to apply our new “recursion tree” method to solve the following recurrence equation:\n<br/><div style=\"text-align:center;\">![new72](//images.ctfassets.net/piwi0eufbb2g/ogXKwD5HVzKuddBLbSXBo/8fb141a9199787a0d2697dab5ff95fc6/new72.png)</div>\n\\\nThe recursion tree will look as follows:\n<br/><div style=\"text-align:center;\">![tree5](//images.ctfassets.net/piwi0eufbb2g/3VSFRdCsKVE7i4o9nQu2es/82fd95adec8a5b0c4246eae5cc07eb29/tree5.png)</div>\nLet’s try computing the total work for each of the first few levels. Our results:\n<br/><br/>\n| level | 1   | 2   | 3   | … |\n|-------|-----|-----|-----|---|\n| <div style=\"position:relative;top:-15px\">work</div>  | <div style=\"position:relative;top:-15px\">cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img16](//images.ctfassets.net/piwi0eufbb2g/5SEkV4yJ3iaFb6r14yaFaR/2e6260b520c7b8eaa122444a08f89458/img16.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img17](//images.ctfassets.net/piwi0eufbb2g/DXuNYbKPMbilIdFTcBwGy/a20e3ae785add765324a40219ec21e0a/img17.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"position:relative;top:-15px\">…</div> |\n<br/>\nClearly as we go deeper in the tree, the total amount of work on the current level decreases. The question is, how fast does it decrease? As we move one level lower, there will be three times that many subproblems. However, their size gets divided by 2, and thus the time to process each of them decreases to one eighth of the original time. Thus the amount of work is decreased by the factor 3/8.\n\\\nBut this means that the entries in the table above form a geometric progression. For a while assume that this progression is infinite. Then its sum would be\n<br/><div style=\"text-align:center;\">![new77](//images.ctfassets.net/piwi0eufbb2g/75cy2reJFkT2KE2vKqsoOy/31a1ec1d2eb01a571b2a03e7069681d0/new77.png)</div>\nThus the total amount of work in our tree is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) (summing the infinite sequence gives us an upper bound). But already the first element of our progression is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>). It follows that the total amount of work in our tree is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) and we are done.\n\\\nThe important generalization of this example: If the amounts of work at subsequent levels of the recursion tree form a __decreasing geometric progression__, the total amount of work is asymptotically the same as the amount of work done in the root node.\n\\\nFrom this result we can deduce an interesting fact about the (hypothetical) algorithm behind this recurrence equation: The recursive calls didn’t take much time in this case, the most time consuming part was preparing the recursive calls and/or processing the results. (I.e. this is the part that should be improved if we need a faster algorithm.)\n\\\n__Example 7.__ Now let’s try to apply our new “recursion tree” method to solve the following recurrence equation:\n<br/><div style=\"text-align:center;\">![new80](//images.ctfassets.net/piwi0eufbb2g/5Wyw3RJnFzgqlA1hK4sUzc/2198e3c1fae6addeb2d98acfb81ff3ef/new80.png)</div>\nThe recursion tree will look as follows:\n<br/><div style=\"text-align:center;\">![tree4](//images.ctfassets.net/piwi0eufbb2g/7MI5X0xGKmQU6RR8oeYVQH/3732983f075cf331bbfb7a82d7adc98d/tree4.png)</div>\nAgain, let’s try computing the total work for each of the first few levels. We get:\n<br/><br/>\n| level | 1   | 2   | 3   | … |\n|-------|-----|-----|-----|---|\n| <div style=\"position:relative;top:-15px\">work</div>  | <div style=\"position:relative;top:-15px\">cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img21](//images.ctfassets.net/piwi0eufbb2g/5CgK58HEHtfnfntlZYPcEc/98c4c0da9d0db3a545b389c4722a446c/img21.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img22](//images.ctfassets.net/piwi0eufbb2g/7Gg1ALwlj3TsB3QpIHl0Wz/2512294d503f347bd15d6441c3004835/img22.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"position:relative;top:-15px\">…</div> |\n<br/>\nThis time we have the opposite situation: As we go deeper in the tree, the total amount of work on the current level increases. As we move one level lower, there will be five times that many subproblems, each of them one third of the previous size, the processing time is linear in problem size. Thus the amount of work increased by the factor 5/3.\n\\\nAgain, we want to compute the total amount of work. This time it won’t be that easy, because the most work is done on the lowest level of the tree. We need to know its depth.\n\\\nThe lowest level corresponds to problems of size 1. The size of a problem on level k is N/3<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>. Solving the equation 1 = N/3<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub> we get k = log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>N. Note that this time we explicitly state the base of the logarithm, as this time it will be important.\n\\\nOur recursion tree has log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>N levels. Each of the levels has five times more vertices than the previous one, thus the last level has ![new89](//images.ctfassets.net/piwi0eufbb2g/1SmukeDxdG1GuSarDmDkkl/10685198c4e0867b475b048d8fd00f70/new89.png) levels. The total work done on this level is then ![new90](//images.ctfassets.net/piwi0eufbb2g/1FRsvs2MIA65AdRcG5ydDy/9bc604ebdc3fa85864d4ea5172d079f4/new90.png).\n\\\nNote that using the trick (3) we may rewrite this as ![new91](//images.ctfassets.net/piwi0eufbb2g/t6ZL1kGPMuG1y0xkuKzMK/5c054ba80b76172fc8f026c7b78f8619/new91.png).\n\\\nNow we want to sum the work done on all levels of the tree. Again, this is a geometric progression. But instead of explicitly computing the sum, we now __reverse__ it. Now we have a __decreasing__ geometric progression…and we are already in the same situation as in the previous example. Using the same reasoning we can show that the sum is asymptotically equal to the largest element.\n\\\nIt follows that the total amount of work in our tree is ![new92](//images.ctfassets.net/piwi0eufbb2g/2L64R8CZ5vytan2FAbZi5o/0ed5a6a567481f00051246d880a4f470/new92.png) and we are done.\n\\\nNote that the base-3 logarithm ends in the exponent, that’s why the base is important. If the base was different, also the result would be asymptotically different.\n\\\nThe Master Theorem\n\\\nWe already started to see a pattern here. Given a recurrence equation, take the corresponding recurrence tree and compute the amounts of work done on each level of the tree. You will get a geometric sequence. If it decreases, the total work is proportional to work done in the root node. If it increases, the total work is proportional to the number of leaves. If it remains the same, the total work is (the work done on one level) times (the number of levels).\n\\\nActually, there are a few ugly cases, but almost often one of these three cases occurs. Moreover, it is possible to prove the statements from the previous paragraph formally. The formal version of this theorem is known under the name Master Theorem.\n\\\nFor reference, we give the full formal statement of this theorem. (Note that knowing the formal proof is not necessary to __apply__ this theorem on a given recurrence equation.)\n\\\nLet a <img src=\"https://images.ctfassets.net/piwi0eufbb2g/48JqWlli2r8Wq9kJYPgGrf/7936cc3cc0cf229c233fa6da8bc6efb4/img24.png\" style=\"position:relative; top: 15px;\"> 1 and b > 1 be integer constants. Let p be a non-negative non-decreasing function. Let f be any solution of the recurrence equation\n<br/><div style=\"text-align:center;\">![new95](//images.ctfassets.net/piwi0eufbb2g/3H3wLzjQSunZVkqx9Lt9qy/f352b06489eb0d1ec164a07875e3d718/new95.png)</div>\nThen\n<br/>\n1. If ![new96](//images.ctfassets.net/piwi0eufbb2g/M0Qqw1L1K8QxwyexHNCYL/36666284053af8cd8eed43569a0c35b6/new96.png) for some ![img26](//images.ctfassets.net/piwi0eufbb2g/7b4QExfhi9RQajtgPtSS7h/6d8083fdd1327d53a2a9646cc8b8a25b/img26.png) > 0 then ![new98](//images.ctfassets.net/piwi0eufbb2g/5gBXAJoTWJB3GafLfx8mAR/1e6574f91620b3cd6497a10b91736270/new98.png)\n2. If , then f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(N)log N).\n3. If  for some  > 0, and if ap(N/b)  cp(N) for some c < 1 and for almost all N, then f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(N)).\n\n<br/>Case 1 corresponds to our Example 7. Most of the time is spent making the recursive calls and it’s the number of these calls that counts.\n\\\nCase 2 corresponds to our Example 5. The time spent making the calls is roughly equal to the time to prepare the calls and process the results. On all levels of the recursion tree we do roughly the same amount of work, the depth of the tree is always logarithmic.\n\\\nCase 3 corresponds to our Example 6. Most of the time is spent on preparing the recursive calls and processing the results. Usually the result will be asymptotically equal to the time spent in the root node.\n\\\nNote the word “usually” and the extra condition in Case 3. For this result to hold we need p to be somehow “regular” – in the sense that for each node in the recursion tree the time spent in the node must be greater than the time spent in its chidren (excluding further recursive calls). This is nothing to worry about too much, most probably all functions p you will encounter in practice will satisfy this condition (if they satisfy the first condition of Case 3).\n\\\n__Example 8.__ Let f (N) be the time Strassen’s fast matrix multiplication algorithm needs to multiply two N x N square matrices. This is a recursive algorithm, that makes 7 recursive calls, each time multiplying two (N/2) x (N/2) square matrices, and then computes the answer in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) time.\n\\\nThis leads us to the following recurrence equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_3](https://images.ctfassets.net/b5f1djy59z3a/1PYsoE2tQMq6IIAIokIwyk/f12615b10713f1a5bb3f2c5e3228fe8c/Computational_Complexity_3.png)</div>\nUsing the Master Theorem, we see that Case 1 applies. Thus the time complexity of Strassen’s algorithm is . Note that by implementing the definition of matrix multiplication we get only a <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) algorithm.\n\\\n__Example 9.__ Occasionally we may encounter the situation when the problems in the recursive calls are not of the same size. An example may be the “median-of-five” algorithm to find the k-th element of an array. It can be shown that its time complexity satisfies the recurrence equation:\n<br/><div style=\"text-align:center;\">![new110](//images.ctfassets.net/piwi0eufbb2g/74WaKVRGFyA7jAPbFrEArc/5aadd01ab15764bf5c1ed78a6f029b88/new110.png)</div>\nHow to solve it? Can the recursion tree be applied also in such asymmetric cases? Is there a more general version of Master Theorem that handles also these cases? And what should I do with the recurrence f (N) = 4f (N/4) + <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N), where the Master Theorem doesn’t apply?\n\\\nWe won’t answer these questions here. This article doesn’t claim to be the one and only reference to computational complexity. If you are already asking these questions, you understand the basics you need for programming challenges – and if you are interested in knowing more, there are good books around that can help you.\n\\\nThanks for reading this far. If you have any questions, comments, bug reports or any other feedback, please use the Round tables. I’ll do my best to answer.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":12,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3rAZrsBseux2curmx1if6s","circular":true}}],"journeyPrevious":{"sys":{"type":"Link","linkType":"Entry","id":"3rAZrsBseux2curmx1if6s","circular":true}}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"42EqzCmxzAjBaHFqz8rtv1","type":"Entry","createdAt":"2022-03-15T09:25:22.380Z","updatedAt":"2024-08-03T09:07:25.162Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":45,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Longest Growing Path in a Matrix","slug":"longest-growing-path-in-a-matrix","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Rte82DJ0sXfUl9RRcJ2O3","type":"Entry","createdAt":"2019-09-18T07:37:35.298Z","updatedAt":"2019-09-18T07:37:35.298Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Dynamic Programming","trackParent":"Competitive Programming"}}],"tags":["C++","Matrix"],"creationDate":"2022-03-15","readTime":"9min","content":"### About the problem:\nReturn the length of the longest growing path in a matrix of n x m integers.\nYou can travel in one of four directions from each cell: left, right, up, or down. You are not permitted to travel diagonally or outside the boundaries.\n\n### References\nThis problem is considered a common interview question asked in companies like Google and Facebook. Therefore, before getting started with solutions, I recommend you give it a try on [Leetcode](https://leetcode.com/problems/longest-increasing-path-in-a-matrix/).\n\n__Example 1:__\nInput: \\[\\[6,8,9\\],\\[5,1,3\\],\\[7,6,4\\]\\]\nOutput: 5\nExplanation: Longest growing path is 1 -> 5 -> 6 -> 8 -> 9\n\n__Example 2:__\nInput: \\[\\[8,3,7,9\\],\\[2,5,1,3\\]\\]\nOutput: 3\nExplanation: Longest growing path is 1 -> 3 -> 9 or 3 -> 7 -> 9\n\n### Approach #1: DFS + DP\nThe simple recursive solution can be found here. We are simply iterating over the matrix and traversing in a DFS fashion for up, down, left, and right with some constraints from each index of the matrix. At every recursive call, make sure that the traversing indexes, i,j, are always within the length bound, and that the previous element was not greater than the current element. If that happens, we are just going to return 0 and not continue on that route.\nWe are saving the path or number of items covered in each call, and then just returning the maximum of them, i.e. the maximum count out of the four directions we're permitted to move in.\n\n__Code:__\n```cpp\nint dp[201][201];\nint dx[4]={0,0,-1,1};\nint dy[4]={1,-1,0,0};\n\nint solve(int r,int c,vector<vector<int>> &matrix)\n{\n    if(dp[r][c]>0)return dp[r][c];\n    int curr=matrix[r][c];\n    int m=0;\n\n    for(int i=0;i<4;i++){\n        int x = r + dx[i];\n        int y = c + dy[i];\n        if(x >= matrix.size() || y>= matrix[0].size() || x<0 || y <0 || matrix[x][y] <= matrix[r][c]) continue;\n\n        m = max(m,solve(x,y,matrix));\n    }\n\n    return dp[r][c]=m+1;\n}\n\nint longestGrowingPath(vector<vector<int>>& matrix) {\n    if(matrix.size()==0)\n        return 0;\n    int n=matrix.size(),m=matrix[0].size();\n\n    int ans=0;\n\n    for(int i=0;i<n;i++)\n        for(int j=0;j<m;j++){\n            int inc=solve(i,j,matrix);\n            ans=max(ans,inc);\n    }\n\n    return ans;\n}\n```\n\n__Time complexity:__ O(4mn) = O(mn), we are making four recursive calls for every index i,j of matrix.\n__Space complexity:__ O(mn), to store the dp array.\n\n### Approach #2: Topological sort\nConduct a standard topological sort of the graph, noting the maximum depth we can reach.\nFor topological sorting, we start with all vertices of 0 indegrees, visit them, and decrement their adjacent neighbor's indegrees by 1. If any of them are now 0, add them to our queue.\n\n### Algorithm:\n1. Increase the indegrees of the smaller values that are related to the larger value that is near the four directions.\n2. Push the coordinates with indegree 0 into the queue,\n3. By decreasing indegree values, you may explore these co-ordinariates and eliminate them from the graph.\n4. Check if it touches 0 after decrementing them, and if it does, add it to the queue.\n5. The ultimate solution will be determined by the depth of the bfs performed.\n\n__Code:__\n```cpp\nint indegree[201][201];\nint dx[4]={0,0,-1,1};\nint dy[4]={1,-1,0,0};\n\nint longestGrowingPath(vector<vector<int>>& matrix) {\n    if(matrix.size()==0)\n        return 0;\n\n    int n=matrix.size();\n    int m=matrix[0].size();\n\n    for(int i=0;i<n;i++)\n        for(int j=0;j<m;j++)\n            for(int d =0;d<4;d++)\n            {\n                int nx=i+dx[d];\n                int ny=j+dy[d];\n\n                if(nx>=0 && ny>=0 && nx<n && ny<m && matrix[nx][ny]>matrix[i][j])\n                    indegree[i][j]++;\n            }\n\n    queue<pair<int,int>> q;\n\n    for(int i=0;i<n;i++)\n        for(int j=0;j<m;j++)\n            if(indegree[i][j]==0)\n                q.push({i,j});\n\n    int ans=0;\n    while(!q.empty()){\n\n        int s=q.size();\n        for(int i=0;i<s;i++)\n        {\n            auto [a,b]=q.front();\n            q.pop();\n            for(int d =0;d<4;d++)\n            {\n                int nx= a+dx[d];\n                int ny= b+dy[d];\n                if(nx>=0 && ny>=0 && nx<n &&ny<m )\n                    if(matrix[nx][ny]<matrix[a][b] && --indegree[nx][ny]==0)\n                        q.push({nx,ny});\n            }\n        }\n        ans++;\n    }\n\n    return ans;\n}\n```\n__Time complexity:__ O(4mn) = O(mn), we are tracing through the matrix at least once.\n__Space complexity:__ O(mn), to store the dp array.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"27rs0Lz9k49ITcQO1hnXsx","type":"Asset","createdAt":"2022-03-15T09:18:22.355Z","updatedAt":"2022-03-15T09:18:22.355Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"interpolation (2)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/27rs0Lz9k49ITcQO1hnXsx/2b6f8fd61c2399d2c0a9c65249afe559/interpolation__2_.jpeg","details":{"size":20289,"image":{"width":455,"height":431}},"fileName":"interpolation (2).jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5WDqV2dANBrT2sl8nK0BDZ","type":"Entry","createdAt":"2022-01-12T16:39:15.593Z","updatedAt":"2022-01-12T16:39:15.593Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":" Riya Kumari","tcHandle":"fornaxxx"}}],"upvotes":4,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5TqRULfnIOllJzEDD4l4FG","type":"Entry","createdAt":"2022-03-08T09:52:16.111Z","updatedAt":"2022-09-01T05:08:50.923Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":48,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"N-th Tribonacci Number","slug":"n-th-tribonacci-number","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Rte82DJ0sXfUl9RRcJ2O3","type":"Entry","createdAt":"2019-09-18T07:37:35.298Z","updatedAt":"2019-09-18T07:37:35.298Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Dynamic Programming","trackParent":"Competitive Programming"}},{"sys":{"type":"Link","linkType":"Entry","id":"5WVdjexpOgcs2bMMKJM2kH"}}],"tags":["C++"],"creationDate":"2022-03-08","readTime":"7min","content":"### About the problem:\nJust like the Fibonacci sequence, which can be defined as F<sub>n</sub> = F<sub>n-1</sub> + F<sub>n-2</sub> where F\\[0\\] = 0, F\\[1\\] = 1, the Tribonacci sequence can be defined as T<sub>n</sub> = T<sub>n-1</sub> + T<sub>n-2</sub> + T<sub>n-3</sub> where T\\[0\\] = 1, T\\[1\\] = 1,T\\[2\\] = 1. Here we are provided with a number and we are to return T<sub>n</sub>.\n\n__Example 1:__\nInput: 15\nOutput: 3136\n\n__Example 2:__\nInput: 26\nOutput: 2555757\n\n### Approach #1: Recursion, Brute Force\nIn this approach, we simply make recursion for the last three values for every n.\n\nCode:\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\n\nint getTrib(int n){\n    if (n == 0)\n        return 0;\n\n    if (n == 1 || n == 2)\n        return 1;\n\n    return getTrib(n-1)+getTrib(n-2)+getTrib(n-3);\n}\n\nint main(){\n\n    int n;\n    cin >> n;\n\n    cout << getTrib(n);\n}\n```\n\n__Time complexity:__ O(3n), we make three recursion calls for every n resulting in an exponential complexity.\n\n### Approach #2: Dynamic Programing\nIn the previous approach, we made calls for the same n again and again, so now we just store the values of n, as we have already calculated the answer, and simply return the calculated value when called.\nWe have discussed both top-down and bottom-up approaches here.\n\nCode:\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\nconst int N = 1e5;\n\nint trib[N];\n\nint getTribRecursive(int n){\n    if (n == 0)\n        return 0;\n\n    if (n == 1 || n == 2)\n        return 1;\n\n    if(trib[n]!=-1) return trib[n];\n\n    return trib[n] = getTribRecursive(n-1)+getTribRecursive(n-2)+getTribRecursive(n-3);\n}\n\nint getTribIterative(int n){\n\n    trib[0] = 0;\n    trib[1] = trib[2] = 1;\n\n    for (int i = 3; i <=n; i++)\n        trib[i] = trib[i - 1] + trib[i - 2] + trib[i - 3];\n\n    return trib[n];   \n}\n\nint main(){\n\n    int n;\n    cin >> n;\n\n    memset(trib,-1,sizeof trib);\n    // Recursive DP approach i.e, memorization\n    cout << getTribRecursive(n) << endl;\n\n    // Iterative DP approach\n    cout << getTribIterative(n) << endl;\n}\n```\n\n__Time complexity:__ O(n), both the above solutions have a linear runtime complexity.\n\n### Approach #3: Space Efficient\nThe above approach has an O(n) space complexity for storing the values of subproblems. We can reduce it to O(1) as we only need to store the last three values for calculating the values of next.\n\nCode:\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\n\nint getTrib(int n){\n    if (n == 0)\n        return 0;\n\n    if (n < 3)\n        return 1;\n\n    int x = 0, y = 1,z = 1,ans;\n\n    for (int i = 3; i <=n; i++){\n        ans = x + y + z;\n            x = y;\n            y = z;\n            z = ans;\n    }\n    return ans;\n}\n\nint main(){\n\n    int n;\n    cin >> n;\n\n    cout << getTrib(n) << endl;\n\n}\n```\n\n__Time complexity:__ O(n)\n__Space complexity:__ O(1), only three variables are used.\n\n### Approach #4: Matrix Exponentiation\nTo solve recurrence relations like Fibonacci or, in this case, Tribonacci, matrix exponentiation can be employed.\n\nCode:\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\n\nvector<vector<int>> M = {{1,1,1},\n                        {1,0,0},\n                        {0,1,0}};\nvector<vector<int>> matrixMul(const vector<vector<int>> &A, const vector<vector<int>> &B) {\n    int n = A.size(),m=B.size(),o=B[0].size();\n\n    vector<vector<int>> C(m, vector<int>(o, 0));\n\n    for(int i=0;i<n;++i)\n        for(int k=0;k<m;++k)\n            for(int j=0;j<o;++j)\n                C[i][j] = C[i][j] + A[i][k] * B[k][j]; \n\n    return C;\n}\n\nvector<vector<int>> matrixPow(const vector<vector<int>> &A, int k) {\n    if(k == 0) {\n        vector<vector<int>> C(A.size(), vector<int>(A.size(), 0));\n        for(int i=0; i < A.size(); ++i) C[i][i] = 1;\n        return C;\n    }\n    if(k == 1) return A;\n\n    vector<vector<int>> C = matrixPow(A, k/2);\n    C = matrixMul(C, C);\n    if(k%2 == 1) return matrixMul(C,A);\n    return C;\n}\n\nint getTrib(int n) {\n    if(n == 0) return 0;\n    if(n<3) return 1;\n\n    int a = 0,b = 1,c = 1;\n\n    vector<vector<int>> C = matrixPow(M, n-2);\n\n    return matrixMul(C, {\n        {c},\n        {b},\n        {a}\n    })[0][0];\n}\n\nint main(){\n\n    int n;\n    cin >> n;\n    cout << getTrib(n) << endl;\n}\n```\n\nWe have three equations:\nf(n) = f(n-1) + f(n-2) + f(n-3)\nf(n-1) = f(n-1)\nf(n-2) = f(n-2)\n\nBy turning them into a matrix relation we get:\n\n| f(n)   |     | 1 1 1 |     | f(n-1) |\n| f(n-1) |  =  | 1 0 0 |  *  | f(n-2) |\n| f(n-2) |     | 0 1 0 |     | f(n-3) |\n\nSince we can compute a matrix exponent by O(log(n)), simplify the relation into exponents.\n\n| f(n)   |     | 1 1 1 |^(n-2)     | f(2) |\n| f(n-1) |  =  | 1 0 0 |       *   | f(1) |\n| f(n-2) |     | 0 1 0 |           | f(0) |\n\nThe matrix multiplication cost is k^3, k=3. So the total cost is O(k^3log(n)).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"a3l0Zo35J49OubdaXhw4v","type":"Asset","createdAt":"2022-03-08T09:45:18.283Z","updatedAt":"2022-03-08T09:45:35.718Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"interpolation (1)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/a3l0Zo35J49OubdaXhw4v/7ba5af4d80e65266c2603ac5aaf8e4bf/interpolation__1_.jpeg","details":{"size":20289,"image":{"width":455,"height":431}},"fileName":"interpolation (1).jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":3,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3lwBHWCkVXIu8uGg0P7MnK"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2FyFPuf9ftL4DguU4YFcoe","type":"Entry","createdAt":"2020-02-19T12:59:58.263Z","updatedAt":"2022-07-11T04:33:32.572Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":148,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Find a Solution","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["SRM","Flood Fill","Problem","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"30 min","content":"[Discuss this article in the forums.](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505843)\n<br/>\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#straightforward\">Straight-forward problems that don’t require a special technique</a>\n<a href=\"#bfs\">Breadth First Search (BFS)</a>\n<a href=\"#floodfill\">Flood Fill</a><\n<a href=\"#bruteNback\">Brute Force and Backtracking</a>\n<a href=\"#bruteforce\">Brute Force</a>\n<a href=\"#backtracking\">Backtracking</a>\n<a href=\"#dp\">Dynamic Programming</a>\n<a href=\"#harddrills\">Hard Drills</a>\n<a href=\"#maximumflow\">Maximum Flow</a>\n<a href=\"#optimal\">Optimal Pair Matching</a>\n<a href=\"#lp\">Linear Programming (Simplex)</a>\n<a href=\"#conclusion\">Conclusion</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nWith many Topcoder problems, the solutions may be found instantly just by reading their descriptions. This is possible thanks to a collection of common traits that problems with similar solutions often have. These traits serve as excellent hints for experienced problem solvers that are able to observe them. The main focus of this article is to teach the reader to be able to observe them too.\n\\\n<a name=\"straightforward\" id=\"straightforward\"></a> __Straight-forward problems that don’t require any special technique (e.g. simulation, searching, sorting etc.)__\n\tIn most cases, these problems will ask you to perform some step by step, straight-forward tasks. Their constraints are not high, and not too low. In most cases the first problems (the easiest ones) in topcoder Single Rounds Matches are of this kind. They test mostly how fast and properly you code, and not necessarily your algorithmic skills.\n\\\nMost simple problems of this type are those that ask you just to execute all steps described in the statement.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BusinessTasks](http://community.topcoder.com/stat?c=problem_statement&pm=1585&rd=6535) – SRM 236 Div 1:__\nN tasks are written down in the form of a circular list, so the first task is adjacent to the last one. A number n is also given. Starting with the first task, move clockwise (from element 1 in the list to element 2 in the list and so on), counting from 1 to n. When your count reaches n, remove that task from the list and start counting from the next available task. Repeat this procedure until one task remains. Return it.\n</div>\n\\\nFor N&lt;=1000 this problem is just a matter of coding, no special algorithm is needed – do this operation step by step until one item is left. Usually these types of problems have a much smaller N, and so we’ll not consider cases where N is very big and for which complicated solution may be needed. Remember that in topcoder competitions even around 100 millions sets of simple operations (i.e. some multiplications, attributions or if statements) will run in allowed time.\n\\\nThis category of problems also includes those that need some simple searches.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[TallPeople](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2923&amp;rd=5854) – SRM 208 Div 1:__\nA group of people stands before you arranged in rows and columns. Looking from above, they form an R by C rectangle of people. Your job is to return 2 specific heights – the first is computed by finding the shortest person in each row, and then finding the tallest person among them (the \"tallest-of-the-shortest\"); and the second is computed by finding the tallest person in each column, and then finding the shortest person among them (the \"shortest-of-the-tallest\").\n</div>\n\\\nAs you see this is a really simple search problem. What you have to do is just to follow the steps described in the statement and find those 2 needed heights. Other TC problems may ask you to sort a collection of items by respecting certain given rules. These problems may be also included in this category, because they too are straight-forward – just sort the items respecting the rules! You can do that with a simple O(N^2) sorting algorithm, or use standard sorting algorithm that exist in your coding language. It’s just a matter of coding.\n<br/>\n__Other example(s):__\n\t__[MedalTable](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2922&amp;rd=5855) – SRM 209 Div 1__.\n<br/>\n\\\n<a name=\"bfs\" id=\"bfs\"></a> __Breadth First Search (BFS)__\n\nProblems that use BFS usually ask to find the fewest number of steps (or the shortest path) needed to reach a certain end point (state) from the starting one. Besides this, certain ways of passing from one point to another are offered, all of them having the same cost of 1 (sometimes it may be equal to another number). Often there is given a N x M table (formed of N lines and M columns) where certain cells are passable and others are impassable, and the target of the problem is to find the shortest time/path needed to reach the end point from the start one. Such tables may represent mazes, maps, cities, and other similar things. These may be considered as classical BFS problems. Because BFS complexity is in most cases linear (sometimes quadratic, or N logN), constraints of N (or M) could be high – even up to 1 million.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[SmartWordToy](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3935&amp;rd=6532) – SRM 233 Div 1:__\nA word composed of four Latin lowercase letters is given. With a single button click you can change any letter to the previous or next letter in alphabetical order (for example ‘c’ can be changed to ‘b’ or ‘d’). The alphabet is circular, thus ‘a’ can become ‘z’, and ‘z’ can become ‘a’ with one click.<br/>\nA collection of constraints is also given, each defining a set of forbidden words. A constraint is composed of 4 strings of letters. A word is forbidden if each of its characters is contained in corresponding string of a single constraint, i.e. first letter is contained in the first string, the second letter – in the second string, and so on. For example, the constraint \"lf a tc e\" defines the words \"late\", \"fate\", \"lace\" and \"face\".<br/>\nYou should find the minimum number of button presses required to reach the word finish from the word start without passing through forbidden words, or return -1 if this is not possible.\n</div>\n\\\n__Problem hints:__\n* Words can be considered as states. There are at most 26^4 different words composed of 4 letters (thus a linear complexity will run in allowed time).\n* There are some ways to pass from one state to another.\n* The cost of passing from a state to another is always 1 (i.e. a single button click).\n* You need to find the minimum number of steps required to reach the end state from start state.\n\nEverything indicates us that it’s a problem solved by the help of a BFS. Similar things can be found in any other BFS problems. Now let’s see an interesting case of BFS problems.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[CaptureThemAll](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2915&amp;rd=5853) – SRM 207 Div 2 (3rd problem):__\nHarry is playing a chess game. He has one knight, and his opponent Joe has a queen and a rook. Find the minimum number of steps that Harry’s knight has to jump so that it captures both the queen and the rook.\n</div>\n\n__Problem hints:__ At first sight this may seem like dynamic programming or backtracking. But as always, take a look into the text of the statement. After a while you should observe the following things: \n\n* A table is given.\n* The knight can jump from one cell to some of its neighbors.\n* The cost of passing from a cell to another is always 1 (just one jump).\n* You need to find the minimum number of steps (jumps).\n\nGiven this information we can see that the problem can be easily solved by the help of BFS. Don’t get confused by the fact that connected points are represented by unconnected cells. Think of cells as points in a graph, or states (whatever you want) – and in order to pass from one point to another, the knight should be able to jump from the first to the second point.\n\nNotice again that the most revealing hint about the BFS solution is the cost of 1 for any jump.\n\nTrain yourself in finding the hints of a BFS problem in following examples:\n\n__Other example(s):__\n__[RevolvingDoors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3064&amp;rd=5869) – SRM 223 Div 1__.\n__[WalkingHome](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3444&amp;rd=5868) – SRM 222 Div 1__.\n__[TurntableService](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3117&amp;rd=5865) – SRM 219 Div 1__.\n<br/>\n\\\n<a name=\"floodfill\" id=\"floodfill\"></a> __Flood Fill__\nSometimes you may encounter problems that are solved by the help of Flood Fill, a technique that uses BFS to find all reachable points. The thing that makes them different from BFS problems described above is that a minimum path/cost is not needed.\nFor example, imagine a maze where 1 represents impassable cells and 0 passable cells. You need to find all cells that are reachable from the upper-left corner. The solution is very simple – take one-by-one a visited vertex, add its unvisited neighbors to the queue of visited vertices and proceed with the next one while the queue is still populated. Note that in most cases a DFS (Depth First Search) will not work for such problems due to stack overflows. Better use a BFS. For inexperienced users it may seem harder to implement, but after a little training it becomes a \"piece of cake\". A good example of such problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[grafixMask](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2998&amp;rd=5857) – SRM 211 Div 1:__\nA 400 x 600 bitmap is given. A set of rectangles covers certain parts of this bitmap (the corners of rectangles have integer coordinates). You need to find all contiguous uncovered areas, including their sizes.\n</div>\n\n__Problem hints:__ What do we have here?\n* A map (table)\n* Certain points are impassable (those covered by given rectangles)\n* Contiguous areas need to be found\n\nIt is easy to understand that a problem with such a statement needs a Flood Fill. Usually problems using it are very easy to detect.\n\\\n<a name=\"bruteNback\" id=\"bruteNback\"></a> __Brute Force and Backtracking__\nI have placed these 2 techniques in the same category because they are very similar.  Both do the same thing – try all possible cases (situations) and choose the best one, or count only those that are needed (depending on the problem). Practically, Backtracking is just more advanced and optimized than Brute Force. It usually uses recursion and is applied to problems having low constraints (for example N&lt;=20). </p>\n\\\n<a name=\"bruteforce\" id=\"bruteforce\"></a>\n__Brute Force__\nThere are many problems that can be solved by the help of a simple brute force. Note that the limits must not be high. How does a brute force algorithm work? Actually, it tries all possible situations and selects the best one. It’s simple to construct and usually simple to implement. If there is a problem that asks to enumerate or find all possible ways (situations) of doing a certain thing, and that doesn’t have high limits – then it’s most probably a brute force problem.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[GeneralChess](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2430&amp;rd=5072) – SRM 197 Div 1:__\nYou are given some knights (at most 8), with their positions on the table (-10000&lt;=x, y&lt;=10000). You need to find all positions to place another one, so that it threatens all given pieces. \n</div>\n\n__Problem hints:__ Well, this is one of the easiest examples. So which are the hints of this statement?\n* You need to find all possible situations (positions) that satisfy a certain rule (threatens all given pieces).\n* The limits are very low – only 8 knights are at most given.\n\nIt’s a common Brute Force problem’s statement. Note that x and y limits are not relevant, because you need only try all positions that threaten one of the knights. For each of these positions see if the knight placed at that position threatens all others too.\n\nAnother interesting problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[LargestCircle](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3005&amp;rd=5858) – SRM 212 Div 2 (3rd problem):__\nGiven a regular square grid, with some number of squares marked, find the largest circle you can draw on the grid that does not pass through any of the marked squares. The circle must be centered on a grid point (the corner of a square) and the radius must be an integer. Return the radius of the circle.\n<br/> The size of the grid is at most 50.\n</div>\n\n__Problem hints:__ And again one of the most important hints is the low limit of the size of the grid – only 50. This problem is possible to be solved with the help of the Brute Force because for each cell you can try to find the circle whose center is situated in that cell and that respects the rules. Among all of these circles found, select the one that has the greatest radius.\n\nComplexity analysis: there are at most 50×50 cells, a circle’s radius is an integer and can be at most 25 units, and you need a linear time (depending on your implementation) for searching the cells situated on the border of the circle. Total complexity is low and thus you can apply a simple Brute Force here.\n\n__Other example(s):__\n__[Cafeteria](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3080&amp;rd=6518) - SRM 229 Div 1__\n__[WordFind](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3972&amp;rd=6521) - SRM 232 Div 1__\n\n<a name=\"backtracking\" id=\"backtracking\"></a> __Backtracking__\nThis technique may be used in many types of problems.  Just take a look at the limits (N, M and other main parameters). They serve as the main hint of a backtrack problem. If these are very small and you haven’t found a solution that’s easier to implement – then just don’t waste your time on searching it and implement a straight-forward backtracking solution.\n\nUsually problems of this kind ask you to find (similarly to Brute Force):\n1. Every possible configuration (subset) of items. These configurations should respect some given rules.\n2. The \"best\" configuration (subset) that respects some given rules.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BridgeCrossing](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1599&amp;rd=4535) – SRM 146 Div 2 (3rd problem):__\nA group of people is crossing an old bridge. The bridge cannot hold more than two people at once. It is dark, so they can’t walk without a flashlight, and they only have one flashlight! Furthermore, the time needed to cross the bridge varies among the people in the group. When people walk together, they always walk at the speed of the slowest person. It is impossible to toss the flashlight across the bridge, so one person always has to go back with the flashlight to the others. What is the minimum amount of time needed to get all the people across the bridge?\n<br/> There are at most 6 people.\n</div>\n\n__Problem hints:__\n* First look at the constraints – there are at most ONLY 6 people! It’s enough for generating all possible permutations, sets etc.\n* There are different possible ways to pass the people from one side to another and you need to find the best one.\n\nThis is of course a problem solved with a backtracking: at the beginning choose any 2 people to pass the bridge first, and after that at each step try to pass any of those that have been left on the start side. From all these passages select the one that needs the smallest amount of time. Note that among persons that have passed over the bridge, the one having the greatest speed should return (it’s better than returning one having a lower speed). This fact makes the code much easier to implement. After having realized these things – just code the solution. There may be others – but you will lose more time to find another than to code this one.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[MNS](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – SRM 148 Div 1:__\n9 numbers need to be arranged in a magic number square. A magic number square is a square of numbers that is arranged such that every row and column has the same sum. You are given 9 numbers that range from 0 to 9 inclusive. Return the number of distinct ways that they can be arranged in a magic number square. Two magic number squares are distinct if they differ in value at one or more positions. \n</div>\n\n__Problem hints:__ Only 9 numbers are given at most; and every distinct way (configuration) to arrange the numbers so that they form a magic number square should be found.\n\nThese are the main properties of a Backtracking problem. If you have observed them – think about the code. You can generate all permutations of numbers and for each of them check if it forms a magic square. If so – add it to the answer. Note that it must be unique. A possible way to do that – is to have a list of earlier found configurations, thus for each new magic square check if it exists in that list and if it doesn’t – add it to the answer. There will not be many distinct magic squares, thus no additional problems will appear when applying this method.\n\n__Other example(s):__\n\n__[WeirdRooks](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3998&amp;rd=6533) - SRM 234 Div 1__\n\\\n<a name=\"dp\" id=\"dp\"></a> __Dynamic Programming__\nQuite a few problems are solved with the help of this technique. Knowing how to detect this type of problem can be very valuable.  However in order to do so, one has to have some experience in dynamic programming. Usually a DP problem has some main integer variables (e.g. N) which are neither too small, nor too big – so that a usual DP complexity of N^2, N^3 etc. fits in time. Note that in the event that N is very small (for TC problems usually less than 30) – then it is likely the problem is not a DP one. Besides that there should exist states and one or more ways (rules) to reach one greater state from another lower one.  In addition, greater states should depend only upon lower states. What is a so-called state? It’s just a certain configuration or situation. To better understand dynamic programming, you may want to read [this article](http://community.topcoder.com/tc?module=Static&amp;d1=tutorials&amp;d2=dynProg).\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nLet’s analyze a simple classic DP problem:<br/>\nGiven a list of N coins with their values (V1, V2, … ,VN), and the total sum S. Find the minimum number of coins the sum of which is S (you can use as many coins of one type as you want), or report that it’s not possible to select coins in such a way that they sum up to S.<br/>\nLet N &lt;= 1,000 and S &lt;= 1,000.\n</div>\n\n__Problem hints:__\n* Two main integer variables are given (N and S). These are neither too small, nor are they too big (i.e. a complexity of N*S fits in time).\n* A state can be defined as the minimum number of coins needed to reach a certain sum.\n* A sum (state) i depends only on lower sums (states) j (j&lt;i).\n* By adding a coin to a certain sum – another greater sum is reached. This is the way to pass from one state to another.\n\nThus all properties of a DP problem are uncovered in this statement. Let’s see another (slightly harder) DP problem:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[ZigZag](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – 2003 TCCC Semifinals 3:__\nA sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a zig-zag sequence. Given a sequence of integers, return the length of the longest subsequence that is a zig-zag sequence. A subsequence is obtained by deleting some number of elements (possibly zero) from the original sequence, leaving the remaining elements in their original order. Assume the sequence contains between 1 and 50 elements, inclusive. \n</div>\n\n__Problem hints:__\n* There are N numbers given (1&lt;=N&lt;=50), thus N isn’t too small, nor too big.\n* A state (i,d) can be defined as the length of the longest zig-zag subsequence ending with the i-th number, for which the number before the last one is smaller than it for d=0, and bigger for d=1.\n* A state i (i.e. a subsequence ending with the i-th number) depends only on lower states j (j&lt;i).\n* By adding a number to the end of a subsequence – another bigger (greater) subsequence is created. This is the way to pass from one state to another.\n\nAs you can see – this statement has almost the same traits (pattern) as in the previous problem. The most difficult part in identifying a DP problem statement is observing/seeing the states with the properties described above. Once you can do that, the next step is to construct the algorithm, which is out of the scope of this article.\n\n__Other example(s):__\n__[ChessMetric](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1592&amp;rd=4482) - 2003 TCCC Round 4__\n__[AvoidRoads](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1889&amp;rd=4709) - 2003 TCO Semifinals 4__\n__[FlowerGarden](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1918&amp;rd=5006) - 2004 TCCC Round 1__\n__[BadNeighbors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2402&amp;rd=5009) - 2004 TCCC Round 4__\n\\\n<a name=\"harddrills\" id=\"harddrills\"></a> __Hard Drills:__\n<a name=\"maximumflow\" id=\"maximumflow\"></a> __Maximum Flow__\n\nIn many cases it’s hard to detect a problem whose solution uses maximum flow.  Often you have to create/define graphs with capacities based on the problem statement.\n\nHere are some signs of a Maximum Flow problem:\n* Take a look at the constraints, they have to be appropriate for a O(N^3) or O(N^4) solution, i.e. N shouldn’t be greater than 500 in extreme cases (usually it’s less than 100).\n* There should be a graph with edges having capacities given, or you should be able to define/create it from data given in the statement.\n* You should be finding a maximum value of something.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nSample problem:<br/>\nYou are given a list of water pipes, each having a certain maximum water flow capacity. There are water pipes connected together at their extremities. <br/>\nYou have to find the maximum amount of water that can flow from start junction to end junction in a unit of time. <br/>\nLet N&lt;=100. <br/>\n</div>\n\nAs you can see – it’s a straight-forward maximum flow problem: water pipes represent edges of the graph, their junctions – vertices; and you have to find the maximum value of amount of water that can flow from start to end vertex in a unit of time.\n\\\n<a name=\"optimal\" id=\"optimal\"></a> __Optimal Pair Matching:__\nThese problems usually have a list of items (from a set A) for which other items (from a set B) should be assigned under some rules, so that all (or a maximum possible number of) items from set A have to each be assigned to a certain item from set B.\n\n__Mixed:__\nSome problems need other techniques in addition to network flows.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Parking](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3530&amp;rd=6535) - SRM 236 Div 1:__\nN cars and M parking lots are given. They are situated on a rectangular surface (represented by a table), where certain cells are impassable. You should find a way to assign each car to a parking lot, so that the greatest of the shortest distances from each car to its assigned parking lot is as small as possible. Each parking lot can have at most one car assigned to it. \n</div>\n__Problem hints:__ By reading this problem one can simply understand the main idea of the solution – it should be something similar to optimal pair matching, because each car (point from a set A) should be assigned to a parking lot (point from a set B) so that all are assigned and that there is at most one car assigned to a parking lot. Additionally, there can be cars that can’t reach certain parking lots, thus some pairs of points (one point from A and the other from B) are not connected. However a graph should be created for optimal pair matching. The way to make it is clear – an edge exists between a car and a parking lot if only there is a path between them, and its cost is equal to the shortest distance needed for the car to reach the parking lot. The next step of the solution is a binary search on the longest edge. Although it may be out of the scope of this article, I will provide a short explanation: At each step delete those edges of the initial graph that have costs greater than a certain value C (Note that you’ll have to save the initial graph’s state in order to repeat this step again for other C values). If it’s possible in this case to assign all the cars to parking lots – then take a smaller C, and repeat the same operation. If not – take a greater C. After a complete binary search, the smallest C for which a complete assignment is possible will be found. This will be the answer.\n\\\n<a name=\"lp\" id=\"lp\"></a> __Linear Programming (Simplex)__\nMost of the common traits of problems solved with the help of the linear programming technique are:\n* You are given collection of items having different costs/weights. There is a certain quantity of each item that must be achieved.\n* A list of sets is given. These sets are composed of some of the available items, having certain quantities of each of them. Each set has a certain cost. \n* The goal of the problem is to find an optimal combination (the cheapest one) of these sets so that the sum of quantities of each of the items they have is exactly the one needed to achieve.\n\nAt first it may seem confusing, but let’s see an example:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Mixture](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3942&amp;rd=6520) - SRM 231 Div 1:__\nA precise mixture of a number of different chemicals, each having a certain amount, is needed. Some mixtures of chemicals may be purchased at a certain price (the chemical components for the mixture might not be available in pure form). Each of them contains certain amounts of some of the chemicals. You need not purchase the available mixtures in integral amounts. Hence if you purchase a 1.5 of a mixture having a price of 3 and amounts of \"2 0 1\", you’ll pay 4.5 and get \"3 0 1.5\" amounts of chemicals. Your task is to determine the lowest price that the desired mixture can be achieved. \n</div>\n__Problem hints:__\n* A collection of items (chemicals).\n* A list of sets (available mixtures), each containing certain amounts of each of the items, and having a certain cost.\n* You need to find the lowest price of the desired collection of items achieved by the combination of the available sets. More than that – you can take also non-integral amounts of mixtures.\n\nThese are exactly the traits described above.\n\\\n<a name=\"conclusion\" id=\"conclusion\"></a>\n__Conclusion__\nIf you have found this article interesting and you have learned new things from it – train yourself on any of the problems in the topcoder Algorithm Arena. Try hard to see the hints and determine the type of the solution by carefully reading through the problem statement. Remember, there are still many problems that may not be included properly in any of the categories described above and may need a different approach.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":27,"downvotes":1}},{"sys":{"type":"Link","linkType":"Entry","id":"KSh5Ua02xAveBntVYQdO9"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6NCHwlE0g9NQmUhvL0WIY6","type":"Entry","createdAt":"2022-01-07T18:24:49.501Z","updatedAt":"2023-09-24T18:40:29.354Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":77,"revision":15,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Edmonds-Karp and Dinic’s Algorithms for Maximum Flow","slug":"edmonds-karp-and-dinics-algorithms-for-maximum-flow","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"675c3u6tacMXieHHlB6n7X"}}],"tags":["Python"],"creationDate":"2022-01-07","readTime":"9min","content":"Edmonds-Karp is a maximum flow algorithm. This is a specific implementation of the Ford-Fulkerson algorithm that uses different techniques for finding augmenting paths.\n\nThe Ford-Fulkerson method is used to find the maximum flow. Maximum flow is very useful for finding bipartite matching.\nAt a high level, Ford-Fulkerson says that we want to repeatedly find an augmenting path from source to sink (s->t) in the flow graph, augment flow and repeat until no more paths exist.\n\nThe key takeaway here is that the Ford-Fulkerson method does not specify how to actually find augmenting paths. This is where optimizations come into play. There are many articles where we see that this method uses a DFS to find augmenting paths that take O(Ff) where E is the number of the edges and f is the maxflow.\n\nEach edge of the flow graph has a certain flow and capacity specified by the fraction adjacent to each edge. Initially, the flow through each edge is 0 and the capacity is non-negative.\n\nTo find the maximum flow (and min-cut as a product) the Ford-Fulkerson method repeatedly finds augmenting graphs through the residual graphs and augments the flow until no more augmenting paths can be found.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5AUHpeBvpYjiz32RzhEsbr/b26afd5ed9ceeb6d250d03c69d353783/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5AUHpeBvpYjiz32RzhEsbr/b26afd5ed9ceeb6d250d03c69d353783/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/5AUHpeBvpYjiz32RzhEsbr/b26afd5ed9ceeb6d250d03c69d353783/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n*Credits for the image go to <a href=\"https://cp-algorithms.com/graph/edmonds_karp.html\">jakobkogler, DamianArado, adamant-pwn, infalmo, LUTLJS, Aryamn, Kakalinn, obiwac, shivensinha4, lm10-piyush, ShayekhBinIslam, wikku, roll-no-1</a>.*\n\n### Edmonds-Karp Algorithm:\nThe Edmonds-Karp algorithm is a modified form of the Ford-Fulkerson algorithm. The difference Is that Ford-Fulkerson uses the DFS approach and Edmonds-Karp uses the BFS approach.\nThe time complexity of this algorithm Is O(E^2) for irrational capacities and maximum longest path from source to sink.\n\n#### Implementation\nHere we use the BFS approach so we will make a 2-D array where we store the capacity of each vertex .We will also have an adjacency list for storing graphs because we will reverse the graph for finding an augmenting path.\nThe function maxflow is used to get the maximum value of a network from a 2-D array which is already created.\n\n```python\ndef bfs(arr, dp, source, sink):\n    q=[source]\n    paths={source:[]}\n    if source==sink:\n        return paths[source]\n    while queue:\n        u=queue.pop(0)\n        for neigh in range(len(arr)):\n            if arr[u][neigh]-dp[u][neigh]>0 and neigh not in paths:\n                paths[neigh]=paths[u]+[(u, neigh)]\n                print(paths)\n                if neigh==sink:\n                    return paths[neigh]\n                q.append(neigh)\n    return \ndef max_flow(arr, source, sink):\n    n=len(arr)\n    dp=[[0]*n for i in range(n)]\n    path=bfs(arr, dp,source, sink)\n    while path!=None:\n        flow=min(arr[u][v]-dp[u][v] for u,v in path)\n        for u,v in path:\n            dp[u][v]+=flow\n            dp[u][v]-=flow\n        path=bfs(arr, dp, source sink)\n    return sum(dp[source][i] for i in range(n))\n```\n\n#### Time complexity:\nThe time complexity of the Edmonds-Karp algorithm is O(VE^2) and space complexity is O(E+V), here E and V are the edges and vertices.\n\n#### Applications:\n1. Maximum flow algorithm\n2. Packet transfer on transport layer in computer network\n3. Traffic flow control on roads\n\n### Dinic’s Algorithm:\nLike the Ford-Fulkerson and Edmonds-Karp algorithms for finding maximum flow, Dinic’s algorithm is efficient for finding network flow of unweighted bipartite graphs. Dinic’s algorithm is fast and convenient. Here we work on combining multiple graph traversal techniques together.\nDinic’s is a strongly polynomial maximum flow algorithm with a runtime of O(VE^2).\nIt is extremely fast and works better on bipartite graphs, giving time complexity of O(VE^(1/2)) due to algorithm reduction.\nThe algorithm was invented by Yefim Dinitz in 1969 and published in 1970.\n\n#### Implementation\n1. Construct a level graph by doing a BFS from the source to sink, all the levels of the current flow graphs.\n2. If the sink was never reached while building the level graph, then stop and return the maxflow.\n3. Using only valid edges in the level graph, do multiple DFS from source to sink (s->t) until blocking flow is reached to sum the bottleneck values of all the augmenting paths found to calculate the maxflow.\n\n```python\ndef Bfs(C, First, s, t):  # C is the capacity matrix\n        n = len(C)\n        queue = []\n        queue.append(s)\n        global steps\n        steps = n * [0]  # initialization\n        steps[s] = 1  \n        while queue:\n            k = queue.pop(0)\n            for i in range(n):\n                    if (First[k][i] < C[k][i]) and (steps[i] == 0): # not visited\n                            steps[i] = steps[k] + 1\n                            queue.append(i)\n        return steps[t] > 0\n\n#search augmenting path by using DFS\ndef Dfs(C, F, k, cp):\n        tmp = cp\n        if k == len(C)-1:\n            return cp\n        for i in range(len(C)):\n            if (level[i] == level[k] + 1) and (F[k][i] < C[k][i]):\n                f = Dfs(C,F,i,min(tmp,C[k][i] - F[k][i]))\n                F[k][i] = F[k][i] + f\n                F[i][k] = F[i][k] - f\n                tmp = tmp - f\n        return cp - tmp\n\n#calculate max flow\n#_ = float('inf')\ndef MaxFlow(C,s,t):\n        n = len(C)\n        F = [n*[0] for i in range(n)] # F is the flow matrix\n        flow = 0\n        while(Bfs(C,F,s,t)):\n               flow = flow + Dfs(C,F,s,100000)\n        return flow\n```\n\n### Comparison Among Various Algorithms\nWe have already read about Edmonds-Karp and Dinic’s algorithms. Now let’s look at a comparison of all the algorithms for maximum flow in a graph.\n\n#### Ford-Fulkerson Max Flow Algorithm:\nFor the max flow f*, the maximum value |f*| denotes a bound in the number of iterations. Total running time is O(|f*|m).\nEdmonds-Karp Algorithm:\nWorst case time complexity O(|f*|m) to O(nm²).\n\n#### Goldberg-Tarjan Algorithm:\nTime complexity is O(n²m).\nBelow is a tabular analysis of all algorithms.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1MLwQtDAok1VpiOMDPCkDV/0a5b321ff19f4b3b1defee12de452717/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1MLwQtDAok1VpiOMDPCkDV/0a5b321ff19f4b3b1defee12de452717/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1MLwQtDAok1VpiOMDPCkDV/0a5b321ff19f4b3b1defee12de452717/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7koRSof4dMlEfXfkdGMKdH","type":"Asset","createdAt":"2022-01-07T18:18:28.869Z","updatedAt":"2023-09-24T18:35:10.267Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":2,"locale":"en-US"},"fields":{"title":"1200px-Pets flow.svg","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7koRSof4dMlEfXfkdGMKdH/b60c11fac7cb4e507a0af6e26b4fb7ff/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"phRCEOBFWzgGECLgjgpy6"}}],"upvotes":11,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2OIybkcX2PxUf6xgY98vXQ"}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2LF4An9w0IDCr6w8k43kXF","type":"Entry","createdAt":"2020-02-24T22:44:09.126Z","updatedAt":"2024-07-31T06:30:05.201Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1296,"revision":586,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Dynamic Programming: From Novice to Advanced","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Sorting","Libraries","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"<a href=\"http://apps.topcoder.com/forums/?module=ThreadList&forumID=505844\">Discuss this article in the forums</a> \n\\\nAn important part of given problems can be solved with the help of dynamic programming (<strong>DP</strong> for short).  Being able to tackle problems of this type would greatly increase your skill. I will try to help you in understanding how to solve problems using DP. The article is based on examples, because a raw theory is very hard to understand. \n\\\n__Note__: If you’re bored reading one section and you already know what’s being discussed in it – skip it and go to the next one. \n\n### Introduction (Beginner)\n<em><strong>What is a dynamic programming, how can it be described?</strong></em> A <strong>DP</strong> is an algorithmic technique which is usually based on a recurrent formula and one (or some) starting states. A sub-solution of the problem is constructed from previously found ones. DP solutions have a polynomial complexity which assures a much faster running time than other techniques like backtracking, brute-force etc.\n\\\nNow let’s see the base of DP with the help of an example: \n\\\nGiven a list of N coins, their values (<strong>V<sub>1</sub></strong>, <strong>V<sub>2</sub></strong>, … , <strong>V<sub>N</sub></strong>), and the total sum <strong>S</strong>. Find the minimum number of coins the sum of which is <strong>S</strong> (we can use as many coins of one type as we want), or report that it’s not possible to select coins in such a way that they sum up to <strong>S</strong>. \n\\\nNow let’s start constructing a DP solution: \n\\\nFirst of all we need to find a state for which an optimal solution is found and with the help of which we can find the optimal solution for the next state. \n\\\n<em><strong>What does a \"state\" stand for?</strong></em> \n\\\nIt’s a way to describe a situation, a sub-solution for the problem. For example a state would be the solution for sum <strong>i</strong>, where <strong>i≤S</strong>. A smaller state than state <strong>i</strong> would be the solution for any sum <strong>j</strong>, where <strong>j&lt;i</strong>. For finding a <strong>state i</strong>, we need to first find all smaller states <strong>j (j&lt;i) </strong>. Having found the minimum number of coins which sum up to <strong>i</strong>, we can easily find the next state – the solution for <strong>i+1</strong>. \n\\\n<em><strong>How can we find it?</strong></em> \n\\\nIt is simple – for each coin <strong>j, V<sub>j</sub>≤i</strong>, look at the minimum number of coins found for the <strong>i-V<sub>j</sub></strong>sum (we have already found it previously). Let this number be <strong>m</strong>. If <strong>m+1</strong> is less than the minimum number of coins already found for current sum <strong>i</strong>, then we write the new result for it. \n\\\nFor a better understanding let’s take this example:<br>Given coins with values 1, 3, and 5.<br>And the sum <strong>S</strong> is set to be 11. \n\\\nFirst of all we mark that for state 0 (sum 0) we have found a solution with a minimum number of 0 coins. We then go to sum 1. First, we mark that we haven’t yet found a solution for this one (a value of Infinity would be fine). Then we see that only coin 1 is less than or equal to the current sum. Analyzing it, we see that for sum 1-<strong>V<sub>1</sub></strong>= 0  we have a solution with 0 coins. Because we add one coin to this solution, we’ll have a solution with 1 coin for sum 1. It’s the only solution yet found for this sum. We write (save) it. Then we proceed to the next state – <strong>sum 2</strong>. We again see that the only coin which is less or equal to this sum is the first coin, having a value of 1. The optimal solution found for sum (2-1) = 1  is coin 1. This coin 1 plus the first coin will sum up to 2, and thus make a sum of 2 with the help of only 2 coins. This is the best and only solution for sum 2. Now we proceed to sum 3. We now have 2 coins which are to be analyzed – first and second one, having values of 1 and 3. Let’s see the first one. There exists a solution for sum 2 (3 – 1) and therefore we can construct from it a solution for sum 3 by adding the first coin to it. Because the best solution for sum 2 that we found has 2 coins, the new solution for sum 3 will have 3 coins. Now let’s take the second coin with value equal to 3. The sum for which this coin needs to be added to make 3 , is 0. We know that sum 0 is made up of 0 coins. Thus we can make a sum of 3 with only one coin – 3. We see that it’s better than the previous found solution for sum 3 , which was composed of 3 coins. We update it and mark it as having only 1 coin. The same we do for sum 4, and get a solution of 2 coins – 1+3. And so on. \n\\\n<strong>Pseudocode:</strong> \n```\nSet Min[i] equal to Infinity for all of i\nMin[0]=0\n\nFor i = 1 to S\nFor j = 0 to N - 1\n\tIf (Vj<=i AND Min[i-Vj]+1 < Min[i])\nThen Min[i]=Min[i-Vj]+1\n\nOutput Min[S]\n```\n\nHere are the solutions found for all sums:\n\\\n<table class=\"tableizer-table\"><thead><tr class=\"tableizer-firstrow\"><th style=\"width:20%\">Sum</th><th style=\"width:32%\">Min. nr. of coins</th><th>Coin value (Previous Smaller Sum)</th></tr></thead><tbody><tr><td>0</td><td>0</td><td>-</td></tr><tr><td>1</td><td>1</td><td>1 (0)</td></tr><tr><td>2</td><td>2</td><td>1 (1)</td></tr><tr><td>3</td><td>1</td><td>3 (0)</td></tr><tr><td>4</td><td>2</td><td>1 (3)</td></tr><tr><td>5</td><td>1</td><td>5 (0)</td></tr><tr><td>6</td><td>2</td><td>3 (3)</td></tr><tr><td>7</td><td>3</td><td>1 (6)</td></tr><tr><td>8</td><td>2</td><td>3 (5)</td></tr><tr><td>9</td><td>3</td><td>1 (8)</td></tr><tr><td>10</td><td>2</td><td>5 (5)</td></tr><tr><td>11</td><td>3</td><td>1 (10)</td></tr> </tbody></table>\n\nAs a result we have found a solution of 3 coins which sum up to 11. \n\nAdditionally, by tracking data about how we got to a certain sum from a previous one, we can find what coins were used in building it. For example: to sum 11 we got by adding the coin with value 1 to a sum of 10. To sum 10 we got from 5. To 5 – from 0. This way we find the coins used: 1, 5 and 5. \n\nHaving understood the basic way a <strong>DP</strong> is used, we may now see a slightly different approach to it. It involves the change (update) of best solution yet found for a sum i, whenever a better solution for this sum was found. In this case the states aren’t calculated consecutively. Let’s consider the problem above. Start with having a solution of 0 coins for sum 0. Now let’s try to add first coin (with value 1) to all sums already found. If the resulting sum <strong>t</strong> will be composed of fewer coins than the one previously found – we’ll update the solution for it. Then we do the same thing for the second coin, third coin, and so on for the rest of them. For example, we first add coin 1 to sum 0 and get sum 1. Because we haven’t yet found a possible way to make a sum of 1 – this is the best solution yet found, and we mark <strong>S[1]=1</strong>. By adding the same coin to sum 1, we’ll get sum 2, thus making <strong>S[2]=2</strong>. And so on for the first coin. After the first coin is processed, take coin 2 (having a value of 3) and consecutively try to add it to each of the sums already found. Adding it to 0, a sum 3 made up of 1 coin will result. Till now, <strong>S[3]</strong> has been equal to 3, thus the new solution is better than the previously found one. We update it and mark <strong>S[3]=1</strong>. After adding the same coin to sum 1, we’ll get a sum 4 composed of 2 coins. Previously we found a sum of 4 composed of 4 coins; having now found a better solution we update <strong>S[4]</strong> to 2. The same thing is done for next sums – each time a better solution is found, the results are updated.\n\n### Elementary\n\nTo this point, very simple examples have been discussed. Now let’s see how to find a way for passing from one state to another, for harder problems. For that we will introduce a new term called recurrent relation, which makes a connection between a lower and a greater state.\n\nLet’s see how it works: \n\nGiven a sequence of N numbers – <strong>A[1] </strong>, <strong>A[2] </strong>, …, <strong>A[N] </strong>. Find the length of the longest non-decreasing sequence. \n\nAs described above we must first find how to define a \"state\" which represents a sub-problem and thus we have to find a solution for it. Note that in most cases the states rely on lower states and are independent from greater states. \n\nLet’s define a state <strong>i</strong> as being the longest non-decreasing sequence which has its last number <strong>A[i] </strong>. This state carries only data about the length of this sequence. Note that for <strong>i&lt;j</strong> the state <strong>i</strong> is independent from <strong>j</strong>, i.e. doesn’t change when we calculate state <strong>j</strong>. Let’s see now how these states are connected to each other. Having found the solutions for all states lower than <strong>i</strong>, we may now look for state <strong>i</strong>. At first we initialize it with a solution of 1, which consists only of the <strong>i-th</strong> number itself. Now for each <strong>j&lt;i</strong> let’s see if it’s possible to pass from it to state i. This is possible only when <strong>A[j]≤A[i] </strong>, thus keeping (assuring) the sequence non-decreasing. So if <strong>S[j] </strong> (the solution found for state <strong>j</strong>) + <strong>1</strong> (number <strong>A[i] </strong> added to this sequence which ends with number <strong>A[j] </strong>) is better than a solution found for <strong>i</strong> (ie. <strong>S[j]+1&gt;S[i] </strong>), we make <strong>S[i]=S[j]+1</strong>. This way we consecutively find the best solutions for each <strong>i</strong>, until last state N. \n\nLet’s see what happens for a randomly generated sequence: 5, 3, 4, 8, 6, 7: \n\n<table><thead><tr class=\"tableizer-firstrow\"><th style=\"width:20%\">I</th><th style=\"width:32%\">Length of Longest non-decreasing sequence (first I numbers)</th><th>The last sequence i from which we \"arrived\" to this one</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>1 (first number itself)</td></tr><tr><td>2</td><td>1</td><td>2 (second number itself)</td></tr><tr><td>3</td><td>2</td><td>2</td></tr><tr><td>4</td><td>3</td><td>3</td></tr><tr><td>5</td><td>3</td><td>3</td></tr><tr><td>6</td><td>4</td><td>5</td></tr> </tbody></table>\n\n<strong>Practice problem:</strong><br>\n\nGiven an undirected graph <strong>G</strong> having <strong>N</strong> (1&lt;N&lt;=1000) vertices and positive weights. Find the shortest path from vertex 1 to vertex N, or state that such path doesn’t exist.\n\nHint: At each step, among the vertices which weren’t yet checked and for which a path from vertex 1 was found, take the one which has the shortest path, from vertex 1 to it, yet found. \n\nTry to solve the following problems from Topcoder competitions:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4493&pm=1259\">ZigZag</a> – 2003 TCCC Semifinals 3\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5009&pm=2402\">BadNeighbors</a> – 2004 TCCC Round 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5006&pm=1918\">FlowerGarden</a> – 2004 TCCC Round 1\n\n### Intermediate\n\nLet’s see now how to tackle bi-dimensional DP problems.\n\n<strong>Problem:</strong>\n\nA table composed of <strong>N x M</strong> cells, each having a certain quantity of apples, is given. You start from the upper-left corner. At each step you can go down or right one cell. Find the maximum number of apples you can collect. \n\nThis problem is solved in the same way as other DP problems; there is almost no difference.\n\nFirst of all we have to find a state. The first thing that must be observed is that there are at most 2 ways we can come to a cell – from the left (if it’s not situated on the first column) and from the top (if it’s not situated on the most upper row). Thus to find the best solution for that cell, we have to have already found the best solutions for all of the cells from which we can arrive to the current cell. \n\nFrom above, a recurrent relation can be easily obtained:<br>\n<strong>S[i][j]=A[i][j] + max(S[i-1][j], if i&gt;0 ; S[i][j-1], if j&gt;0) </strong> (where <strong>i</strong> represents the row and <strong>j</strong> the column of the table , its left-upper corner having coordinates {0,0} ; and <strong>A[i][j]</strong> being the number of apples situated in cell <strong>i,j</strong>). \n\n<strong>S[i][j] </strong> must be calculated by going first from left to right in each row and process the rows from top to bottom, or by going first from top to bottom in each column and process the columns from left to right. \n\nPseudocode:\n```\nFor i = 0 to N - 1\n\tFor j = 0 to M - 1\n\tS[i][j] = A[i][j] +\n\t\tmax(S[i][j-1], if j>0 ; S[i-1][j], if i>0 ; 0)\n\nOutput S[n-1][m-1]\n```\n\nHere are a few problems, from Topcoder Competitions, for practicing:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4709&pm=1889\">AvoidRoads</a> – 2003 TCO Semifinals 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4482&pm=1592\">ChessMetric</a> – 2003 TCCC Round 4\n\n### Upper-Intermediate\n\nThis section will discuss about dealing DP problems which have an additional condition besides the values that must be calculated.\n\nAs a good example would serve the following problem: \n\nGiven an undirected graph <strong>G</strong> having positive weights and <strong>N</strong> vertices.\n\nYou start with having a sum of <strong>M</strong> money. For passing through a vertex <strong>i</strong>, you must pay <strong>S[i] </strong> money. If you don’t have enough money – you can’t pass through that vertex. Find the shortest path from vertex 1 to vertex N, respecting the above conditions; or state that such path doesn’t exist. If there exist more than one path having the same length, then output the cheapest one. Restrictions: 1&lt;N&lt;=100 ; 0&lt;=M&lt;=100 ; for each i, 0&lt;=S[i]&lt;=100. As we can see, this is the same as the classical Dijkstra problem (finding the shortest path between two vertices), with the exception that it has a condition. In the classical Dijkstra problem we would have used a uni-dimensional array <strong>Min[i] </strong>, which marks the length of the shortest path found to vertex <strong>i</strong>. However in this problem we should also keep information about the money we have. Thus it would be reasonable to extend the array to something like <strong>Min[i][j] </strong>, which represents the length of the shortest path found to vertex <strong>i</strong>, with <strong>j</strong> money being left. In this way the problem is reduced to the original path-finding algorithm. At each step we find the unmarked state (i,j) for which the shortest path was found. We mark it as visited (not to use it later), and for each of its neighbors we look if the shortest path to it may be improved. If so – then update it. We repeat this step until there will remain no unmarked state to which a path was found. The solution will be represented by <strong>Min[N-1][j] </strong> having the least value (and the greatest <strong>j</strong> possible among the states having the same value, i.e. the shortest paths to which has the same length). \n\nPseudocode:\n```\nSet states(i,j) as unvisited for all (i,j)\nSet Min[i][j] to Infinity for all (i,j)\n\nMin[0][M]=0\n\nWhile(TRUE)\n\nAmong all unvisited states(i,j) find the one for which Min[i][j]\nis the smallest. Let this state found be (k,l).\n\nIf there wasn't found any state (k,l) for which Min[k][l] is\nless than Infinity - exit While loop.\n\nMark state(k,l) as visited\n\nFor All Neighbors p of Vertex k.\n\tIf (l-S[p]>=0 AND\n\tMin[p][l-S[p]]>Min[k][l]+Dist[k][p])\n\t\tThen Min[p][l-S[p]]=Min[k][l]+Dist[k][p]\ni.e.\nIf for state(i,j) there are enough money left for\ngoing to vertex p (l-S[p] represents the money that\nwill remain after passing to vertex p), and the\nshortest path found for state(p,l-S[p]) is bigger\nthan [the shortest path found for\nstate(k,l)] + [distance from vertex k to vertex p)],\nthen set the shortest path for state(i,j) to be equal\nto this sum.\nEnd For\n\nEnd While\n\nFind the smallest number among Min[N-1][j] (for all j, 0<=j<=M);\nif there are more than one such states, then take the one with greater\nj. If there are no states(N-1,j) with value less than Infinity - then\nsuch a path doesn't exist.\n```\n\nHere are a few Topcoder problems for practicing:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4705&pm=1166\">Jewelry</a> – 2003 TCO Online Round 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4555&pm=1215\">StripePainter</a> – SRM 150 Div 1\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829\">QuickSums</a> – SRM 197 Div 2\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4630&pm=1861\">ShortPalindromes</a> – SRM 165 Div 2\n\n### Advanced\n\nThe following problems will need some good observations in order to reduce them to a dynamic solution.\n\n<strong>Problem <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5854&pm=2940\">StarAdventure</a> – SRM 208 Div 1:</strong> \n\nGiven a matrix with <strong>M</strong> rows and <strong>N</strong> columns (<strong>N x M</strong>). In each cell there’s a number of apples.<br> You start from the upper-left corner of the matrix. You can go down or right one cell. You need to arrive to the bottom-right corner. Then you need to go back to the upper-left cell by going each step one cell left or up. Having arrived at this upper-left cell, you need to go again back to the bottom-right cell.<br> Find the maximum number of apples you can collect.<br>When you pass through a cell – you collect all the apples left there.\n\nRestrictions: 1 &lt; <strong>N</strong>, <strong>M</strong> &lt;= 50 ; each cell contains between 0 and 1000 apples inclusive. \n First of all we observe that this problem resembles to the classical one (described in Section 3 of this article), in which you need to go only once from the top-left cell to the bottom-right one, collecting the maximum possible number of apples. It would be better to try to reduce the problem to this one. Take a good look into the statement of the problem – what can be reduced or modified in a certain way to make it possible to solve using DP? First observation is that we can consider the second path (going from bottom-right cell to the top-left cell) as a path which goes from top-left to bottom-right cell. It makes no difference, because a path passed from bottom to top, may be passed from top to bottom just in reverse order. In this way we get three paths going from top to bottom. This somehow decreases the difficulty of the problem. We can consider these 3 paths as left, middle and right. When 2 paths intersect (like in the figure below) \n\n<center>\n<img src=\"https://www.topcoder.com/i/education/dynProg_1.gif\" border=\"0/\">\n</center>\n\nwe may consider them as in the following picture, without affecting the result: \n\n<center>\n<img src=\"https://www.topcoder.com/i/education/dynProg_2.gif\" border=\"0/\">\n</center>\n\nThis way we’ll get 3 paths, which we may consider as being one left, one middle and the other – right. More than that, we may see that for getting an optimal results they must not intersect (except in the leftmost upper corner and rightmost bottom corner). So for each row <strong>y</strong> (except first and last), the <strong>x</strong> coordinates of the lines (<strong>x1[y] </strong>, <strong>x2[y] </strong> and respectively <strong>x3[y] </strong>) will be : <strong>x1[y] </strong> &lt; <strong>x2[y] </strong> &lt; <strong>x3[y] </strong>. Having done that – the DP solution now becomes much clearer. Let’s consider the row y. Now suppose that for any configuration of <strong>x1[y-1] </strong>, <strong>x2[y-1] </strong> and <strong>x3[y-1] </strong> we have already found the paths which collect the maximum number of apples. From them we can find the optimal solution for row <strong>y</strong>. We now have to find only the way for passing from one row to the next one. Let <strong>Max[i][j][k] </strong> represent the maximum number of apples collected till row <strong>y-1</strong> inclusive, with three paths finishing at column <strong>i</strong>, <strong>j</strong>, and respectively <strong>k</strong>. For the next row <strong>y</strong>, add to each <strong>Max[i][j][k] </strong> (obtained previously) the number of apples situated in cells (<strong>y,i</strong>) , (<strong>y,j</strong>) and (<strong>y,k</strong>). Thus we move down at each step. After we made such a move, we must consider that the paths may move in a row to the right. For keeping the paths out of an intersection, we must first consider the move to the right of the left path, after this of the middle path, and then of the right path. For a better understanding think about the move to the right of the left path – take every possible pair of, <strong>k</strong> (where <strong>j&lt;k</strong>), and for each i (1 i&lt;j) consider the move from position (<strong>i-1,j,k</strong>) to position (<strong>i,j,k</strong>). Having done this for the left path, start processing the middle one, which is done similarly; and then process the right path.  \n\nTC problems for practicing:\n\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4710&pm=1996\">MiniPaint</a> – SRM 178 Div 1\n\n<strong>Additional Note:</strong>\n\nWhen have read the description of a problem and started to solve it, first look at its restrictions. If a polynomial-time algorithm should be developed, then it’s possible that the solution may be of DP type. In this case try to see if there exist such states (sub-solutions) with the help of which the next states (sub-solutions) may be found. Having found that – think about how to pass from one state to another. If it seems to be a DP problem, but you can’t define such states, then try to reduce the problem to another one (like in the example above, from Section 5).\n\n<strong>Mentioned in this writeup:</strong>\n\nTCCC ’03 Semifinals 3 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4493&pm=1259\">ZigZag</a>\nTCCC ’04 Round 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5009&pm=2402\">BadNeighbors</a>\nTCCC ’04 Round 1 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5006&pm=1918\">FlowerGarden</a>\nTCO ’03 Semifinals 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4709&pm=1889\">AvoidRoads</a>\nTCCC ’03 Round 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4482&pm=1592\">ChessMetric</a>\nTCO ’03 Round 4 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4705&pm=1166\">Jewelry</a>\nSRM 150 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4555&pm=1215\">StripePainter</a>\nSRM 197 Div II Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829\">QuickSums</a>\nSRM 165 Div II Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4630&pm=1861\">ShortPalindromes</a>\nSRM 208 Div I Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5854&pm=2940\">StarAdventure</a>\nSRM 178 Div I Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4710&pm=1996\">MiniPaint</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":200,"downvotes":32}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7mQBfgaWnYKbVjOp2MeCxm","type":"Entry","createdAt":"2020-02-20T12:38:10.637Z","updatedAt":"2024-07-12T17:27:18.329Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":727,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part two","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[…read Section 1](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20one)\n<br/>\nIn this part of the article we will focus on estimating the time complexity for recursive programs. In essence, this will lead to finding the order of growth for solutions of recurrence equations. Don’t worry if you don’t understand what exactly is a recurrence solution, we will explain it in the right place at the right time. But first we will consider a simpler case – programs without recursion.\n\\\nNested loops\n\\\nFirst of all let’s consider simple programs that contain no function calls. The rule of thumb to find an upper bound on the time complexity of such a program is:\n- estimate the maximum number of times each loop can be executed,\n- add these bounds for cycles following each other.\n- multiply these bounds for nested cycles/parts of code,\n\n<br/>__Example 1.__ Estimating the time complexity of a random piece of code.\n<br/>\n```\nint result=0;                           //  1\nfor (int i=0; i<N; i++)                 //  2\nfor (int j=i; j<N; j++) {             //  3\nfor (int k=0; k<M; k++) {           //  4\nint x=0;                          //  5\nwhile (x<N) { result++; x+=3; }   //  6\n}                                   //  7\nfor (int k=0; k<2*M; k++)           //  8\nif (k%7 == 4) result++;           //  9\n}                                     // 10\n```\n\\\nThe time complexity of the while-cycle in line 6 is clearly O(N) – it is executed no more than N/3 + 1 times.\n\\\nNow consider the for-cycle in lines 4-7. The variable k is clearly incremented O(M) times. Each time the whole while-cycle in line 6 is executed. Thus the total time complexity of the lines 4-7 can be bounded by O(MN).\n\\\nThe time complexity of the for-cycle in lines 8-9 is O(M). Thus the execution time of lines 4-9 is O(MN + M) = O(MN).\n\\\nThis inner part is executed O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) times – once for each possible combination of i and j. (Note that there are only N(N + 1)/2 possible values for [i, j]. Still, O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) is a correct upper bound.)\n\\\nFrom the facts above follows that the total time complexity of the algorithm in Example 1 is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.MN) = O(MN<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>).\n\\\nFrom now on we will assume that the reader is able to estimate the time complexity of simple parts of code using the method demonstrated above. We will now consider programs using recursion (i.e. a function occasionally calling itself with different parameters) and try to analyze the impact of these recursive calls on their time complexity.\n\\\nUsing recursion to generate combinatorial objects\n\\\nOne common use of recursion is to implement a backtracking algorithm to generate all possible solutions of a problem. The general idea is to generate the solution incrementally and to step back and try another way once all solutions for the current branch have been exhausted.\n\\\nThis approach is not absolutely universal, there may be problems where it is impossible to generate the solution incrementally. However, very often the set of all possible solutions of a problem corresponds to the set of all combinatorial objects of some kind. Most often it is the set of all permutations (of a given size), but other objects (combinations, partitions, etc.) can be seen from time to time.\n\\\nAs a side note, it is always possible to generate all strings of zeroes and ones, check each of them (i.e. check whether it corresponds to a valid solution) and keep the best found so far. If we can find an upper bound on the size of the best solution, this approach is finite. However, this approach is everything but fast. Don’t use it if there is __any__ other way.\n\\\n__Example 2.__ A trivial algorithm to generate all permutations of numbers 0 to N – 1.\n<br/>\n```\nvector permutation(N);\nvector used(N,0);\n\nvoid try(int which, int what) {\n// try taking the number “what” as the “which”-th element\npermutation[which] = what;\nused[what] = 1; \n\nif (which == N-1)\noutputPermutation();\nelse\n// try all possibilities for the next element\nfor (int next=0; next<N; next++)\nif (!used[next])\ntry(which+1, next); \n\nused[what] = 0;\n} \n\nint main() {\n// try all possibilities for the first element\nfor (int first=0; first<N; first++)\ntry(0,first);\n}\n```\n\\\nIn this case a trivial __lower__ bound on the time complexity is the number of possible solutions. Backtracking algorithms are usually used to solve hard problems – i.e. such that we don’t know whether a significantly more efficient solution exists. Usually the solution space is quite large and uniform and the algorithm can be implemented so that its time complexity is close to the theoretical lower bound. To get an upper bound it should be enough to check how much additional (i.e. unnecessary) work the algorithm does.\n\\\nThe number of possible solutions, and thus the time complexity of such algorithms, is usually exponential – or worse.\n\\\nDivide&conquer using recursion\n\\\nFrom the previous example we could get the feeling that recursion is evil and leads to horribly slow programs. The contrary is true. Recursion can be a very powerful tool in the design of effective algorithms. The usual way to create an effective recursive algorithm is to apply the divide & conquer paradigm – try to split the problem into several parts, solve each part separately and in the end combine the results to obtain the result for the original problem. Needless to say, the “solve each part separately” is usually implemented using recursion – and thus applying the same method again and again, until the problem is sufficiently small to be solved by brute force.\n\\\n__Example 3.__ The sorting algorithm MergeSort described in pseudocode.\n<br/>\n```\nMergeSort(sequence S) {\nif (size of S <= 1) return S;\nsplit S into S_1 and S_2 of roughly the same size;\nMergeSort(S_1);\nMergeSort(S_2);\ncombine sorted S_1 and sorted S_2 to obtain sorted S;\nreturn sorted S;\n}\n```\n\\\nClearly O(N) time is enough to split a sequence with N elements into two parts (Depending on the implementation this may be even possible in constant time.) Combining the shorter sorted sequences can be done in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N): Start with an empty S. At each moment the smallest element not yet in S is either at the beginning of S<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">1</sub> or at the beginning of S<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>. Move this element to the end of S and continue.\n\\\nThus the total time to MergeSort a sequence with N elements is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) plus the time needed to make the two recursive calls.\n\\\nLet f (N) be the time complexity of MergeSort as defined in the previous part of our article. The discussion above leads us to the following equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_2](https://images.ctfassets.net/b5f1djy59z3a/wIFnLTP3tQAICqeQk4a04/5990cf2cef5f288cef54994219575d62/Computational_Complexity_2.png)</div>\nwhere p is a linear function representing the amount of work spent on splitting the sequence and merging the results.\n\\\nBasically, this is just a recurrence equation. If you don’t know this term, please don’t be afraid. The word “recurrence” stems from the latin phrase for “to run back”. Thus the name just says that the next values of f are defined using the previous (i.e. smaller) values of f.\n\\\nWell, to be really formal, for the equation to be complete we should specify some initial values – in this case, f (1). This (and knowing the implementation-specific function p) would enable us to compute the exact values of f.\n\\\nBut as you hopefully understand by now, this is not necessarily our goal. While it is theoretically possible to compute a closed-form formula for f (N), this formula would most probably be really ugly… and we don’t really need it. We only want to find a <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">-bound (and sometimes only an O-bound) on the growth of f. Luckily, this can often be done quite easily, if you know some tricks of the trade.\n\\\nAs a consequence, we won’t be interested in the exact form of p, all we need to know is that p(N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N). Also, we don’t need to specify the initial values for the equation. We simply assume that all problem instances with small N can be solved in constant time.\n\\\nThe rationale behind the last simplification: While changing the initial values does change the solution to the recurrence equation, it usually doesn’t change its asymptotic order of growth. (If your intuition fails you here, try playing with the equation above. For example fix p and try to compute f (8), f (16) and f (32) for different values of f (1).)\n\\\nIf this would be a formal textbook, at this point we would probably have to develop some theory that would allow us to deal with the floor and ceiling functions in our equations. Instead we will simply neglect them from now on. (E.g. we can assume that each division will be integer division, rounded down.)\n\\\nA reader skilled in math is encouraged to prove that if p is a polynomial (with non-negative values on N) and q(n) = p(n + 1) then q(n) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(n)). Using this observation we may formally prove that (assuming the f we seek is polynomially-bounded) the right side of each such equation remains asymptotically the same if we replace each ceiling function by a floor function.\n\\\nThe observations we made allow us to rewrite our example equation in a more simple way:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_3](https://images.ctfassets.net/b5f1djy59z3a/1PYsoE2tQMq6IIAIokIwyk/f12615b10713f1a5bb3f2c5e3228fe8c/Computational_Complexity_3.png)\n  <p>(1)</p></div>\nNote that this is not an equation in the classical sense. As in the examples in the first part of this article, the equals sign now reads “is asymptotically equal to”. Usually there are lots of different functions that satisfy such an equation. But usually all of them will have the same order of growth – and this is exactly what we want to determine. Or, more generally, we want to find the smallest upper bound on the growth of __all possible__ functions that satisfy the given equation.\n\\\nIn the last sections of this article we will discuss various methods of solving these “equations”. But before we can do that, we need to know a bit more about logarithms.\n\\\nNotes on logarithms\n\\\nBy now, you may have already asked one of the following questions: If the author writes that some complexity is e.g. O(N log N), what is the base of the logarithm? In some cases, wouldn’t O(N log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>N) be a better bound?\n\\\nThe answer: The base of the logarithm does not matter, all logarithmic functions (with base > 1) are asymptotically equal. This is due to the well-known equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_4](https://images.ctfassets.net/b5f1djy59z3a/4MgqQ4AXx6wEUE6Iy6QE2i/f23cf25e2c3da6b8ad786f00feedcf7d/Computational_Complexity_4.png)<p>(2)</p></div>\nNote that given two bases a, b, the number 1/log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>a is just a constant, and thus the function logaN is just a constant multiple of log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>N.\n\\\nTo obtain more clean and readable expressions, we always use the notation log N inside big-Oh expressions, even if logarithms with a different base were used in the computation of the bound.\n\\\nBy the way, sadly the meaning of log N differs from country to country. To avoid ambiguity where it may occur: I use log N to denote the decadic (i.e. base-10) logarithm, ln N for the natural (i.e. base-e) logarithm, lg N for the binary logarithm and log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>N for the general case.\n\\\nNow we will show some useful tricks involving logarithms, we will need them later. Suppose a, b are given constants such that a, b > 1.\n\\\nFrom (2) we get:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_5](https://images.ctfassets.net/b5f1djy59z3a/2JQOSNo87Y6O4IYE4m6iUk/bae14f9aba4c8ae910ef544c0e04d482/Computational_Complexity_5.png)</div>\nUsing this knowledge, we can simplify the term ![new47](//images.ctfassets.net/piwi0eufbb2g/64l938UvNmbNHGd0zrr1gY/84fc017979b0aeaec5d4b2d334d19958/new47.png)\n<br/><div style=\"text-align:center;\">![new48](//images.ctfassets.net/piwi0eufbb2g/2GTJRokW8hwUUuNsVpIP0w/eeef30852f48b2905333f84a3b353085/new48.png)<p>(3)</p></div>\nThe substitution method\n\\\nThis method can be summarized in one sentence: Guess an asymptotic upper bound on f and (try to) prove it by induction.\n\\\nAs an example, we will prove that if f satisfies the equation (1) then f (N) = O(N log N).\n\\\nFrom (1) we know that:\n<br/><div style=\"text-align:center;\">![new52](//images.ctfassets.net/piwi0eufbb2g/64F3kJwlYijHjxwZtMGLlO/0d2085183ebbd4b94a35294c5843142b/new52.png)</div>\nfor some c. Now we will prove that if we take a large enough (but constant) d then for almost all N we have f (N) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> dN lg N. We will start by proving the induction step.\n\\\nAssume that f (N/2) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> d (N/2)lg(N/2). Then\n<br/><div style=\"text-align:center;\">![new57](//images.ctfassets.net/piwi0eufbb2g/5UH5U0XZkXHghwJT7ZIuqI/b77447ab9d64755777bbe264a5e1ee0e/new57.png)</div>\nIn other words, the induction step will hold as long as d > c. We are always able to choose such d.\n\\\nWe are only left with proving the inequality for some initial value N. This gets quite ugly when done formally. The general idea is that if the d we found so far is not large enough, we can always increase it to cover the initial cases.\n\\\nNote that for our example equation we won’t be able to prove it for N = 1, because lg 1 = 0. However, by taking f (N) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> dN lg N, where d is some fixed constant. Conclusion: from (1) it follows that f (N) = O(N lg N).\n\\\nThe recursion tree\n\\\nTo a beginner, the previous method won’t be very useful. To use it successfully we need to make a good guess – and to make a good guess we need some insight. The question is, how to gain this insight? Let’s take a closer look at what’s happening, when we try to evaluate the recurrence (or equivalently, when we run the corresponding recursive program).\n\\\nWe may describe the execution of a recursive program on a given input by a rooted tree. Each node will correspond to some instance of the problem the program solves. Consider an arbitrary vertex in our tree. If solving its instance requires recursive calls, this vertex will have children corresponding to the smaller subproblems we solve recursively. The root node of the tree is the input of the program, leaves represent small problems that are solved by brute force.\n\\\nNow suppose we label each vertex by the amount of work spent solving the corresponding problem (excluding the recursive calls). Clearly the runtime is exactly the sum of all labels.\n\\\nAs always, we only want an asymptotic bound. To achieve this, we may “round” the labels to make the summation easier. Again, we will demonstrate this method on examples.\n\\\n__Example 4.__ The recursion tree for MergeSort on 5 elements.\n<br/><div style=\"text-align:center;\">![tree1](//images.ctfassets.net/piwi0eufbb2g/2vEZy2el9aDX9tbgXjLJAk/b030404573d5657cbb86750fe3a08baa/tree1.png)</div>\nThe recursion tree for the corresponding recurrence equation. This time, the number inside each vertex represents the number of steps the algorithm makes there.\n<br/><div style=\"text-align:center;\">![tree2](//images.ctfassets.net/piwi0eufbb2g/6WGTZYJ4ZAPZk4uINWognb/5d1fd8d1e6253ff3faff81d01c7a737c/tree2.png)</div>\nNote that in a similar way we may sketch the general form of the recursion tree for any recurrence. Consider our old friend, the equation (1). Here we know that there is a number c such that the number of operations in each node can be bound by (c times the current value of N). Thus the tree in the example below is indeed the worst possible case.\n\\\n__Example 5.__ A worst-case tree for the general case of the recurrence equation (1).\n<br/><div style=\"text-align:center;\">![tree3](//images.ctfassets.net/piwi0eufbb2g/6yuqtsqtBEBNfwqltHQvYD/cdb2212e850d26c840f29ec08f4f5ea1/tree3.png)</div>\nNow, the classical trick from combinatorics is to sum the elements in an order different from the order in which they were created. In this case, consider an arbitrary level of the tree (i.e. a set of vertices with the same depth). It is not hard to see that the total work on each of the levels is cN.\n\\\nNow comes the second question: What is the number of levels? Clearly, the leaves correspond to the trivial cases of the algorithm. Note that the size of the problem is halved in each step. Clearly after lg N steps we are left with a trivial problem of size 1, thus the number of levels is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N).\n\\\nCombining both observations we get the final result: The total amount of work done here is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(cN x log N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n\\\nA side note. If the reader doesn’t trust the simplifications we made when using this method, he is invited to treat this method as a “way of making a good guess” and then to prove the result using the substitution method. However, with a little effort the application of this method could also be upgraded to a full formal proof.\n\\\nMore recursion trees\n\\\nBy now you should be asking: Was it really only a coincidence that the total amount of work on each of the levels in Example 5 was the same?\n\\\nThe answer: No and yes. No, there’s a simple reason why this happened, we’ll discover it later. Yes, because this is not always the case – as we’ll see in the following two examples.\n\\\n__Example 6.__ Let’s try to apply our new “recursion tree” method to solve the following recurrence equation:\n<br/><div style=\"text-align:center;\">![new72](//images.ctfassets.net/piwi0eufbb2g/ogXKwD5HVzKuddBLbSXBo/8fb141a9199787a0d2697dab5ff95fc6/new72.png)</div>\n\\\nThe recursion tree will look as follows:\n<br/><div style=\"text-align:center;\">![tree5](//images.ctfassets.net/piwi0eufbb2g/3VSFRdCsKVE7i4o9nQu2es/82fd95adec8a5b0c4246eae5cc07eb29/tree5.png)</div>\nLet’s try computing the total work for each of the first few levels. Our results:\n<br/><br/>\n| level | 1   | 2   | 3   | … |\n|-------|-----|-----|-----|---|\n| <div style=\"position:relative;top:-15px\">work</div>  | <div style=\"position:relative;top:-15px\">cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img16](//images.ctfassets.net/piwi0eufbb2g/5SEkV4yJ3iaFb6r14yaFaR/2e6260b520c7b8eaa122444a08f89458/img16.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img17](//images.ctfassets.net/piwi0eufbb2g/DXuNYbKPMbilIdFTcBwGy/a20e3ae785add765324a40219ec21e0a/img17.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"position:relative;top:-15px\">…</div> |\n<br/>\nClearly as we go deeper in the tree, the total amount of work on the current level decreases. The question is, how fast does it decrease? As we move one level lower, there will be three times that many subproblems. However, their size gets divided by 2, and thus the time to process each of them decreases to one eighth of the original time. Thus the amount of work is decreased by the factor 3/8.\n\\\nBut this means that the entries in the table above form a geometric progression. For a while assume that this progression is infinite. Then its sum would be\n<br/><div style=\"text-align:center;\">![new77](//images.ctfassets.net/piwi0eufbb2g/75cy2reJFkT2KE2vKqsoOy/31a1ec1d2eb01a571b2a03e7069681d0/new77.png)</div>\nThus the total amount of work in our tree is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) (summing the infinite sequence gives us an upper bound). But already the first element of our progression is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>). It follows that the total amount of work in our tree is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) and we are done.\n\\\nThe important generalization of this example: If the amounts of work at subsequent levels of the recursion tree form a __decreasing geometric progression__, the total amount of work is asymptotically the same as the amount of work done in the root node.\n\\\nFrom this result we can deduce an interesting fact about the (hypothetical) algorithm behind this recurrence equation: The recursive calls didn’t take much time in this case, the most time consuming part was preparing the recursive calls and/or processing the results. (I.e. this is the part that should be improved if we need a faster algorithm.)\n\\\n__Example 7.__ Now let’s try to apply our new “recursion tree” method to solve the following recurrence equation:\n<br/><div style=\"text-align:center;\">![new80](//images.ctfassets.net/piwi0eufbb2g/5Wyw3RJnFzgqlA1hK4sUzc/2198e3c1fae6addeb2d98acfb81ff3ef/new80.png)</div>\nThe recursion tree will look as follows:\n<br/><div style=\"text-align:center;\">![tree4](//images.ctfassets.net/piwi0eufbb2g/7MI5X0xGKmQU6RR8oeYVQH/3732983f075cf331bbfb7a82d7adc98d/tree4.png)</div>\nAgain, let’s try computing the total work for each of the first few levels. We get:\n<br/><br/>\n| level | 1   | 2   | 3   | … |\n|-------|-----|-----|-----|---|\n| <div style=\"position:relative;top:-15px\">work</div>  | <div style=\"position:relative;top:-15px\">cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img21](//images.ctfassets.net/piwi0eufbb2g/5CgK58HEHtfnfntlZYPcEc/98c4c0da9d0db3a545b389c4722a446c/img21.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img22](//images.ctfassets.net/piwi0eufbb2g/7Gg1ALwlj3TsB3QpIHl0Wz/2512294d503f347bd15d6441c3004835/img22.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"position:relative;top:-15px\">…</div> |\n<br/>\nThis time we have the opposite situation: As we go deeper in the tree, the total amount of work on the current level increases. As we move one level lower, there will be five times that many subproblems, each of them one third of the previous size, the processing time is linear in problem size. Thus the amount of work increased by the factor 5/3.\n\\\nAgain, we want to compute the total amount of work. This time it won’t be that easy, because the most work is done on the lowest level of the tree. We need to know its depth.\n\\\nThe lowest level corresponds to problems of size 1. The size of a problem on level k is N/3<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>. Solving the equation 1 = N/3<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub> we get k = log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>N. Note that this time we explicitly state the base of the logarithm, as this time it will be important.\n\\\nOur recursion tree has log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>N levels. Each of the levels has five times more vertices than the previous one, thus the last level has ![new89](//images.ctfassets.net/piwi0eufbb2g/1SmukeDxdG1GuSarDmDkkl/10685198c4e0867b475b048d8fd00f70/new89.png) levels. The total work done on this level is then ![new90](//images.ctfassets.net/piwi0eufbb2g/1FRsvs2MIA65AdRcG5ydDy/9bc604ebdc3fa85864d4ea5172d079f4/new90.png).\n\\\nNote that using the trick (3) we may rewrite this as ![new91](//images.ctfassets.net/piwi0eufbb2g/t6ZL1kGPMuG1y0xkuKzMK/5c054ba80b76172fc8f026c7b78f8619/new91.png).\n\\\nNow we want to sum the work done on all levels of the tree. Again, this is a geometric progression. But instead of explicitly computing the sum, we now __reverse__ it. Now we have a __decreasing__ geometric progression…and we are already in the same situation as in the previous example. Using the same reasoning we can show that the sum is asymptotically equal to the largest element.\n\\\nIt follows that the total amount of work in our tree is ![new92](//images.ctfassets.net/piwi0eufbb2g/2L64R8CZ5vytan2FAbZi5o/0ed5a6a567481f00051246d880a4f470/new92.png) and we are done.\n\\\nNote that the base-3 logarithm ends in the exponent, that’s why the base is important. If the base was different, also the result would be asymptotically different.\n\\\nThe Master Theorem\n\\\nWe already started to see a pattern here. Given a recurrence equation, take the corresponding recurrence tree and compute the amounts of work done on each level of the tree. You will get a geometric sequence. If it decreases, the total work is proportional to work done in the root node. If it increases, the total work is proportional to the number of leaves. If it remains the same, the total work is (the work done on one level) times (the number of levels).\n\\\nActually, there are a few ugly cases, but almost often one of these three cases occurs. Moreover, it is possible to prove the statements from the previous paragraph formally. The formal version of this theorem is known under the name Master Theorem.\n\\\nFor reference, we give the full formal statement of this theorem. (Note that knowing the formal proof is not necessary to __apply__ this theorem on a given recurrence equation.)\n\\\nLet a <img src=\"https://images.ctfassets.net/piwi0eufbb2g/48JqWlli2r8Wq9kJYPgGrf/7936cc3cc0cf229c233fa6da8bc6efb4/img24.png\" style=\"position:relative; top: 15px;\"> 1 and b > 1 be integer constants. Let p be a non-negative non-decreasing function. Let f be any solution of the recurrence equation\n<br/><div style=\"text-align:center;\">![new95](//images.ctfassets.net/piwi0eufbb2g/3H3wLzjQSunZVkqx9Lt9qy/f352b06489eb0d1ec164a07875e3d718/new95.png)</div>\nThen\n<br/>\n1. If ![new96](//images.ctfassets.net/piwi0eufbb2g/M0Qqw1L1K8QxwyexHNCYL/36666284053af8cd8eed43569a0c35b6/new96.png) for some ![img26](//images.ctfassets.net/piwi0eufbb2g/7b4QExfhi9RQajtgPtSS7h/6d8083fdd1327d53a2a9646cc8b8a25b/img26.png) > 0 then ![new98](//images.ctfassets.net/piwi0eufbb2g/5gBXAJoTWJB3GafLfx8mAR/1e6574f91620b3cd6497a10b91736270/new98.png)\n2. If , then f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(N)log N).\n3. If  for some  > 0, and if ap(N/b)  cp(N) for some c < 1 and for almost all N, then f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(N)).\n\n<br/>Case 1 corresponds to our Example 7. Most of the time is spent making the recursive calls and it’s the number of these calls that counts.\n\\\nCase 2 corresponds to our Example 5. The time spent making the calls is roughly equal to the time to prepare the calls and process the results. On all levels of the recursion tree we do roughly the same amount of work, the depth of the tree is always logarithmic.\n\\\nCase 3 corresponds to our Example 6. Most of the time is spent on preparing the recursive calls and processing the results. Usually the result will be asymptotically equal to the time spent in the root node.\n\\\nNote the word “usually” and the extra condition in Case 3. For this result to hold we need p to be somehow “regular” – in the sense that for each node in the recursion tree the time spent in the node must be greater than the time spent in its chidren (excluding further recursive calls). This is nothing to worry about too much, most probably all functions p you will encounter in practice will satisfy this condition (if they satisfy the first condition of Case 3).\n\\\n__Example 8.__ Let f (N) be the time Strassen’s fast matrix multiplication algorithm needs to multiply two N x N square matrices. This is a recursive algorithm, that makes 7 recursive calls, each time multiplying two (N/2) x (N/2) square matrices, and then computes the answer in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) time.\n\\\nThis leads us to the following recurrence equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_3](https://images.ctfassets.net/b5f1djy59z3a/1PYsoE2tQMq6IIAIokIwyk/f12615b10713f1a5bb3f2c5e3228fe8c/Computational_Complexity_3.png)</div>\nUsing the Master Theorem, we see that Case 1 applies. Thus the time complexity of Strassen’s algorithm is . Note that by implementing the definition of matrix multiplication we get only a <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) algorithm.\n\\\n__Example 9.__ Occasionally we may encounter the situation when the problems in the recursive calls are not of the same size. An example may be the “median-of-five” algorithm to find the k-th element of an array. It can be shown that its time complexity satisfies the recurrence equation:\n<br/><div style=\"text-align:center;\">![new110](//images.ctfassets.net/piwi0eufbb2g/74WaKVRGFyA7jAPbFrEArc/5aadd01ab15764bf5c1ed78a6f029b88/new110.png)</div>\nHow to solve it? Can the recursion tree be applied also in such asymmetric cases? Is there a more general version of Master Theorem that handles also these cases? And what should I do with the recurrence f (N) = 4f (N/4) + <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N), where the Master Theorem doesn’t apply?\n\\\nWe won’t answer these questions here. This article doesn’t claim to be the one and only reference to computational complexity. If you are already asking these questions, you understand the basics you need for programming challenges – and if you are interested in knowing more, there are good books around that can help you.\n\\\nThanks for reading this far. If you have any questions, comments, bug reports or any other feedback, please use the Round tables. I’ll do my best to answer.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":12,"downvotes":1,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3rAZrsBseux2curmx1if6s","type":"Entry","createdAt":"2020-02-20T12:38:07.258Z","updatedAt":"2024-08-07T14:00:23.815Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":571,"revision":58,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part one","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505848)\n<br/>\nIn this article I’ll try to introduce you to the area of computation complexity. The article will be a bit long before we get to the actual formal definitions because I feel that the rationale behind these definitions needs to be explained as well – and that understanding the rationale is even more important than the definitions alone.\n\\\nWhy is it important?\n\\\n__Example 1.__ Suppose you were assigned to write a program to process some records your company receives from time to time. You implemented two different algorithms and tested them on several sets of test data. The processing times you obtained are in Table 1.\n<br/>\n__Table 1. Runtimes of two fictional algorithms.__\n| # of records | 10    | 20    | 50    | 100   | 1000   | 5000   |\n|--------------|-------|-------|-------|-------|--------|--------|\n| algorithm 1  | 0.00s | 0.01s | 0.05s | 0.47s | 23.92s | 47min  |\n| algorithm 2  | 0.05s | 0.05s | 0.06s | 0.11s | 0.78s  | 14.22s |\n<br/>\nIn praxis, we probably could tell which of the two implementations is better for us (as we usually can estimate the amount of data we will have to process). For the company this solution may be fine. But from the programmer’s point of view, it would be much better if he could estimate the values in Table 1 __before__ writing the actual code – then he could only implement the better algorithm.\n\\\nThe same situation occurs during programming challenges: The size of the input data is given in the problem statement. Suppose I found an algorithm. Questions I have to answer before I start to type should be: Is my algorithm worth implementing? Will it solve the largest test cases in time? If I know more algorithms solving the problem, which of them shall I implement?\n\\\nThis leads us to the question: How to compare algorithms? Before we answer this question in general, let’s return to our simple example. If we extrapolate the data in Table 1, we may assume that if the number of processed records is larger than 1000, algorithm 2 will be substantially faster. In other words, if we consider all possible inputs, algorithm 2 will be better for almost all of them.\n\\\nIt turns out that this is almost always the case – given two algorithms, either one of them is almost always better, or they are approximately the same. Thus, this will be our definition of a better algorithm. Later, as we define everything formally, this will be the general idea behind the definitions.\n\\\nA neat trick\n\\\nIf you thing about Example 1 for a while, it shouldn’t be too difficult to see that there is an algorithm with runtimes similar to those in Table 2:\n<br/>\n__Table 2. Runtimes of a new fictional algorithm.__\n| # of records | 10    | 20    | 50    | 100   | 1000  | 5000   |\n|--------------|-------|-------|-------|-------|-------|--------|\n| algorithm 3  | 0.00s | 0.01s | 0.05s | 0.11s | 0.78s | 14.22s |\n<br/>\nThe idea behind this algorithm: Check the number of records. If it is small enough, run algorithm 1, otherwise run algorithm 2.\n\\\nSimilar ideas are often used in praxis. As an example consider most of the sort() functions provided by various libraries. Often this function is an implementation of QuickSort with various improvements, such as:\n- if the number of elements is too small, run InsertSort instead (as InsertSort is faster for small inputs)\n- if the pivot choices lead to poor results, fall back to MergeSort\n\n<br/>What is efficiency?\n\\\n__Example 2.__ Suppose you have a concrete implementation of some algorithm. (The example code presented below is actually an implementation of MinSort – a slow but simple sorting algorithm.)\n<br/>\n```\nfor (int i=0; i<N; i++)\nfor (int j=i+1; j<N; j++)\nif (A[i] > A[j])\nswap( A[i], A[j] );\n```\n\\\nIf we are given an input to this algorithm (in our case, the array A and its size N), we can exactly compute the number of steps our algorithm does on this input. We could even count the processor instructions if we wanted to. However, there are too many possible inputs for this approach to be practical.\n\\\nAnd we still need to answer one important question: What is it exactly we are interested in? Most usually it is the behavior of our program in the __worst possible case__ – we need to look at the input data and to determine an upper bound on how long will it take if we run the program.\n\\\nBut then, what is the worst possible case? Surely we can always make the program run longer simply by giving it a larger input. Some of the more important questions are: What is the worst input with 700 elements? __How fast__ does the maximum runtime grow when we increase the input size?\n\\\nFormal notes on the input size\n\\\nWhat exactly is this “input size” we started to talk about? In the formal definitions this is the size of the input written in some fixed finite alphabet (with at least 2 “letters”). For our needs, we may consider this alphabet to be the numbers 0…255. Then the “input size” turns out to be exactly the size of the input file in bytes.\n\\\nUsually a part of the input is a number (or several numbers) such that the size of the input is proportional to the number.\n\\\nE.g. in Example 2 we are given an int N and an array containing N ints. The size of the input file will be roughly 5N (depending on the OS and architecture, but always linear in N).\n\\\nIn such cases, we may choose that this number will represent the size of the input. Thus when talking about problems on arrays/strings, the input size is the length of the array/string, when talking about graph problems, the input size depends both on the number of vertices (N) and the number of edges (M), etc.\n\\\nWe will adopt this approach and use N as the input size in the following parts of the article.\n\\\nThere is one tricky special case you sometimes need to be aware of. To write a (possibly large) number we need only logarithmic space. (E.g. to write 123456, we need only roughly log<sub style=\"bottom: -.25em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">10</sub>(123456) digits.) This is why the naive primality test does not run in polynomial time – its runtime is polynomial in the __size__ of the number, but not in its __number of digits__! If you didn’t understand the part about polynomial time, don’t worry, we’ll get there later.\n\\\nHow to measure efficiency?\n\\\nWe already mentioned that given an input we are able to count the number of steps an algorithm makes simply by simulating it. Suppose we do this for all inputs of size at most __N__ and find the worst of these inputs (i.e. the one that causes the algorithm to do the most steps). Let f (__N__) be this number of steps. We will call this function the time complexity, or shortly the runtime of our algorithm.\n\\\nIn other words, if we have any input of size __N__, solving it will require at most f (__N__) steps.\n\\\nLet’s return to the algorithm from Example 2. What is the worst case of size __N__? In other words, what array with __N__ elements will cause the algorithm to make the most steps? If we take a look at the algorithm, we can easily see that:\n- the first step is executed exactly N times\n- the second and third step are executed exactly N(N – 1)/2 times\n- the fourth step is executed at most N(N – 1)/2 times\n\n<br/>Clearly, if the elements in A are in descending order at the beginning, the fourth step will always be executed. Thus in this case the algorithm makes 3N(__N__ – 1)/2 + __N__ = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N steps. Therefore our algorithm has f (__N__) = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N.\n\\\nAs you can see, determining the exact function f for more complicated programs is painful. Moreover, it isn’t even necessary. In our case, clearly the -0.5N term can be neglected. It will usually be much smaller than the 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> term and it won’t affect the runtime significantly. The result “f (__N__) is roughly equal to 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>” gives us all the information we need. As we will show now, if we want to compare this algorithm with some other algorithm solving the same problem, even the constant 1.5 is not that important.\n\\\nConsider two algorithms, one with the runtime N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, the other with the runtime 0.001N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>. One can easily see that for N greater than 1 000 the first algorithm is faster – and soon this difference becomes apparent. While the first algorithm is able to solve inputs with N = 20 000 in a matter of seconds, the second one will already need several minutes on current machines.\n\\\nClearly this will occur always when one of the runtime functions grows __asymptotically faster__ than the other (i.e. when N grows beyond all bounds the limit of their quotient is zero or infinity). Regardless of the constant factors, an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> will always be better than an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub> __on almost all inputs__. And this observation is exactly what we base our formal definition on.\n\\\nFinally, formal definitions\n\\\nLet f, g be positive non-decreasing functions defined on positive integers. (Note that all runtime functions satisfy these conditions.) We say that f (N) is O(g(N)) (read: f is big-oh of g) if for some c and N0 the following condition holds:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_1.png](https://images.ctfassets.net/b5f1djy59z3a/22I9okwtiQ8w86WCCuyy2a/6b44bf4a6736db87aa793e7837a3df89/Computational_Complexity_1.png)</div>\nIn human words, f (N) is O(g(N)), if for some c almost the entire graph of the function f is below the graph of the function c.g. Note that this means that f grows at most as fast as c.g does.\n\\\nInstead of “f (N) is O(g(N))” we usually write f (N) = O(g(N)). Note that this “equation” is __not symmetric__ – the notion \" O(g(N)) = f (N)\" has no sense and \" g(N) = O(f (N))\" doesn’t have to be true (as we will see later). (If you are not comfortable with this notation, imagine O(g(N)) to be a set of functions and imagine that there is a E instead of =.)\n\\\nWhat we defined above is known as the big-oh notation and is conveniently used to specify upper bounds on function growth.\n\\\nE.g. consider the function f (N) = 3N(N – 1)/2 + N = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N from Example 2. We may say that f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) (one possibility for the constants is c = 2 and N<sub style=\"bottom: -2.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">0</sub> = 0). This means that f doesn’t grow (asymptotically) faster than N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nNote that even the exact runtime function f doesn’t give an exact answer to the question “How long will the program run on my machine?” But the important observation in the example case is that the runtime function is quadratic. If we double the input size, the runtime will increase approximately to four times the current runtime, no matter how fast our computer is.\n\\\nThe f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) upper bound gives us almost the same – it guarantees that the growth of the runtime function is at most quadratic.\n\\\nThus, we will use the O-notation to describe the time (and sometimes also memory) complexity of algorithms. For the algorithm from Example 2 we would say “The time complexity of this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” or shortly “This algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”.\n\\\nIn a similar way we defined O we may define <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">.\n\\\nWe say that f (N) is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> (g(N)) if g(N) = O(f (N)), in other words if f grows at least as fast as g.\n\\\nWe say that f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> (g(N)) if f (N) = O(g(N)) and g(N) = O(f (N)), in other words if both functions have approximately the same rate of growth.\n\\\nAs it should be obvious,  is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> used to specify lower bounds and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> is used to give a tight asymptotic bound on a function. There are other similar bounds, but these are the ones you’ll encounter most of the time.\n\\\nSome examples of using the notation:\n- 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> -0.5N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- 47N log N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- N log N + 1 000 047N = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n- All polynomials of order k are O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>).\n- The time complexity of the algorithm in Example 2 is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- If an algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), it is also O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">5</sub>).\n- Each comparision-based sorting algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N log N).\n- MergeSort run on an array with N elements does roughly N log N comparisions. Thus the time complexity of MergeSort is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N). If we trust the previous statement, this means that MergeSort is an asymptotically optimal general sorting algorithm.\n- The algorithm in Example 2 uses <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) bytes of memory.\n- The function giving my number of teeth in time is O(1).\n- A naive backtracking algorithm trying to solve chess is O(1) as the tre of positions it will examine is finite. (But of course in this case the constant hidden behind the O(1) is unbelievably large.)\n- The statement “Time complexity of this algorithm is at least O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” is meaningless. (It says: “Time complexity of this algorithm is at least at most roughly quadratic.” The speaker probably wanted to say: “Time complexity of this algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).”)\n\n<br/>When speaking about the time/memory complexity of an algorithm, instead of using the formal <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(f (n))-notation we may simply state the class of functions f belongs to. E.g. if f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N), we call the algorithm linear. More examples:\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N): logarithmic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2): quadratic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3): cubic\n- f (N) = O(Nk) for some k: polynomial\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(2N): exponential\n\n<br/>For graph problems, the complexity <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N + M) is known as “linear in the graph size”.\n\\\nDetermining execution time from an asymptotic bound\n\\\nFor most algorithms you may encounter in praxis, the constant hidden behind the O (or <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">) is usually relatively small. If an algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), you may expect that the exact time complexity is something like 10N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, not 10<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">7</sub>N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nThe same observation in other words: if the constant is large, it is usually somehow related to some constant in the problem statement. In this case it is good practice to give this constant a name and to include it in the asymptotic notation.\n\\\nAn example: The problem is to count occurences of each letter in a string of N letters. A naive algorithm passes through the whole string once for each possible letter. The size of alphabet is fixed (e.g. at most 255 in C), thus the algorithm is linear in N. Still, it is better to write that its time complexity is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S|.N), where S is the alphabet used. (Note that there is a better algorithm solving this problem in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S| + N).)\n\\\nIn a topcoder contest, an algorithm doing 1 000 000 000 multiplications runs barely in time. This fact together with the above observation and some experience with topcoder problems can help us fill the following table:\n<br/>\n__Table 3. Approximate maximum problem size solvable in 8 seconds.__\n| complexity | maximum N   |\n|------------|-------------|\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N)        | 100 000 000 |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N)  | 40 000 000  |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2)       | 10 000      |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3)       | 500         |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N4)       | 90          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(2N)       | 20          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N!)       | 11          |\n<br/>\nA note on algorithm analysis\n\\\nUsually if we present an algorithm, the best way to present its time complexity is to give a . However, it is common practice to only give an O-bound - the other bound is usually trivial, O is much easier to type and better known. Still, don’t forget that O represents only an upper bound. Usually we try to find an O-bound that’s as good as possible.\n\\\n__Example 3.__ Given is a sorted array A. Determine whether it contains two elements with the difference D. Consider the following code solving this problem:\n<br/>\n```\nint j=0;\nfor (int i=0; i<N; i++) {\nwhile ( (j<N-1) && (A[i]-A[j] > D) )\nj++;\nif (A[i]-A[j] == D) return 1;\n}\n```\n\\\nIt is easy to give an O(N2) bound for the time complexity of this algorithm – the inner while-cycle is called N times, each time we increase j at most N times. But a more careful analysis shows that in fact we can give an O(N) bound on the time complexity of this algorithm – it is sufficient to realize that during the __whole execution__ of the algorithm the command “__j++__;” is executed no more than N times.\n\\\nIf we said “this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”, we would have been right. But by saying “this algorithm is O(N)” we give more information about the algorithm.\n\\\n__Conclusion__\n\\\nWe have shown how to write bounds on the time complexity of algorithms. We have also demonstrated why this way of characterizing algorithms is natural and (usually more-or-less) sufficient.\n\\\nThe next logical step is to show how to estimate the time complexity of a given algorithm. As we have already seen in Example 3, sometimes this can be messy. It gets really messy when recursion is involved. We will address these issues in the second part of this article.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20two)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":22,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7mQBfgaWnYKbVjOp2MeCxm","circular":true}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"7mQBfgaWnYKbVjOp2MeCxm","circular":true}}}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3rAZrsBseux2curmx1if6s","type":"Entry","createdAt":"2020-02-20T12:38:07.258Z","updatedAt":"2024-08-07T14:00:23.815Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":571,"revision":58,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part one","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505848)\n<br/>\nIn this article I’ll try to introduce you to the area of computation complexity. The article will be a bit long before we get to the actual formal definitions because I feel that the rationale behind these definitions needs to be explained as well – and that understanding the rationale is even more important than the definitions alone.\n\\\nWhy is it important?\n\\\n__Example 1.__ Suppose you were assigned to write a program to process some records your company receives from time to time. You implemented two different algorithms and tested them on several sets of test data. The processing times you obtained are in Table 1.\n<br/>\n__Table 1. Runtimes of two fictional algorithms.__\n| # of records | 10    | 20    | 50    | 100   | 1000   | 5000   |\n|--------------|-------|-------|-------|-------|--------|--------|\n| algorithm 1  | 0.00s | 0.01s | 0.05s | 0.47s | 23.92s | 47min  |\n| algorithm 2  | 0.05s | 0.05s | 0.06s | 0.11s | 0.78s  | 14.22s |\n<br/>\nIn praxis, we probably could tell which of the two implementations is better for us (as we usually can estimate the amount of data we will have to process). For the company this solution may be fine. But from the programmer’s point of view, it would be much better if he could estimate the values in Table 1 __before__ writing the actual code – then he could only implement the better algorithm.\n\\\nThe same situation occurs during programming challenges: The size of the input data is given in the problem statement. Suppose I found an algorithm. Questions I have to answer before I start to type should be: Is my algorithm worth implementing? Will it solve the largest test cases in time? If I know more algorithms solving the problem, which of them shall I implement?\n\\\nThis leads us to the question: How to compare algorithms? Before we answer this question in general, let’s return to our simple example. If we extrapolate the data in Table 1, we may assume that if the number of processed records is larger than 1000, algorithm 2 will be substantially faster. In other words, if we consider all possible inputs, algorithm 2 will be better for almost all of them.\n\\\nIt turns out that this is almost always the case – given two algorithms, either one of them is almost always better, or they are approximately the same. Thus, this will be our definition of a better algorithm. Later, as we define everything formally, this will be the general idea behind the definitions.\n\\\nA neat trick\n\\\nIf you thing about Example 1 for a while, it shouldn’t be too difficult to see that there is an algorithm with runtimes similar to those in Table 2:\n<br/>\n__Table 2. Runtimes of a new fictional algorithm.__\n| # of records | 10    | 20    | 50    | 100   | 1000  | 5000   |\n|--------------|-------|-------|-------|-------|-------|--------|\n| algorithm 3  | 0.00s | 0.01s | 0.05s | 0.11s | 0.78s | 14.22s |\n<br/>\nThe idea behind this algorithm: Check the number of records. If it is small enough, run algorithm 1, otherwise run algorithm 2.\n\\\nSimilar ideas are often used in praxis. As an example consider most of the sort() functions provided by various libraries. Often this function is an implementation of QuickSort with various improvements, such as:\n- if the number of elements is too small, run InsertSort instead (as InsertSort is faster for small inputs)\n- if the pivot choices lead to poor results, fall back to MergeSort\n\n<br/>What is efficiency?\n\\\n__Example 2.__ Suppose you have a concrete implementation of some algorithm. (The example code presented below is actually an implementation of MinSort – a slow but simple sorting algorithm.)\n<br/>\n```\nfor (int i=0; i<N; i++)\nfor (int j=i+1; j<N; j++)\nif (A[i] > A[j])\nswap( A[i], A[j] );\n```\n\\\nIf we are given an input to this algorithm (in our case, the array A and its size N), we can exactly compute the number of steps our algorithm does on this input. We could even count the processor instructions if we wanted to. However, there are too many possible inputs for this approach to be practical.\n\\\nAnd we still need to answer one important question: What is it exactly we are interested in? Most usually it is the behavior of our program in the __worst possible case__ – we need to look at the input data and to determine an upper bound on how long will it take if we run the program.\n\\\nBut then, what is the worst possible case? Surely we can always make the program run longer simply by giving it a larger input. Some of the more important questions are: What is the worst input with 700 elements? __How fast__ does the maximum runtime grow when we increase the input size?\n\\\nFormal notes on the input size\n\\\nWhat exactly is this “input size” we started to talk about? In the formal definitions this is the size of the input written in some fixed finite alphabet (with at least 2 “letters”). For our needs, we may consider this alphabet to be the numbers 0…255. Then the “input size” turns out to be exactly the size of the input file in bytes.\n\\\nUsually a part of the input is a number (or several numbers) such that the size of the input is proportional to the number.\n\\\nE.g. in Example 2 we are given an int N and an array containing N ints. The size of the input file will be roughly 5N (depending on the OS and architecture, but always linear in N).\n\\\nIn such cases, we may choose that this number will represent the size of the input. Thus when talking about problems on arrays/strings, the input size is the length of the array/string, when talking about graph problems, the input size depends both on the number of vertices (N) and the number of edges (M), etc.\n\\\nWe will adopt this approach and use N as the input size in the following parts of the article.\n\\\nThere is one tricky special case you sometimes need to be aware of. To write a (possibly large) number we need only logarithmic space. (E.g. to write 123456, we need only roughly log<sub style=\"bottom: -.25em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">10</sub>(123456) digits.) This is why the naive primality test does not run in polynomial time – its runtime is polynomial in the __size__ of the number, but not in its __number of digits__! If you didn’t understand the part about polynomial time, don’t worry, we’ll get there later.\n\\\nHow to measure efficiency?\n\\\nWe already mentioned that given an input we are able to count the number of steps an algorithm makes simply by simulating it. Suppose we do this for all inputs of size at most __N__ and find the worst of these inputs (i.e. the one that causes the algorithm to do the most steps). Let f (__N__) be this number of steps. We will call this function the time complexity, or shortly the runtime of our algorithm.\n\\\nIn other words, if we have any input of size __N__, solving it will require at most f (__N__) steps.\n\\\nLet’s return to the algorithm from Example 2. What is the worst case of size __N__? In other words, what array with __N__ elements will cause the algorithm to make the most steps? If we take a look at the algorithm, we can easily see that:\n- the first step is executed exactly N times\n- the second and third step are executed exactly N(N – 1)/2 times\n- the fourth step is executed at most N(N – 1)/2 times\n\n<br/>Clearly, if the elements in A are in descending order at the beginning, the fourth step will always be executed. Thus in this case the algorithm makes 3N(__N__ – 1)/2 + __N__ = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N steps. Therefore our algorithm has f (__N__) = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N.\n\\\nAs you can see, determining the exact function f for more complicated programs is painful. Moreover, it isn’t even necessary. In our case, clearly the -0.5N term can be neglected. It will usually be much smaller than the 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> term and it won’t affect the runtime significantly. The result “f (__N__) is roughly equal to 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>” gives us all the information we need. As we will show now, if we want to compare this algorithm with some other algorithm solving the same problem, even the constant 1.5 is not that important.\n\\\nConsider two algorithms, one with the runtime N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, the other with the runtime 0.001N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>. One can easily see that for N greater than 1 000 the first algorithm is faster – and soon this difference becomes apparent. While the first algorithm is able to solve inputs with N = 20 000 in a matter of seconds, the second one will already need several minutes on current machines.\n\\\nClearly this will occur always when one of the runtime functions grows __asymptotically faster__ than the other (i.e. when N grows beyond all bounds the limit of their quotient is zero or infinity). Regardless of the constant factors, an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> will always be better than an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub> __on almost all inputs__. And this observation is exactly what we base our formal definition on.\n\\\nFinally, formal definitions\n\\\nLet f, g be positive non-decreasing functions defined on positive integers. (Note that all runtime functions satisfy these conditions.) We say that f (N) is O(g(N)) (read: f is big-oh of g) if for some c and N0 the following condition holds:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_1.png](https://images.ctfassets.net/b5f1djy59z3a/22I9okwtiQ8w86WCCuyy2a/6b44bf4a6736db87aa793e7837a3df89/Computational_Complexity_1.png)</div>\nIn human words, f (N) is O(g(N)), if for some c almost the entire graph of the function f is below the graph of the function c.g. Note that this means that f grows at most as fast as c.g does.\n\\\nInstead of “f (N) is O(g(N))” we usually write f (N) = O(g(N)). Note that this “equation” is __not symmetric__ – the notion \" O(g(N)) = f (N)\" has no sense and \" g(N) = O(f (N))\" doesn’t have to be true (as we will see later). (If you are not comfortable with this notation, imagine O(g(N)) to be a set of functions and imagine that there is a E instead of =.)\n\\\nWhat we defined above is known as the big-oh notation and is conveniently used to specify upper bounds on function growth.\n\\\nE.g. consider the function f (N) = 3N(N – 1)/2 + N = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N from Example 2. We may say that f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) (one possibility for the constants is c = 2 and N<sub style=\"bottom: -2.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">0</sub> = 0). This means that f doesn’t grow (asymptotically) faster than N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nNote that even the exact runtime function f doesn’t give an exact answer to the question “How long will the program run on my machine?” But the important observation in the example case is that the runtime function is quadratic. If we double the input size, the runtime will increase approximately to four times the current runtime, no matter how fast our computer is.\n\\\nThe f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) upper bound gives us almost the same – it guarantees that the growth of the runtime function is at most quadratic.\n\\\nThus, we will use the O-notation to describe the time (and sometimes also memory) complexity of algorithms. For the algorithm from Example 2 we would say “The time complexity of this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” or shortly “This algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”.\n\\\nIn a similar way we defined O we may define <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">.\n\\\nWe say that f (N) is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> (g(N)) if g(N) = O(f (N)), in other words if f grows at least as fast as g.\n\\\nWe say that f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> (g(N)) if f (N) = O(g(N)) and g(N) = O(f (N)), in other words if both functions have approximately the same rate of growth.\n\\\nAs it should be obvious,  is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> used to specify lower bounds and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> is used to give a tight asymptotic bound on a function. There are other similar bounds, but these are the ones you’ll encounter most of the time.\n\\\nSome examples of using the notation:\n- 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> -0.5N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- 47N log N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- N log N + 1 000 047N = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n- All polynomials of order k are O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>).\n- The time complexity of the algorithm in Example 2 is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- If an algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), it is also O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">5</sub>).\n- Each comparision-based sorting algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N log N).\n- MergeSort run on an array with N elements does roughly N log N comparisions. Thus the time complexity of MergeSort is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N). If we trust the previous statement, this means that MergeSort is an asymptotically optimal general sorting algorithm.\n- The algorithm in Example 2 uses <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) bytes of memory.\n- The function giving my number of teeth in time is O(1).\n- A naive backtracking algorithm trying to solve chess is O(1) as the tre of positions it will examine is finite. (But of course in this case the constant hidden behind the O(1) is unbelievably large.)\n- The statement “Time complexity of this algorithm is at least O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” is meaningless. (It says: “Time complexity of this algorithm is at least at most roughly quadratic.” The speaker probably wanted to say: “Time complexity of this algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).”)\n\n<br/>When speaking about the time/memory complexity of an algorithm, instead of using the formal <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(f (n))-notation we may simply state the class of functions f belongs to. E.g. if f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N), we call the algorithm linear. More examples:\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N): logarithmic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2): quadratic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3): cubic\n- f (N) = O(Nk) for some k: polynomial\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(2N): exponential\n\n<br/>For graph problems, the complexity <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N + M) is known as “linear in the graph size”.\n\\\nDetermining execution time from an asymptotic bound\n\\\nFor most algorithms you may encounter in praxis, the constant hidden behind the O (or <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">) is usually relatively small. If an algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), you may expect that the exact time complexity is something like 10N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, not 10<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">7</sub>N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nThe same observation in other words: if the constant is large, it is usually somehow related to some constant in the problem statement. In this case it is good practice to give this constant a name and to include it in the asymptotic notation.\n\\\nAn example: The problem is to count occurences of each letter in a string of N letters. A naive algorithm passes through the whole string once for each possible letter. The size of alphabet is fixed (e.g. at most 255 in C), thus the algorithm is linear in N. Still, it is better to write that its time complexity is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S|.N), where S is the alphabet used. (Note that there is a better algorithm solving this problem in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S| + N).)\n\\\nIn a topcoder contest, an algorithm doing 1 000 000 000 multiplications runs barely in time. This fact together with the above observation and some experience with topcoder problems can help us fill the following table:\n<br/>\n__Table 3. Approximate maximum problem size solvable in 8 seconds.__\n| complexity | maximum N   |\n|------------|-------------|\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N)        | 100 000 000 |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N)  | 40 000 000  |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2)       | 10 000      |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3)       | 500         |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N4)       | 90          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(2N)       | 20          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N!)       | 11          |\n<br/>\nA note on algorithm analysis\n\\\nUsually if we present an algorithm, the best way to present its time complexity is to give a . However, it is common practice to only give an O-bound - the other bound is usually trivial, O is much easier to type and better known. Still, don’t forget that O represents only an upper bound. Usually we try to find an O-bound that’s as good as possible.\n\\\n__Example 3.__ Given is a sorted array A. Determine whether it contains two elements with the difference D. Consider the following code solving this problem:\n<br/>\n```\nint j=0;\nfor (int i=0; i<N; i++) {\nwhile ( (j<N-1) && (A[i]-A[j] > D) )\nj++;\nif (A[i]-A[j] == D) return 1;\n}\n```\n\\\nIt is easy to give an O(N2) bound for the time complexity of this algorithm – the inner while-cycle is called N times, each time we increase j at most N times. But a more careful analysis shows that in fact we can give an O(N) bound on the time complexity of this algorithm – it is sufficient to realize that during the __whole execution__ of the algorithm the command “__j++__;” is executed no more than N times.\n\\\nIf we said “this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”, we would have been right. But by saying “this algorithm is O(N)” we give more information about the algorithm.\n\\\n__Conclusion__\n\\\nWe have shown how to write bounds on the time complexity of algorithms. We have also demonstrated why this way of characterizing algorithms is natural and (usually more-or-less) sufficient.\n\\\nThe next logical step is to show how to estimate the time complexity of a given algorithm. As we have already seen in Example 3, sometimes this can be messy. It gets really messy when recursion is involved. We will address these issues in the second part of this article.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20two)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":22,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7mQBfgaWnYKbVjOp2MeCxm","circular":true}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"7mQBfgaWnYKbVjOp2MeCxm","circular":true}}}}}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2LF4An9w0IDCr6w8k43kXF","type":"Entry","createdAt":"2020-02-24T22:44:09.126Z","updatedAt":"2024-07-31T06:30:05.201Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1296,"revision":586,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Dynamic Programming: From Novice to Advanced","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Sorting","Libraries","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"<a href=\"http://apps.topcoder.com/forums/?module=ThreadList&forumID=505844\">Discuss this article in the forums</a> \n\\\nAn important part of given problems can be solved with the help of dynamic programming (<strong>DP</strong> for short).  Being able to tackle problems of this type would greatly increase your skill. I will try to help you in understanding how to solve problems using DP. The article is based on examples, because a raw theory is very hard to understand. \n\\\n__Note__: If you’re bored reading one section and you already know what’s being discussed in it – skip it and go to the next one. \n\n### Introduction (Beginner)\n<em><strong>What is a dynamic programming, how can it be described?</strong></em> A <strong>DP</strong> is an algorithmic technique which is usually based on a recurrent formula and one (or some) starting states. A sub-solution of the problem is constructed from previously found ones. DP solutions have a polynomial complexity which assures a much faster running time than other techniques like backtracking, brute-force etc.\n\\\nNow let’s see the base of DP with the help of an example: \n\\\nGiven a list of N coins, their values (<strong>V<sub>1</sub></strong>, <strong>V<sub>2</sub></strong>, … , <strong>V<sub>N</sub></strong>), and the total sum <strong>S</strong>. Find the minimum number of coins the sum of which is <strong>S</strong> (we can use as many coins of one type as we want), or report that it’s not possible to select coins in such a way that they sum up to <strong>S</strong>. \n\\\nNow let’s start constructing a DP solution: \n\\\nFirst of all we need to find a state for which an optimal solution is found and with the help of which we can find the optimal solution for the next state. \n\\\n<em><strong>What does a \"state\" stand for?</strong></em> \n\\\nIt’s a way to describe a situation, a sub-solution for the problem. For example a state would be the solution for sum <strong>i</strong>, where <strong>i≤S</strong>. A smaller state than state <strong>i</strong> would be the solution for any sum <strong>j</strong>, where <strong>j&lt;i</strong>. For finding a <strong>state i</strong>, we need to first find all smaller states <strong>j (j&lt;i) </strong>. Having found the minimum number of coins which sum up to <strong>i</strong>, we can easily find the next state – the solution for <strong>i+1</strong>. \n\\\n<em><strong>How can we find it?</strong></em> \n\\\nIt is simple – for each coin <strong>j, V<sub>j</sub>≤i</strong>, look at the minimum number of coins found for the <strong>i-V<sub>j</sub></strong>sum (we have already found it previously). Let this number be <strong>m</strong>. If <strong>m+1</strong> is less than the minimum number of coins already found for current sum <strong>i</strong>, then we write the new result for it. \n\\\nFor a better understanding let’s take this example:<br>Given coins with values 1, 3, and 5.<br>And the sum <strong>S</strong> is set to be 11. \n\\\nFirst of all we mark that for state 0 (sum 0) we have found a solution with a minimum number of 0 coins. We then go to sum 1. First, we mark that we haven’t yet found a solution for this one (a value of Infinity would be fine). Then we see that only coin 1 is less than or equal to the current sum. Analyzing it, we see that for sum 1-<strong>V<sub>1</sub></strong>= 0  we have a solution with 0 coins. Because we add one coin to this solution, we’ll have a solution with 1 coin for sum 1. It’s the only solution yet found for this sum. We write (save) it. Then we proceed to the next state – <strong>sum 2</strong>. We again see that the only coin which is less or equal to this sum is the first coin, having a value of 1. The optimal solution found for sum (2-1) = 1  is coin 1. This coin 1 plus the first coin will sum up to 2, and thus make a sum of 2 with the help of only 2 coins. This is the best and only solution for sum 2. Now we proceed to sum 3. We now have 2 coins which are to be analyzed – first and second one, having values of 1 and 3. Let’s see the first one. There exists a solution for sum 2 (3 – 1) and therefore we can construct from it a solution for sum 3 by adding the first coin to it. Because the best solution for sum 2 that we found has 2 coins, the new solution for sum 3 will have 3 coins. Now let’s take the second coin with value equal to 3. The sum for which this coin needs to be added to make 3 , is 0. We know that sum 0 is made up of 0 coins. Thus we can make a sum of 3 with only one coin – 3. We see that it’s better than the previous found solution for sum 3 , which was composed of 3 coins. We update it and mark it as having only 1 coin. The same we do for sum 4, and get a solution of 2 coins – 1+3. And so on. \n\\\n<strong>Pseudocode:</strong> \n```\nSet Min[i] equal to Infinity for all of i\nMin[0]=0\n\nFor i = 1 to S\nFor j = 0 to N - 1\n\tIf (Vj<=i AND Min[i-Vj]+1 < Min[i])\nThen Min[i]=Min[i-Vj]+1\n\nOutput Min[S]\n```\n\nHere are the solutions found for all sums:\n\\\n<table class=\"tableizer-table\"><thead><tr class=\"tableizer-firstrow\"><th style=\"width:20%\">Sum</th><th style=\"width:32%\">Min. nr. of coins</th><th>Coin value (Previous Smaller Sum)</th></tr></thead><tbody><tr><td>0</td><td>0</td><td>-</td></tr><tr><td>1</td><td>1</td><td>1 (0)</td></tr><tr><td>2</td><td>2</td><td>1 (1)</td></tr><tr><td>3</td><td>1</td><td>3 (0)</td></tr><tr><td>4</td><td>2</td><td>1 (3)</td></tr><tr><td>5</td><td>1</td><td>5 (0)</td></tr><tr><td>6</td><td>2</td><td>3 (3)</td></tr><tr><td>7</td><td>3</td><td>1 (6)</td></tr><tr><td>8</td><td>2</td><td>3 (5)</td></tr><tr><td>9</td><td>3</td><td>1 (8)</td></tr><tr><td>10</td><td>2</td><td>5 (5)</td></tr><tr><td>11</td><td>3</td><td>1 (10)</td></tr> </tbody></table>\n\nAs a result we have found a solution of 3 coins which sum up to 11. \n\nAdditionally, by tracking data about how we got to a certain sum from a previous one, we can find what coins were used in building it. For example: to sum 11 we got by adding the coin with value 1 to a sum of 10. To sum 10 we got from 5. To 5 – from 0. This way we find the coins used: 1, 5 and 5. \n\nHaving understood the basic way a <strong>DP</strong> is used, we may now see a slightly different approach to it. It involves the change (update) of best solution yet found for a sum i, whenever a better solution for this sum was found. In this case the states aren’t calculated consecutively. Let’s consider the problem above. Start with having a solution of 0 coins for sum 0. Now let’s try to add first coin (with value 1) to all sums already found. If the resulting sum <strong>t</strong> will be composed of fewer coins than the one previously found – we’ll update the solution for it. Then we do the same thing for the second coin, third coin, and so on for the rest of them. For example, we first add coin 1 to sum 0 and get sum 1. Because we haven’t yet found a possible way to make a sum of 1 – this is the best solution yet found, and we mark <strong>S[1]=1</strong>. By adding the same coin to sum 1, we’ll get sum 2, thus making <strong>S[2]=2</strong>. And so on for the first coin. After the first coin is processed, take coin 2 (having a value of 3) and consecutively try to add it to each of the sums already found. Adding it to 0, a sum 3 made up of 1 coin will result. Till now, <strong>S[3]</strong> has been equal to 3, thus the new solution is better than the previously found one. We update it and mark <strong>S[3]=1</strong>. After adding the same coin to sum 1, we’ll get a sum 4 composed of 2 coins. Previously we found a sum of 4 composed of 4 coins; having now found a better solution we update <strong>S[4]</strong> to 2. The same thing is done for next sums – each time a better solution is found, the results are updated.\n\n### Elementary\n\nTo this point, very simple examples have been discussed. Now let’s see how to find a way for passing from one state to another, for harder problems. For that we will introduce a new term called recurrent relation, which makes a connection between a lower and a greater state.\n\nLet’s see how it works: \n\nGiven a sequence of N numbers – <strong>A[1] </strong>, <strong>A[2] </strong>, …, <strong>A[N] </strong>. Find the length of the longest non-decreasing sequence. \n\nAs described above we must first find how to define a \"state\" which represents a sub-problem and thus we have to find a solution for it. Note that in most cases the states rely on lower states and are independent from greater states. \n\nLet’s define a state <strong>i</strong> as being the longest non-decreasing sequence which has its last number <strong>A[i] </strong>. This state carries only data about the length of this sequence. Note that for <strong>i&lt;j</strong> the state <strong>i</strong> is independent from <strong>j</strong>, i.e. doesn’t change when we calculate state <strong>j</strong>. Let’s see now how these states are connected to each other. Having found the solutions for all states lower than <strong>i</strong>, we may now look for state <strong>i</strong>. At first we initialize it with a solution of 1, which consists only of the <strong>i-th</strong> number itself. Now for each <strong>j&lt;i</strong> let’s see if it’s possible to pass from it to state i. This is possible only when <strong>A[j]≤A[i] </strong>, thus keeping (assuring) the sequence non-decreasing. So if <strong>S[j] </strong> (the solution found for state <strong>j</strong>) + <strong>1</strong> (number <strong>A[i] </strong> added to this sequence which ends with number <strong>A[j] </strong>) is better than a solution found for <strong>i</strong> (ie. <strong>S[j]+1&gt;S[i] </strong>), we make <strong>S[i]=S[j]+1</strong>. This way we consecutively find the best solutions for each <strong>i</strong>, until last state N. \n\nLet’s see what happens for a randomly generated sequence: 5, 3, 4, 8, 6, 7: \n\n<table><thead><tr class=\"tableizer-firstrow\"><th style=\"width:20%\">I</th><th style=\"width:32%\">Length of Longest non-decreasing sequence (first I numbers)</th><th>The last sequence i from which we \"arrived\" to this one</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>1 (first number itself)</td></tr><tr><td>2</td><td>1</td><td>2 (second number itself)</td></tr><tr><td>3</td><td>2</td><td>2</td></tr><tr><td>4</td><td>3</td><td>3</td></tr><tr><td>5</td><td>3</td><td>3</td></tr><tr><td>6</td><td>4</td><td>5</td></tr> </tbody></table>\n\n<strong>Practice problem:</strong><br>\n\nGiven an undirected graph <strong>G</strong> having <strong>N</strong> (1&lt;N&lt;=1000) vertices and positive weights. Find the shortest path from vertex 1 to vertex N, or state that such path doesn’t exist.\n\nHint: At each step, among the vertices which weren’t yet checked and for which a path from vertex 1 was found, take the one which has the shortest path, from vertex 1 to it, yet found. \n\nTry to solve the following problems from Topcoder competitions:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4493&pm=1259\">ZigZag</a> – 2003 TCCC Semifinals 3\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5009&pm=2402\">BadNeighbors</a> – 2004 TCCC Round 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5006&pm=1918\">FlowerGarden</a> – 2004 TCCC Round 1\n\n### Intermediate\n\nLet’s see now how to tackle bi-dimensional DP problems.\n\n<strong>Problem:</strong>\n\nA table composed of <strong>N x M</strong> cells, each having a certain quantity of apples, is given. You start from the upper-left corner. At each step you can go down or right one cell. Find the maximum number of apples you can collect. \n\nThis problem is solved in the same way as other DP problems; there is almost no difference.\n\nFirst of all we have to find a state. The first thing that must be observed is that there are at most 2 ways we can come to a cell – from the left (if it’s not situated on the first column) and from the top (if it’s not situated on the most upper row). Thus to find the best solution for that cell, we have to have already found the best solutions for all of the cells from which we can arrive to the current cell. \n\nFrom above, a recurrent relation can be easily obtained:<br>\n<strong>S[i][j]=A[i][j] + max(S[i-1][j], if i&gt;0 ; S[i][j-1], if j&gt;0) </strong> (where <strong>i</strong> represents the row and <strong>j</strong> the column of the table , its left-upper corner having coordinates {0,0} ; and <strong>A[i][j]</strong> being the number of apples situated in cell <strong>i,j</strong>). \n\n<strong>S[i][j] </strong> must be calculated by going first from left to right in each row and process the rows from top to bottom, or by going first from top to bottom in each column and process the columns from left to right. \n\nPseudocode:\n```\nFor i = 0 to N - 1\n\tFor j = 0 to M - 1\n\tS[i][j] = A[i][j] +\n\t\tmax(S[i][j-1], if j>0 ; S[i-1][j], if i>0 ; 0)\n\nOutput S[n-1][m-1]\n```\n\nHere are a few problems, from Topcoder Competitions, for practicing:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4709&pm=1889\">AvoidRoads</a> – 2003 TCO Semifinals 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4482&pm=1592\">ChessMetric</a> – 2003 TCCC Round 4\n\n### Upper-Intermediate\n\nThis section will discuss about dealing DP problems which have an additional condition besides the values that must be calculated.\n\nAs a good example would serve the following problem: \n\nGiven an undirected graph <strong>G</strong> having positive weights and <strong>N</strong> vertices.\n\nYou start with having a sum of <strong>M</strong> money. For passing through a vertex <strong>i</strong>, you must pay <strong>S[i] </strong> money. If you don’t have enough money – you can’t pass through that vertex. Find the shortest path from vertex 1 to vertex N, respecting the above conditions; or state that such path doesn’t exist. If there exist more than one path having the same length, then output the cheapest one. Restrictions: 1&lt;N&lt;=100 ; 0&lt;=M&lt;=100 ; for each i, 0&lt;=S[i]&lt;=100. As we can see, this is the same as the classical Dijkstra problem (finding the shortest path between two vertices), with the exception that it has a condition. In the classical Dijkstra problem we would have used a uni-dimensional array <strong>Min[i] </strong>, which marks the length of the shortest path found to vertex <strong>i</strong>. However in this problem we should also keep information about the money we have. Thus it would be reasonable to extend the array to something like <strong>Min[i][j] </strong>, which represents the length of the shortest path found to vertex <strong>i</strong>, with <strong>j</strong> money being left. In this way the problem is reduced to the original path-finding algorithm. At each step we find the unmarked state (i,j) for which the shortest path was found. We mark it as visited (not to use it later), and for each of its neighbors we look if the shortest path to it may be improved. If so – then update it. We repeat this step until there will remain no unmarked state to which a path was found. The solution will be represented by <strong>Min[N-1][j] </strong> having the least value (and the greatest <strong>j</strong> possible among the states having the same value, i.e. the shortest paths to which has the same length). \n\nPseudocode:\n```\nSet states(i,j) as unvisited for all (i,j)\nSet Min[i][j] to Infinity for all (i,j)\n\nMin[0][M]=0\n\nWhile(TRUE)\n\nAmong all unvisited states(i,j) find the one for which Min[i][j]\nis the smallest. Let this state found be (k,l).\n\nIf there wasn't found any state (k,l) for which Min[k][l] is\nless than Infinity - exit While loop.\n\nMark state(k,l) as visited\n\nFor All Neighbors p of Vertex k.\n\tIf (l-S[p]>=0 AND\n\tMin[p][l-S[p]]>Min[k][l]+Dist[k][p])\n\t\tThen Min[p][l-S[p]]=Min[k][l]+Dist[k][p]\ni.e.\nIf for state(i,j) there are enough money left for\ngoing to vertex p (l-S[p] represents the money that\nwill remain after passing to vertex p), and the\nshortest path found for state(p,l-S[p]) is bigger\nthan [the shortest path found for\nstate(k,l)] + [distance from vertex k to vertex p)],\nthen set the shortest path for state(i,j) to be equal\nto this sum.\nEnd For\n\nEnd While\n\nFind the smallest number among Min[N-1][j] (for all j, 0<=j<=M);\nif there are more than one such states, then take the one with greater\nj. If there are no states(N-1,j) with value less than Infinity - then\nsuch a path doesn't exist.\n```\n\nHere are a few Topcoder problems for practicing:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4705&pm=1166\">Jewelry</a> – 2003 TCO Online Round 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4555&pm=1215\">StripePainter</a> – SRM 150 Div 1\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829\">QuickSums</a> – SRM 197 Div 2\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4630&pm=1861\">ShortPalindromes</a> – SRM 165 Div 2\n\n### Advanced\n\nThe following problems will need some good observations in order to reduce them to a dynamic solution.\n\n<strong>Problem <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5854&pm=2940\">StarAdventure</a> – SRM 208 Div 1:</strong> \n\nGiven a matrix with <strong>M</strong> rows and <strong>N</strong> columns (<strong>N x M</strong>). In each cell there’s a number of apples.<br> You start from the upper-left corner of the matrix. You can go down or right one cell. You need to arrive to the bottom-right corner. Then you need to go back to the upper-left cell by going each step one cell left or up. Having arrived at this upper-left cell, you need to go again back to the bottom-right cell.<br> Find the maximum number of apples you can collect.<br>When you pass through a cell – you collect all the apples left there.\n\nRestrictions: 1 &lt; <strong>N</strong>, <strong>M</strong> &lt;= 50 ; each cell contains between 0 and 1000 apples inclusive. \n First of all we observe that this problem resembles to the classical one (described in Section 3 of this article), in which you need to go only once from the top-left cell to the bottom-right one, collecting the maximum possible number of apples. It would be better to try to reduce the problem to this one. Take a good look into the statement of the problem – what can be reduced or modified in a certain way to make it possible to solve using DP? First observation is that we can consider the second path (going from bottom-right cell to the top-left cell) as a path which goes from top-left to bottom-right cell. It makes no difference, because a path passed from bottom to top, may be passed from top to bottom just in reverse order. In this way we get three paths going from top to bottom. This somehow decreases the difficulty of the problem. We can consider these 3 paths as left, middle and right. When 2 paths intersect (like in the figure below) \n\n<center>\n<img src=\"https://www.topcoder.com/i/education/dynProg_1.gif\" border=\"0/\">\n</center>\n\nwe may consider them as in the following picture, without affecting the result: \n\n<center>\n<img src=\"https://www.topcoder.com/i/education/dynProg_2.gif\" border=\"0/\">\n</center>\n\nThis way we’ll get 3 paths, which we may consider as being one left, one middle and the other – right. More than that, we may see that for getting an optimal results they must not intersect (except in the leftmost upper corner and rightmost bottom corner). So for each row <strong>y</strong> (except first and last), the <strong>x</strong> coordinates of the lines (<strong>x1[y] </strong>, <strong>x2[y] </strong> and respectively <strong>x3[y] </strong>) will be : <strong>x1[y] </strong> &lt; <strong>x2[y] </strong> &lt; <strong>x3[y] </strong>. Having done that – the DP solution now becomes much clearer. Let’s consider the row y. Now suppose that for any configuration of <strong>x1[y-1] </strong>, <strong>x2[y-1] </strong> and <strong>x3[y-1] </strong> we have already found the paths which collect the maximum number of apples. From them we can find the optimal solution for row <strong>y</strong>. We now have to find only the way for passing from one row to the next one. Let <strong>Max[i][j][k] </strong> represent the maximum number of apples collected till row <strong>y-1</strong> inclusive, with three paths finishing at column <strong>i</strong>, <strong>j</strong>, and respectively <strong>k</strong>. For the next row <strong>y</strong>, add to each <strong>Max[i][j][k] </strong> (obtained previously) the number of apples situated in cells (<strong>y,i</strong>) , (<strong>y,j</strong>) and (<strong>y,k</strong>). Thus we move down at each step. After we made such a move, we must consider that the paths may move in a row to the right. For keeping the paths out of an intersection, we must first consider the move to the right of the left path, after this of the middle path, and then of the right path. For a better understanding think about the move to the right of the left path – take every possible pair of, <strong>k</strong> (where <strong>j&lt;k</strong>), and for each i (1 i&lt;j) consider the move from position (<strong>i-1,j,k</strong>) to position (<strong>i,j,k</strong>). Having done this for the left path, start processing the middle one, which is done similarly; and then process the right path.  \n\nTC problems for practicing:\n\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4710&pm=1996\">MiniPaint</a> – SRM 178 Div 1\n\n<strong>Additional Note:</strong>\n\nWhen have read the description of a problem and started to solve it, first look at its restrictions. If a polynomial-time algorithm should be developed, then it’s possible that the solution may be of DP type. In this case try to see if there exist such states (sub-solutions) with the help of which the next states (sub-solutions) may be found. Having found that – think about how to pass from one state to another. If it seems to be a DP problem, but you can’t define such states, then try to reduce the problem to another one (like in the example above, from Section 5).\n\n<strong>Mentioned in this writeup:</strong>\n\nTCCC ’03 Semifinals 3 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4493&pm=1259\">ZigZag</a>\nTCCC ’04 Round 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5009&pm=2402\">BadNeighbors</a>\nTCCC ’04 Round 1 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5006&pm=1918\">FlowerGarden</a>\nTCO ’03 Semifinals 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4709&pm=1889\">AvoidRoads</a>\nTCCC ’03 Round 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4482&pm=1592\">ChessMetric</a>\nTCO ’03 Round 4 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4705&pm=1166\">Jewelry</a>\nSRM 150 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4555&pm=1215\">StripePainter</a>\nSRM 197 Div II Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829\">QuickSums</a>\nSRM 165 Div II Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4630&pm=1861\">ShortPalindromes</a>\nSRM 208 Div I Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5854&pm=2940\">StarAdventure</a>\nSRM 178 Div I Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4710&pm=1996\">MiniPaint</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":200,"downvotes":32}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7lMyNjEbRPf9epZLzfkupP","type":"Entry","createdAt":"2023-09-06T19:18:01.943Z","updatedAt":"2024-07-25T19:18:13.436Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":55,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"STAGING VS. TESTING ENVIRONMENTS: UNDERSTANDING THE CORE DIFFERENCES","slug":"staging-vs-testing-environments-understanding-the-core-differences","type":"Article","trackCategory":["Development"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sofL39d1uWshUiu27kL21","type":"Entry","createdAt":"2019-10-24T21:25:43.778Z","updatedAt":"2019-10-24T21:25:43.778Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Development","trackParent":"Topcoder"}}],"tags":["Core Differences"],"creationDate":"2023-09-06","readTime":"8min","content":"In the software development and deployment process, having distinct environments for staging and testing plays a crucial role in ensuring the quality and reliability of the final product. These environments serve different purposes and offer unique advantages for development teams. In this article, we will explore the core differences between staging and testing environments, along with real-world examples to illustrate their functionalities.\n\n## MAIN DIFFERENCES\n\n### 1. Definition and Purpose\n\nThe staging environment is an intermediary platform between the development and production environments. It is designed to closely mimic the production environment, allowing developers to test the application in a near-production setup. The primary purpose of the staging environment is to validate code changes, check for integration issues, and assess the overall system behavior before releasing the updates to the live production environment.\n\nThe testing environment, on the other hand, is focused on comprehensive testing activities. It is a controlled setup where developers and testers perform various types of testing, such as:\n\n__Unit testing:__ The initial level of testing in the software testing process focuses on independently evaluating the various parts or units of a software program. A unit could be a brief section of code, a method, a function, or a class. Unit testing checks that each piece of software operates as expected and satisfies its functional requirements.\n\nUnit testing characteristics:\n- Developers carry out during the development process.\n- Tests are separated and run in a controlled environment, typically with the help of automated testing frameworks.\n- It aids in the early detection of flaws and problems, making them easier and less expensive to rectify.\n- Allows developers to test the validity of individual units without taking their interactions into account.\n\n__Integration testing__ follows unit testing and focuses on evaluating the interactions and integration between distinct units or modules of a software application. The purpose is to detect issues that develop when units interact with one another and guarantee that they work cohesively as a whole.\n\nIntegration Testing Characteristics:\n\n- Performed following unit testing and prior to system testing.\n- It entails testing the integrated functionality of numerous components to ensure that they correctly communicate and share data.\n- Integration testing can be done iteratively, adding and testing more integrated components as development develops.\n- It aids in the detection of issues such as data connection faults, boundary mismatches, and module interactions that were previously undetected during unit testing.\n\n__Performance testing__ is a sort of testing that assesses how well a software program operates under specified conditions, such as a large number of users, big data sets, or high traffic loads. The primary goal is to identify performance bottlenecks, monitor reaction times, and guarantee that the application can manage the predicted load without performance degradation.\n\nPerformance Testing Characteristics:\n\n- Simulates real-world scenarios to evaluate the responsiveness, stability, and scalability of the program.\n- Load testing (testing under expected load), stress testing (testing beyond predicted load), and scalability testing (testing to determine system growth capacity) are all examples of performance testing.\n- Under various settings, it aids in the discovery of performance-related issues such as poor response times, resource overutilization, memory leaks, and system failures.\n\n__Security testing__ is an important part of software testing that focuses on discovering flaws and vulnerabilities in an application's security mechanisms. The purpose is to safeguard the application from potential security threats and illegal access.\n\nSecurity Testing Characteristics:\n\n- Security testing is carried out to ensure that sensitive data and user information are secure in accordance with industry standards and best practices.\n- Ethical hackers or security specialists replicate real-world attacks and detect potential entry points for malevolent activity by performing penetration testing.\n\n### 2. Isolation and Accessibility\n\nIn a staging environment, access is limited to specific team members who are responsible for testing and quality assurance. A select group thoroughly evaluates changes before promoting them to production, thanks to this controlled access. It also prevents unauthorized users from potentially causing issues or making changes that are not adequately validated.\n\nIn contrast, a testing environment is often more accessible to the development team and testers. Since the primary goal is to perform comprehensive testing, multiple team members may need access to execute different test cases simultaneously. It is essential to manage access and version control carefully to avoid conflicts and confusion.\n\nExample:\n\nImagine a large e-commerce website undergoing a major update with personalized product recommendations, which make customized product recommendations based on browsing habits, previous purchases, and preferences using machine learning algorithms and data on user behavior. The feature is tested for efficiency and performance by the development team in a setting that is similar to production. Senior developers and quality assurance experts carry out thorough testing to confirm the precision and applicability of customized product recommendations. \n\nWhen new versions are prepared for validation, the staging environment is updated to make sure the feature works properly and provides pertinent recommendations before it is published to the live production environment. The testing environment is dynamic and focuses on assessing how well the feature integrates with other systems as well as how it affects business metrics and user engagement. Before being finally deployed to the live production environment, the feature is still available to various departments so that they can collect feedback and make sure it meets stakeholder needs.\n\n### 3. Data and Configuration\n\nIn the staging environment, developers often use a subset of real production data, sometimes anonymized or obscured, to maintain data privacy and security. Additionally, the configuration settings in the staging environment are usually aligned with those of the production environment, ensuring that the behavior of the application in staging closely mirrors what can be expected in production.\n\nTesting environments typically contain synthetic or mock data specifically designed to test different scenarios and edge cases effectively. Since testing environments are frequently used for unit tests and integration tests, having control over the data helps maintain consistency and ensure predictable testing outcomes.\n\nExample:\n\nSuppose a social media platform is adding a new tool called “Interest Pals”, which will propose friends based on users' common interests and pastimes. This feature improves social connections and engagement by identifying users with shared interests using machine learning algorithms and user settings. The development team is primarily concerned with integrating the feature into the current platform, verifying its efficiency and performance with actual user data, and ensuring the security and privacy of user data. \n\nThe testing environment replicates various friendship scenarios using synthetic data to assess the feature's capabilities and identify potential edge cases, while the staging environment is used to implement the key algorithms and logic. The testing environment is dynamic since the feature and the testing procedure are frequently updated and modified. Before the feature is implemented in the staging and live production settings, it will be rigorously tested using fake data to evaluate its performance in a variety of friendship scenarios.\n\n### 4. Stability and Updates\n\nIn the staging environment, the emphasis is on stability and predictability. It is common to have fewer code changes in this environment, as the primary goal is to validate that the new features or updates work as intended before production deployment. Staging environments are more static in nature to prevent any unexpected disruptions.\n\nConversely, the testing environment is highly dynamic, with frequent code updates and changes. Developers continuously integrate new code to conduct various types of testing, and the environment may be reset or refreshed regularly to ensure a clean slate for testing activities.\n\nExample:\n\nA banking application is introducing a new online feature called Finance Hub, which enables users to link and examine accounts from numerous banks and financial organizations. The development team follows coding and security requirements as they work on the feature in the staging environment. To ensure functioning and compliance with banking rules and data privacy legislation, unit testing is done. Integrity testing guarantees smooth communication between components. \n\nSenior developers and quality assurance experts carry out thorough testing to confirm stability and adherence to banking standards and data privacy legislation. Protection audits, such as penetration testing, reveal potential flaws and guarantee the protection of user data. Before deploying the product to the staging environment, the team can assess the product's performance, usability, and security parameters in the dynamic testing environment.\n\n### 5. Risk and Scope\n\nThe staging environment plays a critical role in software testing by providing a simulation of the production environment. This allows developers to identify and resolve significant problems before software is released. Potential issues that can arise in staging include security vulnerabilities, performance slowdowns, bugs, data corruption, compatibility issues between staging and production, and problems meeting accessibility standards.\n\nIf not addressed, these problems could lead to hacked systems, slow or crashing software, loss of user data, and legal action over inaccessible software. Inadequate backup systems could also make data recovery difficult after corruption. Differences between staging and production may require expensive rework down the line.\n\nThe testing environment, due to its controlled and isolated nature, is considered a safer environment to experiment with new changes. While failures in this environment are valuable for identifying issues early in the development process, they have a relatively low impact on the overall project.\n\nExample:\n\nTake the use case of a software company introducing an expense auto-bot feature in its accounting software, aiming to streamline the process of categorizing expenses for businesses.  The staging environment is updated when new versions are ready for validation, ensuring the feature functions correctly and meets required standards before being released to the live production environment. The testing environment is dynamic, with frequent updates and changes made to the feature and the testing process. The goal is to catch critical issues like inaccurate tax calculations early on and prevent them from reaching the staging environment, reducing the risk of financial losses for businesses using the accounting software.\n\n### Conclusion:\nIn summary, the staging and testing environments serve distinct purposes in the software development and deployment life cycles. The staging environment acts as an intermediate platform for validating code changes and system integration, while the testing environment focuses on comprehensive testing to ensure a high-quality, stable, and reliable product. By understanding and effectively utilizing these environments, development teams can deliver software with reduced risks, improved quality, and enhanced user experiences.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1tb4jBUcwMt8P7VnUiu0J1","type":"Asset","createdAt":"2023-09-06T19:21:40.802Z","updatedAt":"2023-09-06T19:21:40.802Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"google-deepmind-mbq0qL3ynMs-unsplash","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1tb4jBUcwMt8P7VnUiu0J1/6832a5541d83ccbc176df7b954041cc5/google-deepmind-mbq0qL3ynMs-unsplash.jpg","details":{"size":2263000,"image":{"width":4000,"height":4000}},"fileName":"google-deepmind-mbq0qL3ynMs-unsplash.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3iMuYI2Zp5Iwl4MXVarHfK","type":"Entry","createdAt":"2023-09-06T19:15:31.660Z","updatedAt":"2023-09-06T19:15:31.660Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Florence Njau","tcHandle":"FlowTech"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3L3Igwqp75i5SmxeIXrO9l","type":"Entry","createdAt":"2023-09-06T18:56:18.871Z","updatedAt":"2023-09-06T18:56:18.871Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":128,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Prototyping in UX design: A basic guide (benefits + types)","slug":"prototyping-in-ux-design-a-basic-guide-benefits-types","type":"Article","trackCategory":["Design"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5W8yVIchiseIGTWrWKXN57","type":"Entry","createdAt":"2019-09-18T07:36:54.570Z","updatedAt":"2023-09-06T19:01:10.075Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Design"}}],"tags":["prototyping","wireframes","high-fidelity prototype","low-fidelity prototype","UX design"],"creationDate":"2023-09-06","readTime":"10min","content":"### What is Prototyping?\nThe average person spends 10 hours a day on their phone. That's a lot of time to be using a product that's not user-friendly. In a study by Nielsen Norman Group, 79% of users said they would abandon a website if it were difficult to use. So, how do you know if the product you’re building is one that people will enjoy using?\n\nBy prototyping.\n\nPrototyping is creating early versions of your product to test and validate its usability and functionality before investing in development. By prototyping, you can identify and fix usability issues early on, get feedback from users, and communicate your ideas to stakeholders. This will help to build a product that users love and that is more likely to succeed.\n\n### What makes UX prototyping necessary? \nPrototyping is the key to producing products that people enjoy. You could think your product is fantastic, but you won't know until you put it to users. This makes the final product easier to use by allowing designers to test ideas and receive user feedback before development.\n\nThe following are some benefits associated with prototyping in UX design:\n\nA. Improved User Experience\nUnderstanding user behavior, needs, and trouble areas is made possible through prototyping. Designers may get customer input early on and make adjustments before the product is finished by building a functional prototype. By doing this, you can make that the product is user-friendly and satisfies the demands of the intended market.\n\nA [blog post](https://www.nngroup.com/articles/mozilla-paper-prototype/) from Nielsen Norman Group describes how Mozilla used prototyping to ease the experience of users when searching for help articles. During the prototyping session, Mozilla found that users had difficulty finding the help articles they were looking for. This feedback helped Mozilla to improve the search functionality on their website.\n\nB. Enhanced Participation and Communication\nAlso, prototypes are a useful resource for inside teams. They aid in visualizing the designer's concept and making it simple for stakeholders and engineers to grasp. This can assist to keep communication open and prevent misunderstandings.\n\nThey can be especially helpful for stakeholders who are not familiar with design or user experience. By creating a tangible representation of a product or feature, prototypes help everyone involved to see the big picture and understand how the different pieces fit together.\n\nAdditionally, prototypes let designers gather input from stakeholders and programmers at the beginning of the design process. The prototype may be modified in response to this feedback to fulfill the demands of all parties involved while also streamlining the development process.\n\nC. Feedback and Validation at an Early Stage\n\"Prototypes are the best way to get feedback from users early and often,\" says Jeff Gothelf, author of Lean UX. By collecting early customer input through prototyping, designers may save up to 90% on redesign expenses. \n\nThis is how prototyping achieves it.\n\n- Prototypes allow you to test your ideas with users early on. This is important because it gives you the opportunity to get feedback on your designs before you've invested too much time and money in development.\n\n- Prototypes can help you identify usability issues early on. This is important because it can save you a lot of time and money in the long run. If you can identify and fix usability issues early on, you'll be less likely to have to make costly changes later on.\n\n- Prototypes can help you get buy-in from stakeholders. By showing stakeholders a prototype of your product, you can give them a better understanding of your vision and get their feedback early on. This can help to ensure that your product meets the needs of your stakeholders and that it is approved for development.\n\nD. Savings in both money and time\nA useful technique that can speed up development and save costs is prototyping. Early versions can save money later on by seeing and resolving functional problems beforehand on. Businesses can conserve a lot of time and money by doing this, which will speed up the time it takes for them to market their products.\n\nIn the same way, reducing the number of faults that need to be fixed before a product's release helps to shorten time-to-market. This is so that you may test your product early on with people and obtain their input on how it functions. This input might assist you in identifying and correcting any usability issues before you release your product to the public.\n\nE. Reduced Development Risks\nPrototyping can help to identify technical issues early on. This is because prototypes can be used to test the functionality of a product before it is fully developed. This can help to identify any technical problems that may occur, such as compatibility issues or performance bottlenecks.\n\nAnd by identifying and fixing technical problems early on, prototypes can help to ensure that the development process goes smoothly.\n\nF. Collaboration\nWhen kicking off a project, prototyping is an excellent method for teamwork and idea visualization. Teams can come up with creative concepts and brainstorm ideas by creating sketches and wireframes. This ensures that everyone is aligned and heading in the right direction.\n\nPrototypes are also a valuable tool for gathering early feedback from stakeholders and generating insights through user testing.\n\nAn example of how prototypes are used in a user testing session is found here.\n\n### The Prototyping Process\nThe prototyping process is iterative, which means that you will likely go back and forth between the different steps as you get feedback from users. This is a normal part of the process, and it is important to be open to making changes to your prototype based on feedback.\n\nIt usually follows these steps:\n\n1. Define the goals of the prototype. What do you want to test? What feedback are you hoping to get?\n2. Choose the right type of prototype. There are many different types of prototypes, each with its own benefits and drawbacks. The best kind of prototype for a project will depend on the specific needs of the project.\n3. Build the prototype. Several tools and methods can be used to do this.\n4. With users, test the prototype through usability tests. Obtain user input and employ it to enhance the prototype.\n5. Develop the prototype further. Based on the comments you get, modify the prototype.\n6. Until you are satisfied with the prototype, repeat steps 4-5.\n\n### Types of Prototypes In UX Design\nA large percentage of usability problems can be identified through low-fidelity prototyping. That's why prototypes are a secret weapon of UX designers. \n\nBut the best type of prototype for you will depend on your specific project. Some questions to ask when choosing a prototype for a project are:\n\n- What are the specific goals of your prototype?\n- What are the constraints on your project, such as time and budget?\n- Who are your target users?\n- What kind of feedback are you looking for?\n\nThere are many different sorts of prototypes, each with advantages and disadvantages. Let's look at them.\n\n### Low-Fidelity/Lo-fi Prototypes\nThe most basic form of prototypes is low-fidelity ones. They are often made from paper, sticky notes, or other cheap materials. Lo-fi's are ideal for testing and the early stages of design since they can be rapidly and readily created. Due to their lack of visual appeal, they might not be as effective for assessing complex interactions.\n\nWhen are low-fi prototypes useful?\n\nLow-fidelity prototypes are used in the early stages of the design process when designers continue to develop and test various ideas and concepts. They are used to:\n\n- Test the overall layout and structure of a product.\n- Get feedback on the flow of information.\n- Identify usability problems.\n- Validate assumptions about user behavior.\n\nSome types of low-fidelity prototypes include:\n\n1. Paper prototypes: These are made by sketching out the design of a product on paper. They can be used to represent the layout of a product, the flow of information, or the interaction between different elements. They are a good option for projects where it is important to be able to physically interact with the prototype.\n\n![white printer paper](//images.ctfassets.net/piwi0eufbb2g/ezjlDQKxDONXgZypSszWh/370698635ad2f119bc86fd9472d5d9c4/amelie-mourichon-zVdUQ0-opSY-unsplash.jpg)\n\n2. Storyboards: These are a type of low-fidelity prototype that uses images or text to represent the flow of a product. Storyboards can be used to show how users will interact with a product and to identify potential usability problems.\n\n![photo-1624961151169-b3df5c0f06ab](//images.ctfassets.net/piwi0eufbb2g/1DyNWSM1x9KzFUC3YgnxGm/aa96068acbb37778bfc38584187a011c/photo-1624961151169-b3df5c0f06ab.avif)\n\n### Pros \n- Quick and easy to create - This makes them ideal for early-stage design and testing. This can save time and money, and it allows designers to iterate on their designs quickly.\n- Inexpensive - They are made using low-cost materials, such as paper, sticky notes, or cardboard. This makes them a cost-effective way to test ideas and concepts.\n- Easy to get feedback - Low-fidelity prototypes are easy to share with others, which makes them a great way to get feedback from users. \n\n### Cons\n- Not visually appealing - Low-fidelity prototypes are not as visually appealing as high-fidelity prototypes. This can make it difficult to get feedback from users who are focused on the visual design of a product.\n- Not as effective for testing complex interactions - Low-fidelity prototypes may not be as effective for testing complex interactions. This is because they may not be able to accurately represent the way that a product will actually work.\n\n### Medium-Fidelity Prototypes/Mid-Fidelity Prototypes\nMedium-fidelity prototypes strike a balance between low and high fidelity by providing enough visual detail to give users a good sense of the look and feel of the product, while also being interactive enough to allow users to test how the product works. \n\nThey offer more interactivity than low-fidelity prototypes because they typically include some interactive elements, such as buttons, text fields, and drop-down menus. They are typically created using digital tools, such as Axure, Adobe XD, or Figma.\n\nWhen are medium-fidelity prototypes used?\n\nThey are used after low-fidelity prototypes have been created and tested. They can be employed to:\n\n- Get feedback on the visual design of a product.\n- Test the interactivity of a product.\n- Identify usability problems.\n- Validate assumptions about user behavior.\n\nA type of medium-fidelity prototype is:\n\n- Wireframes and Clickable/interactive prototypes: Wireframes are a type of mid-fidelity prototype that focuses on the layout of a product. Wireframes typically do not include any visual elements, such as images or colors. They are used to represent the structure of a product and to test the flow of information. They are typically created with a wireframing tool like Axure. They can also be designed in Sketch or Figma usually in black and white, and then previewed in software like Invision or Marvel for prototyping.\n\nIn the same manner, wireframe prototypes that are clickable or interactive allow people to engage with the components of a product by clicking on them. Clickable wireframe prototypes can help discover possible usability issues by testing how consumers interact with a product. They may be leveraged to test intricate interactions and gather user input on the overall user experience.\n\nThe image below shows how an onboarding process in mid-fidelity could look.\n\n![mid-fi](//images.ctfassets.net/piwi0eufbb2g/y7TGpI9qykN9v75DmrgvQ/46d2e891439a3fab52e713d33a91f97a/mid-fi.gif)\n\n### Pros\n- More visually appealing - They are more visually appealing than low-fidelity prototypes, which can make them easier to get feedback from users.\n- More interactive - Medium-fidelity prototypes are more interactive than low-fidelity prototypes, which can give users a better sense of how the product will actually work.\n- A good balance of cost and time - Medium-fidelity prototypes are a good balance of cost and time, as they are not as expensive or time-consuming to create as high-fidelity prototypes.\n\n### Cons\n- Not as realistic as high-fidelity prototypes - Medium-fidelity prototypes are not as realistic as high-fidelity prototypes, which can make it difficult to test some complex interactions.\n- Not as easy to iterate on as low-fidelity prototypes - Medium-fidelity prototypes can be more difficult to iterate on than low-fidelity prototypes, as they require more time and effort to update.\n- May not be as effective for testing the final user experience - This is because they may not be able to accurately represent the way that a product will actually look and feel.\n\n### High-Fidelity Prototypes\nHigh-fidelity prototypes are the most visually appealing and interactive type of prototype. They are typically created using digital tools, such as Adobe XD or Figma. High-fidelity prototypes can test complex interactions and provide a realistic preview of the final product.\n\nWhen are high-fidelity prototypes typically used?\n\nHigh-fidelity prototypes are used in the later stages of the design process after low-fidelity and medium-fidelity prototypes have been used to test the overall layout and structure of a product. They can be used to:\n\n- Get feedback on the final user experience\n- Get buy-in from stakeholders\n- Demonstrate the product to potential customers\n\nA type of high-fidelity prototype is:\n\n- Clickable/Interactive prototypes: Prototypes that are clickable or interactive enable people to engage with the components of a product by clicking on them. Clickable prototypes can help discover possible usability issues by testing how consumers interact with a product. They may be used to test intricate interactions and gather opinions of users on the overall user experience.\n\nLet's examine the high-quality version of the above onboarding process.\n![hi-fi prototype](//images.ctfassets.net/piwi0eufbb2g/5i0nETdswL5XoaocwY4sVK/fddcb14b5278cfa02edacf4f4e114ed2/hi-fi_prototype.gif)\n\n### Pros\n- High visual appeal - High-fidelity prototypes have attractive visuals, which can assist pique consumers' interest in and engagement with the prototype. This is particularly useful for visual design-focused products like e-commerce websites and mobile applications.\n- Realistic interactivity - High-fidelity prototypes can be interactive, which allows users to interact with the prototype in a way that is similar to how they would interact with the final product. This can help to identify any usability problems that may occur in the final product.\n- Near-realistic user experience - High-fidelity prototypes can simulate a near-realistic user experience, which can help get users' feedback on the product's overall usability. This can be helpful for identifying any problems that users may have with the product, such as difficulty understanding how to use the product or frustration with the product's performance.\n\n### Cons\n- Time-consuming and expensive to create - High-fidelity prototypes can be time-consuming and expensive to create, which can make them a less feasible option for projects with limited time or budget.\n- May not be as effective for testing early-stage ideas - High-fidelity prototypes may not be as effective for testing early-stage ideas, as they can be too polished and may not accurately represent the final product.\n\n### Prototypes for Virtual Reality (VR) and Augmented Reality (AR)\nUsers can engage with digital information more immersively thanks to the upcoming technologies of virtual reality (VR) and augmented reality (AR). When compared to AR, which superimposes digital material over the actual environment, VR delivers an entirely immersive experience.\n\nVR and AR prototypes can be used to design and test immersive user experiences. They allow designers to see how users interact with digital content in a realistic environment and identify potential usability problems.\n\nWhen are VR and AR prototypes used?\n\nVR and AR prototypes are early versions of VR and AR experiences created to test the design and functionality of the experience. They can be used to:\n\n- Test the feasibility of a VR or AR experience.\n- Get feedback from users\n- Demonstrate the experience to stakeholders\n\nSome examples are;\n\n- [IKEA Kreativ](https://www.ikea.com/us/en/home-design/) -  is an augmented reality software that enables customers to visualize how IKEA furniture will appear in their residences. Users may place digital furniture in their physical surroundings and view how it appears from various perspectives.\n- Google Tilt Brush - Users may paint in a 3D environment using the AR painting software [Google Tilt Brush](https://www.tiltbrush.com/).\n\nNote: These examples would better be appreciated if you download the IKEA Kreativ and Google Tilt Brush apps or try them out from their respective websites.\n\n### Benefits\n- Increased immersion - VR and AR prototypes can create a more immersive experience for users, which can help designers identify potential usability problems.\n- Reduced development costs - VR and AR prototypes can help to reduce development costs by identifying potential problems early in the design process.\n- Improved user feedback - VR and AR prototypes can help to improve user feedback by allowing users to interact with digital content in a more realistic environment.\n\n### Challenges\n- Cost - VR and AR prototypes can be expensive, especially if they are high-fidelity.\n- Hardware requirements - VR and AR prototypes require specialized hardware, such as VR headsets or AR glasses. This can make them difficult to use for testing with many users.\n- Software requirements - VR and AR prototypes require specialized software like Unity or Unreal Engine. This can make them difficult to create for designers unfamiliar with these platforms.\n\n### Final thoughts\nPrototyping is the secret weapon of UX designers who want to take a step toward better UX. There are many different types of prototypes, each with its own benefits and drawbacks. But, the best type of prototype for a particular project will depend on its specific goals.\n\nWhatever kind of prototype you decide on, iterative design is made possible via prototyping, which enables designers to test their concepts. For that reason, dear designers, make use of prototypes to fill the gap between ideas and realities.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TjMoEs4HOxvv6rcSzA1uP","type":"Asset","createdAt":"2023-09-06T18:54:06.319Z","updatedAt":"2023-09-06T18:54:06.319Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"photo-1576153192621-7a3be10b356e","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4TjMoEs4HOxvv6rcSzA1uP/09c8ce04f0afddf1e40c770056229f66/photo-1576153192621-7a3be10b356e.avif","details":{"size":27900,"image":{"width":500,"height":375}},"fileName":"photo-1576153192621-7a3be10b356e.avif","contentType":"image/avif"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"7HIyZkudVKIQdeECSNzSuA"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5qUC92WWB9Cr7ufhEZaaSB","type":"Entry","createdAt":"2023-07-10T17:20:53.883Z","updatedAt":"2023-07-10T19:29:39.960Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":155,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Information Architecture vs UX Design: What's the Difference? ","slug":"information-architecture-vs-ux-design-whats-the-difference","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}}],"tags":["UX","Information Architecture"],"creationDate":"2023-07-10","readTime":"10 min","content":"In the world of digital design, two pillars stand tall, shaping our interactions with websites, apps, and digital products: Information Architecture (IA) and User Experience Design (UX Design). Like two skilled architects, they work diligently to create seamless and captivating digital landscapes. In this piece, we'll find out what sets them apart and how they complement each other.\n\n## Information Architecture In A Nutshell\n\nInformation Architecture, the mastermind behind seamless digital journeys, is all about organizing information in a captivating, logical, and user-friendly way. It's the secret sauce that ensures users find what they're looking for and understand it effortlessly.\n\n### The Key Elements Of Information Architecture\n\nThese elements are the secret that enables IA to transform design chaos into clarity and make the digital world a user's playground. They include the following;\n\n__1\\. Organization and Structure:__ IA focuses on arranging information logically and coherently. It involves determining hierarchies, categorizing content, and establishing relationships between different pieces of information.\n\n__2\\. Navigation Systems:__ IA designs intuitive navigation systems that help users easily move through the digital product. This includes creating menus, navigation bars, search functionalities, and other elements that aid in exploration and discovery.\n\n__3\\. Taxonomy and Labelling:__ IA employs effective labeling and categorization systems to make information findable and understandable. This involves creating consistent and meaningful labels, defining categories, and developing taxonomies that reflect user mental models.\n\n__4\\. Search Functionality:__ IA considers the implementation of robust search features to enable users to quickly locate specific information within a digital product. This includes designing search interfaces, integrating search algorithms, and optimizing search results.\n\n__5\\. Content Hierarchy:__ IA establishes a clear hierarchy of content, ensuring that important information receives prominence while maintaining a logical flow of information. This hierarchy helps users prioritize their attention and understand the relative importance of different elements.\n\n### The Key Processes And Methods In Information Architecture\n\nBy following the IA processes and methods listed below, information architects can create a well-structured and user-centered information architecture that enhances usability, and overall user experience within a digital product.\n\n__1\\. Research:__ IA begins with thorough research. This involves understanding user needs, business goals, and studying existing content. User research methods like interviews, surveys, and observation help gain insights into user behaviors, preferences, and mental models. Competitor analysis helps identify best practices and learn from existing solutions.\n\n__2\\. Information Organisation:__ Once the research phase is complete, IA professionals delve into organizing the information. They create content hierarchies by determining the relationships and priorities between different content elements. This involves categorizing information, establishing logical structures, and defining taxonomies. The goal is to ensure that users can easily navigate and comprehend the content.\n\n__3\\. Wireframing and Prototyping:__ IA practitioners employ wireframes and prototypes to visually represent the information architecture. Wireframes are skeletal layouts that depict the structure and placement of content elements. Prototypes are interactive representations that allow users to navigate and interact with the proposed IA. These visual representations help validate the effectiveness of the IA design, identify potential issues, and iterate on the structure as needed.\n\n__4\\. Card Sorting:__ Card sorting is a technique used in IA to involve users in the process of organizing information. It involves providing users with physical or virtual cards representing different content elements and asking them to group and categorize them based on their understanding. This exercise helps IA professionals understand users' mental models, preferences, and expectations, guiding the creation of an IA that aligns with user needs.\n\n__5\\. User Flows:__ User flows visually map out the paths and steps that users take to accomplish specific tasks within a digital product. They illustrate the sequence of interactions and decisions a user makes, helping IA professionals identify potential bottlenecks or gaps in the user journey. User flows enable them to optimize the IA by streamlining the navigation and ensuring a seamless user experience.\n![image5-userflows](//images.ctfassets.net/piwi0eufbb2g/3M8xwDjFNyeBKxa94qk6B/206ba558e4ee9da7e27ae35d08445214/image5.jpg)\n*Image is taken from Unsplash.com*\n\n__6\\. Site Maps:__ Site maps are visual representations of the overall structure and hierarchy of a website or app. They provide an overview of the content organization, showcasing the relationships between different pages or sections. Sitemaps aid in understanding the scope of the IA, identifying content gaps or redundancies, and facilitating collaboration between IA professionals and other stakeholders.\n\nTo put IA in perspective, let's take a look at how [Adidas](https://www.adidas.com/us) has made shopping easy on its website.\n\n1.  Clever navigation structure - As large as its catalog, the homepage is divided into several sections, each of which contains information about a different product category or topic. We can see that users will not experience a hard time finding the products of choice.\n![adidas-nav](//images.ctfassets.net/piwi0eufbb2g/4i9LA92vwbGcwXFCfUSyAq/be44229f114e1a793f201dbd8fc62610/adidas-nav.png)\n*[Adidas](https://www.adidas.com/us)' homepage navigation*\n\\.\n\n1.  Search bar - The Adidas website also has a search bar that allows users to search for specific products or information. The search bar is located in the top right corner of the website, and it is easy to find and use.\n![adidas-search](//images.ctfassets.net/piwi0eufbb2g/72hZaXhbuMdA1Yha0mhmkX/d25320f3591e56881daba7722c0fbfd2/adidas-search.png)\n*The search bar on the [Adidas](https://www.adidas.com/us) homepage*\n\nThe Adidas search bar also comes loaded with popup suggestions per category. It makes it easy to find products as it filters the search result according to input.\n![adidas-advanced-search](//images.ctfassets.net/piwi0eufbb2g/2mLuP5HnWjNfSN7U566qI9/4bc132d2f80b9fe5737001def43eb498/adidas-advanced-search.png)\n*[Adidas](https://www.adidas.com/us) advanced search*\n\n### What Tools Do Information Architects Use?\n\nInformation Architects (IAs) use various tools to support their work and streamline the process of designing and implementing effective information architectures. Some of the commonly used tools by IAs are;\n\n__1\\. Diagramming and Wireframing Tools:__ Tools such as Adobe XD, Sketch, Axure RP, FigJam, and Balsamiq allow IAs to create wireframes and visual representations of the information architecture. They help in organizing content, designing navigation systems, and showcasing the structure and layout of digital products.\n\n__2\\. Prototyping Tools:__ Prototyping tools like InVision, Figma, Proto.io, Adobe XD, and Marvel enable IAs to create interactive prototypes that simulate user interactions and flows. These prototypes help test and validate the information architecture, gather user feedback, and refine the design.\n\n__3\\. Card Sorting Tools:__ Online card sorting tools like OptimalSort, Treejack, and UserZoom facilitate remote and online card sorting exercises. These tools enable IAs to collaborate with users, collect data on how users categorize and group information, and gain insights into user mental models.\n\n__4\\. Collaborative Design and Documentation Tools:__ Tools like Miro, Mural, and Google Workspace (formerly G Suite) provide collaborative spaces for IAs to work with cross-functional teams. These tools allow for real-time collaboration, brainstorming, and documentation of the information architecture process.\n\n__5\\. Diagramming and Visualization Tools:__ Tools like Microsoft Visio, Lucidchart, and draw.io assist IAs in creating flowcharts, site maps, and visual representations of the information architecture. These tools help in communicating and presenting the IA design to stakeholders and development teams.\n\n## Understanding UX Design\n\nUX Design is the art of understanding users' desires, dreams, and frustrations and translating them into unforgettable digital encounters. Its purpose? To create digital masterpieces that leave users in awe.\n\n### The Key Elements of UX Design\n\nThese are often referred to as the Five Planes of UX. They work together harmoniously to create a remarkable user experience. They include;\n\n__1\\. Strategy:__ The strategy sets the course for our journey, guiding us toward creating an exceptional user experience. It involves understanding business goals, and target audience, and defining the overall vision for the product. The strategy lays the foundation for our design decisions, ensuring that we're headed in the right direction.\n\n__2\\. Scope:__ Think of scope as setting the boundaries for our design expedition. It helps us determine what features and functionalities will be included in the product. We carefully consider the needs and expectations of our users, balancing them with practical constraints like time, resources, and technical limitations. Defining the scope ensures that we focus on creating a valuable and achievable user experience.\n\n__3\\. Structure:__  This is the sturdy backbone of our design. It's about organizing and arranging information in a logical and user-friendly manner. We create a clear and intuitive navigation system, making it a breeze for users to explore and find what they need. By structuring the content and interactions, we ensure that users can easily navigate through the product, saving them from any frustrating detours.\n\n__4\\. Skeleton:__ This serves as the essential framework of our design, setting the stage for the key elements and interactions. Within this foundation, we determine the arrangement and positioning of buttons and menus, as well as establish the flow of interactions. This framework allows us to visualize the overall structure of the product and anticipate how users will engage with it.\n\n__5\\. Surface:__ This is where we add delightful visual touches to our design. We apply color, typography, imagery, and other visual elements to create an engaging and visually pleasing experience. The surface gives our design its personality, reflecting the brand identity and evoking emotions in our users.\n\n### UX Design Processes And Methods\n\nThese are integral to creating successful and user-centered digital experiences. Let's explore some of the key UX Design processes and methods.\n\n__1\\. Research and Analysis:__ UX Design begins with thorough research and discovery to gain insights into user needs, behaviors, and preferences. This involves conducting user interviews, surveys, and usability testing, as well as analyzing market trends and competitor analysis. The goal is to understand the target audience and their goals to inform the design process.\n\n__2\\. User Persona Development:__ User personas serve as fictional representations of various user types derived from thorough research. UX designers employ personas to add a human touch to the target audience and gain insights into their motivations, needs, and challenges. These personas play a pivotal role in steering design choices, ensuring that the product is customized to cater to specific user groups.\n\n__3\\. User Journey Mapping:__ User journey mapping involves visualizing the end-to-end experience of users as they interact with a product or service. It identifies touchpoints, emotions, and pain points throughout the user's journey. User journey maps provide a holistic view of the user's experience, helping UX designers identify opportunities for improvement and create seamless interactions.\n\n__4\\. Information Architecture:__ Information Architecture (IA) is a critical component of UX Design. It involves organizing and structuring the content and information within a product logically and intuitively. IA ensures that users can easily navigate and find the information they need, enhancing the overall user experience. A part of the deliverables for IA is wireframes and prototypes.\n![image7](//images.ctfassets.net/piwi0eufbb2g/6rBQIieP7vJoKdNJilcmGt/0175df252703f563ba03547d0fc2b609/image7.jpg)\n*Image is taken from Unsplash.com*\n\nWireframing is the process of creating low-fidelity visual representations of the user interface. It focuses on the layout and structure of the design without getting into visual details. Prototyping, on the other hand, involves creating interactive and more high-fidelity representations of the design. Wireframes and prototypes allow designers to test and iterate on the design before development, ensuring usability and user satisfaction.\n\n__5\\. Usability Testing:__ Usability testing involves observing and gathering feedback from users as they interact with a prototype or a live product. This method helps identify usability issues, pain points, and areas for improvement. UX designers conduct usability tests to validate design decisions, make data-driven improvements, and enhance the user experience.\n\n__6\\. Iterative Design:__ UX Design follows an iterative approach, constantly refining and enhancing the design based on user feedback and data. This ongoing improvement process ensures that the design evolves and aligns with user expectations.\n\nLet's take a look at some of [Apple's](https://www.apple.com/) website features that make it a great UX site.\n\n1\\.  The use of white space - Whitespace is the space between elements on a webpage. It is often used to create a sense of space and organization. On Apple's website, whitespace is used effectively to make the website easy to scan and to focus attention on the most important content. This reduces distraction for users, hence a good UX.\n\nWhile this feature almost goes unnoticed, it goes a long way in creating a positive, long-lasting impression for users.\n![apple-whitespace](//images.ctfassets.net/piwi0eufbb2g/1zlbTkCUh7JHyLLuxwfciq/53eab8558e4959fbafffac43f3871a90/apple-whitespace.png)\n*[Apple'](http://apple.com)s watch series page shows the use of whitespace*\n\n2\\.  Use of cool animations - Another important feature of Apple's website design is the use of animated images. We can see in the screenshot below how Apple cleverly showcases its products using subtle yet effective techniques to capture attention. Likewise, users can interact with the animation by clicking on different parts of the screen. This allows users to explore the product in more detail, and it helps them to learn more about its features. This helps to create a positive emotion with the product.\n![apple-interaction](//images.ctfassets.net/piwi0eufbb2g/38yzGAUiFtRomQPnEiXKGr/4eede04660bce7b65a322f05a2a788f8/apple-interaction.gif)\n*[Apple's](http://apple.com) homepage with animated images.*\n\n### Tools Employed By UX Designers\n\nUX designers utilize a variety of tools to aid them in the design process and create exceptional user experiences. Listed are some commonly employed tools by UX designers:\n\n__1\\. Design and Prototyping Tools:__ Tools like Sketch, Adobe XD, Figma, and InVision enable UX designers to create high-fidelity mockups, wireframes, and interactive prototypes. They offer features for designing user interfaces, creating animations, and simulating user interactions, allowing designers to visualize and test their design concepts before implementation.\n\n__2\\. User Research Tools:__ User research tools help UX designers gather valuable insights into user behavior and preferences. Tools such as UserTesting, Optimal Workshop, and UserZoom enable designers to conduct remote usability testing, surveys, card sorting, and other research methods. These tools provide feedback, analytics, and user behavior data that inform design decisions.\n\n__3\\. Collaboration and Communication Tools:__ Collaboration and communication tools facilitate teamwork and streamline communication among UX designers, stakeholders, and developers. Tools like Slack, Microsoft Teams, and Asana enable designers to collaborate on projects, share design files, provide feedback, and manage tasks efficiently. These tools promote effective collaboration and project coordination.\n\n__4\\. Accessibility Testing Tools__: Accessibility testing tools help UX designers ensure that their designs are inclusive and accessible to users with disabilities. Tools like WebAIM, WAVE, and AChecker evaluate web accessibility compliance, identify accessibility issues, and provide recommendations for improvement. These tools assist designers in creating products that adhere to accessibility standards and guidelines.\n\n__5\\. Usability Testing Tools:__ Usability testing tools aid UX designers in evaluating the usability and effectiveness of their designs. Tools like Maze, UserZoom, and Lookback facilitate remote user testing, screen recording, and user feedback collection. These tools help designers observe user interactions, gather qualitative and quantitative data, and refine the design based on user insights.\n\n## Information Architecture vs UX Design: What's the Difference\n\nIt's important to note that  IA can exist separately from UX, however, UX cannot exist without IA. Let's take a look at an overview of the overlapping and complementing areas of Information Architecture and UX Design.\n\n|Factor|Information Architecture (IA)|UX Design|\n|:----|:----|:----|\n|__Focus__|Content structuring and organization for easy finding|Emotions and psychology of the users. Overall user satisfaction and usability|\n|__Key Elements__|Content hierarchy, navigation systems, taxonomy, search functionality|User research, interaction design, visual design, usability testing|\n|__Objectives__|Optimize information findability and comprehension|Create enjoyable and intuitive user experiences|\n|__Key Activities__|Organizing content, creating taxonomies, designing navigation systems|User research, wireframing, prototyping, usability testing|\n|__Deliverables__|Site maps, content hierarchies, labeling systems, metadata, wireframes, prototypes|User personas, experience maps, empathy maps, journey maps|\n|__Scope__|Primarily focuses on information structure and organization|Holistic approach encompassing aesthetics, interactions, and usability|\n|__Timeframe__|Often established in the early stages of the design process|Spanning the entire design process, from research to implementation|\n|__Overlapping Areas__|UX Design incorporates IA principles to create a seamless user experience|IA benefits from UX Design's insights on user needs and interactions|\n\n## Final Thoughts\n\nInformation Architecture (IA) and User Experience Design (UX Design) are two essential disciplines that work hand in hand to create exceptional digital experiences. While IA focuses on organizing and structuring information to optimize findability and comprehension, UX Design takes a broader approach, considering overall user satisfaction and usability.\n\nSo, the next time you're navigating a well-organized website or enjoying a user-friendly app, remember that Information Architecture and UX Design have worked hand in hand to create that delightful experience.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4MvV4MKBVxBwYrrrE2PNlw","type":"Asset","createdAt":"2023-07-10T11:03:28.308Z","updatedAt":"2023-07-10T11:03:28.308Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"ux-versus-ia","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4MvV4MKBVxBwYrrrE2PNlw/f74026d7fd00b73102cdabee82b8bab3/ux-process.png","details":{"size":293363,"image":{"width":445,"height":355}},"fileName":"ux-process.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"4rUnTz3X10yfndHMECQ6kG"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"QUWD2QS7RiuC12nzWW4Ai","type":"Entry","createdAt":"2022-10-07T10:12:11.131Z","updatedAt":"2022-10-07T10:12:11.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"UX Design","slug":"ux-design","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}},{"sys":{"type":"Link","linkType":"Entry","id":"6kbzSOMPOI8eWQV2cJzrHR"}}],"tags":["UX"],"creationDate":"2022-10-06","readTime":"7min","content":"UX design is an essential part of the design or redesign of any product. However, more often than not, UX design principles are confused with the design process. It should be noted that the UX design and the design process are similar but different. UX design is the standard principle for a product design, while the design process is the step-by-step guide a designer takes in designing a product. The design process typically varies based on the designer and the effect the designer is trying to create or redesign. \n\nTherefore, here we will be looking at carrying out a UX design while you design an app based on the principles learned and adequately document your design process. Note that the UX design should be based on the needs of the user and the stakeholder. Simply put, your UX design must solve the users' needs and meet business goals.\n\nAccording to the Stanford school of design the UX design comprises:\n- Product definition\n- Research\n- Analysis\n- Design\n- Validation\n\n### Product definition\nThis is the first phase in the user design process. This is where the design team understands the problem they are trying to solve and the context in which the product is being formed. This is where the \"whys” of the design are discussed. This is where the designer will collect the user needs based on business goals. Any mistakes in understanding the scope will lead to a product in the market that is not required. At this stage, the designer has stakeholder meetings in which he meets with the business manager, the product manager, and the lead developer. It is here we determine what our product is all about, who will use our product, and why they will be using our product. The entire team will have to consult with customers in their environment and analyze what they want within the framework of your operation. At this stage, critical KPIs are set, and success metrics are determined.\n\n### Research\nAfter you have adequately defined those, we move further into carrying out our research. This is very important because it helps save us time, money, and effort early in our design process. We identify pain points, needs, wants, and desires, and knowing our user's wants we can design a solution that will solve their problem. Research also involves competitive analysis where we check out what is already in mind and what we can add or remove that would give us an edge in the market. This aids us in entering the market faster.\nWe also look into the latest trends in UI design and design guidelines during the research process.\n\n### Analysis\nThis is where we combine and analyze the information gathered during research to get what we need from the data. We produce storyboards, user stories, personas, and experience maps, among other things. At this point, the designer shifts their focus from what to why a user needs or wants something. The designer has an initial guess about what the user might need, but they are not sure at this point in the user experience design process.\n\nAfter conducting enough studies and assessing the data obtained from research, we confirm our assumptions at this point.\n- __Fictional Personas:__ Developing fictional scenarios enables the designer to understand the many customers of your product better. It allows a realistic portrayal of the finished product. The design team can determine how it will seem following delivery.\n- __Experience Maps:__ These diagrams depict how users move through your finished product. This is accomplished through visual representation and suitable interactions with the customer.\n- __User story:__ A user story is a tool designers can use to better comprehend how users engage with a product or service. As a [user], I want to [objective to attain] so that [motive], which is the typical definition.\n- __Storyboarding:__ Designers can connect user personas and user stories with the storyboarding method. It's a story about a user interacting with your product, as the name suggests.\n\n### Design\nWhen product designers have a strong understanding of what customers want, need, and expect from a product, they move on to the design phase. Product teams work on various projects at this stage, from creating an Information Architecture (IA) to UI design in practice. A successful design phase is highly collaborative (every team member involved in product design must actively participate in this phase), iterative, and combined (meaning it cycles back upon itself to validate ideas).\n\nTypically, the design phase entails:\n- __Sketching:__ The quickest and most straightforward approach to visualize our ideas is through sketches. This can be accomplished by hand-drawing on paper, on a whiteboard, or with a computer tool. It may let the team see a wide range of design possibilities before determining which one to use, which makes it particularly helpful during brainstorming sessions.\n- __Wireframing:__ A wireframe is a tool designers may use to see the essential components of a future page and how they will work together. Wireframing is the product's backbone, and designers frequently utilize it as a foundation for mockups and prototypes.\n- __Prototyping:__ While wireframes are primarily concerned with structure and visual hierarchy (the look), prototypes are concerned with the actual interaction experience (the look and feel). A prototype resembles a simulation of the finished product and ranges from low-fidelity (clickable wireframes) to high-fidelity (coded prototypes) depending on the specific screens.\n- __Design specifications:__ They include user flow and task flow diagrams. It shows how the UI/UX product will generally function and its stylistic needs. It explains the procedures and visual components needed to produce fantastic user experiences.\n- __The development of design systems:__ Designers frequently construct a system of components, patterns, and styles for significant projects to enable designers and developers to stay on the same page with the design.\n\n### Validation or Testing\nTesting is the stage that establishes the final product's overall quality. When something has to be fixed, the testers make notes and submit them back to the appropriate team so they can fix the mistakes. Although some businesses conduct internal tests, doing so is not recommended because it is likely that these individuals have a basic understanding of how these apps operate and are prejudiced in favor of the product. \n\nThe validation process typically begins after the high-fidelity design is completed because testing with high-fidelity methods yields more insightful feedback from end-users. It is, however, also advisable to carry out tests also on your low-fi design; this helps in knowing that your user can carry out given actions with the barest minimum. During several user testing sessions, the team validates the product with stakeholders and end-users. \n\nThe following activities may be included in the validation phase of the UX process: \n- __Testing sessions:__ User testing sessions with participants who correspond to your target market are crucial. There are numerous forms to experiment with, such as moderated/unmoderated usability testing, focus groups, beta testing, and A/B testing.\n- __Surveys:__ Surveys are a fantastic tool for gathering quantitative and qualitative data from actual people. Open-ended questions, such as \"What portion of the product do you dislike?\" might be added by UX designers to elicit user feedback on specific features. \n- __Analytics:__ Quantitative data (clicks, navigation time, search queries, and so on) from an analytics tool can be helpful in determining how users engage with your product.\n\nThere are a few things to consider while assessing your finished project. Some are:\n- Is the system simple to use? \n- Is it adaptable and straightforward to use? \n- Does it resolve the client's problem? \n- Does it have credibility and entice customers to return when they require your service?\n\nIt should be noted that the UX design process is an iterative process where the designer performs back and forth movement based on findings from user testing sessions and meetings with stakeholders and our developers. \n\n### Conclusion\nOne must adopt a systematic approach to create excellent UX/UI interfaces. To do this, we need a UI/UX design process technique. The entire design team will participate in the process. In this increasingly competitive world, this is one of the most acceptable methods to maintain present clients and attract new ones.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"KLiU6Wijp0SYkFb5R8l8O"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}},{"sys":{"type":"Link","linkType":"Entry","id":"2uvUxTj7xgbHN7m06Ekpmo"}},{"sys":{"type":"Link","linkType":"Entry","id":"6caWgGv16CdBLAnAELHGjH"}}],"openExternalLinksInNewTab":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4MypFsmISeX3lVf8orurw4"}},{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"QUWD2QS7RiuC12nzWW4Ai","type":"Entry","createdAt":"2022-10-07T10:12:11.131Z","updatedAt":"2022-10-07T10:12:11.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"UX Design","slug":"ux-design","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}},{"sys":{"type":"Link","linkType":"Entry","id":"6kbzSOMPOI8eWQV2cJzrHR"}}],"tags":["UX"],"creationDate":"2022-10-06","readTime":"7min","content":"UX design is an essential part of the design or redesign of any product. However, more often than not, UX design principles are confused with the design process. It should be noted that the UX design and the design process are similar but different. UX design is the standard principle for a product design, while the design process is the step-by-step guide a designer takes in designing a product. The design process typically varies based on the designer and the effect the designer is trying to create or redesign. \n\nTherefore, here we will be looking at carrying out a UX design while you design an app based on the principles learned and adequately document your design process. Note that the UX design should be based on the needs of the user and the stakeholder. Simply put, your UX design must solve the users' needs and meet business goals.\n\nAccording to the Stanford school of design the UX design comprises:\n- Product definition\n- Research\n- Analysis\n- Design\n- Validation\n\n### Product definition\nThis is the first phase in the user design process. This is where the design team understands the problem they are trying to solve and the context in which the product is being formed. This is where the \"whys” of the design are discussed. This is where the designer will collect the user needs based on business goals. Any mistakes in understanding the scope will lead to a product in the market that is not required. At this stage, the designer has stakeholder meetings in which he meets with the business manager, the product manager, and the lead developer. It is here we determine what our product is all about, who will use our product, and why they will be using our product. The entire team will have to consult with customers in their environment and analyze what they want within the framework of your operation. At this stage, critical KPIs are set, and success metrics are determined.\n\n### Research\nAfter you have adequately defined those, we move further into carrying out our research. This is very important because it helps save us time, money, and effort early in our design process. We identify pain points, needs, wants, and desires, and knowing our user's wants we can design a solution that will solve their problem. Research also involves competitive analysis where we check out what is already in mind and what we can add or remove that would give us an edge in the market. This aids us in entering the market faster.\nWe also look into the latest trends in UI design and design guidelines during the research process.\n\n### Analysis\nThis is where we combine and analyze the information gathered during research to get what we need from the data. We produce storyboards, user stories, personas, and experience maps, among other things. At this point, the designer shifts their focus from what to why a user needs or wants something. The designer has an initial guess about what the user might need, but they are not sure at this point in the user experience design process.\n\nAfter conducting enough studies and assessing the data obtained from research, we confirm our assumptions at this point.\n- __Fictional Personas:__ Developing fictional scenarios enables the designer to understand the many customers of your product better. It allows a realistic portrayal of the finished product. The design team can determine how it will seem following delivery.\n- __Experience Maps:__ These diagrams depict how users move through your finished product. This is accomplished through visual representation and suitable interactions with the customer.\n- __User story:__ A user story is a tool designers can use to better comprehend how users engage with a product or service. As a [user], I want to [objective to attain] so that [motive], which is the typical definition.\n- __Storyboarding:__ Designers can connect user personas and user stories with the storyboarding method. It's a story about a user interacting with your product, as the name suggests.\n\n### Design\nWhen product designers have a strong understanding of what customers want, need, and expect from a product, they move on to the design phase. Product teams work on various projects at this stage, from creating an Information Architecture (IA) to UI design in practice. A successful design phase is highly collaborative (every team member involved in product design must actively participate in this phase), iterative, and combined (meaning it cycles back upon itself to validate ideas).\n\nTypically, the design phase entails:\n- __Sketching:__ The quickest and most straightforward approach to visualize our ideas is through sketches. This can be accomplished by hand-drawing on paper, on a whiteboard, or with a computer tool. It may let the team see a wide range of design possibilities before determining which one to use, which makes it particularly helpful during brainstorming sessions.\n- __Wireframing:__ A wireframe is a tool designers may use to see the essential components of a future page and how they will work together. Wireframing is the product's backbone, and designers frequently utilize it as a foundation for mockups and prototypes.\n- __Prototyping:__ While wireframes are primarily concerned with structure and visual hierarchy (the look), prototypes are concerned with the actual interaction experience (the look and feel). A prototype resembles a simulation of the finished product and ranges from low-fidelity (clickable wireframes) to high-fidelity (coded prototypes) depending on the specific screens.\n- __Design specifications:__ They include user flow and task flow diagrams. It shows how the UI/UX product will generally function and its stylistic needs. It explains the procedures and visual components needed to produce fantastic user experiences.\n- __The development of design systems:__ Designers frequently construct a system of components, patterns, and styles for significant projects to enable designers and developers to stay on the same page with the design.\n\n### Validation or Testing\nTesting is the stage that establishes the final product's overall quality. When something has to be fixed, the testers make notes and submit them back to the appropriate team so they can fix the mistakes. Although some businesses conduct internal tests, doing so is not recommended because it is likely that these individuals have a basic understanding of how these apps operate and are prejudiced in favor of the product. \n\nThe validation process typically begins after the high-fidelity design is completed because testing with high-fidelity methods yields more insightful feedback from end-users. It is, however, also advisable to carry out tests also on your low-fi design; this helps in knowing that your user can carry out given actions with the barest minimum. During several user testing sessions, the team validates the product with stakeholders and end-users. \n\nThe following activities may be included in the validation phase of the UX process: \n- __Testing sessions:__ User testing sessions with participants who correspond to your target market are crucial. There are numerous forms to experiment with, such as moderated/unmoderated usability testing, focus groups, beta testing, and A/B testing.\n- __Surveys:__ Surveys are a fantastic tool for gathering quantitative and qualitative data from actual people. Open-ended questions, such as \"What portion of the product do you dislike?\" might be added by UX designers to elicit user feedback on specific features. \n- __Analytics:__ Quantitative data (clicks, navigation time, search queries, and so on) from an analytics tool can be helpful in determining how users engage with your product.\n\nThere are a few things to consider while assessing your finished project. Some are:\n- Is the system simple to use? \n- Is it adaptable and straightforward to use? \n- Does it resolve the client's problem? \n- Does it have credibility and entice customers to return when they require your service?\n\nIt should be noted that the UX design process is an iterative process where the designer performs back and forth movement based on findings from user testing sessions and meetings with stakeholders and our developers. \n\n### Conclusion\nOne must adopt a systematic approach to create excellent UX/UI interfaces. To do this, we need a UI/UX design process technique. The entire design team will participate in the process. In this increasingly competitive world, this is one of the most acceptable methods to maintain present clients and attract new ones.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"KLiU6Wijp0SYkFb5R8l8O"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}},{"sys":{"type":"Link","linkType":"Entry","id":"2uvUxTj7xgbHN7m06Ekpmo"}},{"sys":{"type":"Link","linkType":"Entry","id":"6caWgGv16CdBLAnAELHGjH"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6raiETCgPADnd17sRSKJSG","type":"Entry","createdAt":"2022-08-09T07:53:49.899Z","updatedAt":"2022-08-25T06:03:49.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","slug":"what-skills-do-you-need-to-be-a-graphic-designer-2","type":"Article","trackCategory":["Design"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5W8yVIchiseIGTWrWKXN57","type":"Entry","createdAt":"2019-09-18T07:36:54.570Z","updatedAt":"2023-09-06T19:01:10.075Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Design"}}],"tags":["Learn","Graphic Design"],"creationDate":"2022-08-08","readTime":"8min","content":"Graphic designers use visuals to communicate and make visual notions by hand or with computer tools. Through both real and virtual art forms, they can provide suggestions for inspiring, motivating, or enhancing consumers. Professionals in graphic design work on various projects, including brochures, print ads, and logos.\n\n### Evolution of Graphic Design\n\nIt isn't easy to envision life in the present era without graphic design because society encompasses so many aspects of it. Though it has been a long trip from stone tools to digital tablets, visual communication is roughly as old as our opposable thumbs, so in some respects, we never have lived without graphic design. In summary, the history of graphic design is a narrative that spans all of human history and can both inform and inspire contemporary graphic artists.\nGraphic design has evolved starting with cave paintings, then the origin of the printing press, the pre-digital era, and now the digital age. Graphic design has come a long way. As it evolves over time the skill sets are also changing.\n\n### Skill Set of Graphic Designers\n\nIn today's fast, ever-changing world, graphic designers need technical and soft skills. Your industry-specific professional knowledge and competencies are the foundation for your technical skills. Technological requirements are constantly changing; your current technical abilities might not be enough for the work you'll be requested to complete tomorrow. That's where soft skills come into play. Teamwork, effective communication, problem-solving, leadership, decisiveness, time management, and flexibility are examples of soft skills that are highly valued.\n\nLet's look more deeply into the technical and soft skills that graphic designers need in today's world.\n\n### Technical Skills\nEmployers seek out adaptable graphic designers with the necessary technical know-how to start immediately. Some of the most sought-after technical abilities for a graphic designer are the following:\n\n#### Typography skills\nThe visual representation of words and phrases is known as typography. The actual job of a graphic designer is to arrange words and letters in a visually appealing way. Typography skills work to combine the principles of visual design, font, lettering, color, and several other aspects of print writing to create banners, billboards, signs, magazine articles, website content, letters and letterheads, and many other print and writing applications\n\n#### Font selection\nThe graphic designer must be able to select the right font for each project. You must be able to choose the right font for each project, considering font style, size, and weight. All affect how your designs seem and may change how readers interpret your content.\n\n#### Design principles\nKnowing the design principles is a must-have trait for a graphic designer. Successful graphic designers understand how to balance designs using white space, color, hierarchy, and other design elements. For instance, during each project, a graphic designer must be able to select the appropriate color scheme. In contrast to RGB, which is frequently used for digital designs, CMYK is best for print projects.\n\nAlong with design principles, standards used to decide how a brand will be presented to audience members are called branding guidelines. You must be able to adhere to these rules strictly if you want to excel in the field.\n\n#### UX design\nUX design is the bridge between design and the front-end development team. The user interface, or UI, is a term that is generally understood. The screen that a person interacts with, such as while using a website or app, is most frequently the user interface. UX refers to the overall experiences a customer gets when utilizing a product or service, including UI. Graphic designers with UX experience know how to produce straightforward layouts that are practical and adhere to recognized accessibility standards.\n\n#### Digital technology (HTML, CSS, JS)\nThis skill is not required but is an optional one. Knowledge of HTML, CSS, and JavaScript is included in this. You should be familiar with well-known JavaScript libraries like React. Testing, debugging, build tools, and dependency managers may also be included.\n\nIt is significant to highlight that the position necessitates in-depth CSS knowledge. This might include using preprocessors like Sass and Less or the CSS architecture. Experience with CSS-in-JS libraries like Styled Components and Emotion is advantageous.\nThese skills will definitely help you if you plan to design websites or work as a graphic designer.\n\n#### Photography skills/photo editing\nIt's crucial to know how to edit stock pictures or take excellent photos because you might need to include photos in your graphic design work.\n\n### Soft Skills\n\nNo matter how strong your technical abilities, if you lack the soft qualities that companies value, it will be difficult for you to thrive in the design industry. Soft skills are character attributes that, as previously mentioned, can help you thrive in any industry. You can collaborate with others, communicate clearly, and establish a good rapport with clients and coworkers if you possess these qualities. The following soft skills are necessary for graphic designers.\n\n#### Collaboration skills\nWorking with people to achieve a shared objective is simple when one possesses strong collaboration abilities. A good collaborator pays attention to others, communicates well, and accepts responsibility for their errors.\n\n#### Emotional intelligence\nIndividuals with high emotional intelligence are masters at controlling their feelings, which enables them to solve problems and relieve stress from their team members.\n\n#### Communication skills\nEffective communication with coworkers, clients, and other stakeholders is essential. Graphic designers with good communication skills who can articulate their ideas concisely and consistently are always in demand by potential employers.\n\n#### Time management\nSince deadlines are a big part of graphic design, time management skills are necessary.\n\n#### Creativity \nThe potential to come up with fresh notions and apply them to problems or interpersonal communication is referred to as creativity. Successful graphic designers have a strong sense of creativity and originality.\n\n#### Storytelling\nStorytelling is a terrific approach to learn what your audience needs and how your organization may meet those needs if you're attempting to appeal to a particular demographic. The ability to tell a story is extremely useful for graphic designers tasked with creating enduring brand identities.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1i786NVOB6KrgH8WIjNA5o","type":"Asset","createdAt":"2022-08-08T17:15:51.156Z","updatedAt":"2022-08-08T17:15:51.156Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1i786NVOB6KrgH8WIjNA5o/f4c8f049da0a86b350b2d0871784b97b/What_Skills_do_you_Need_to_be_a_Graphic_Designer","details":{"size":79753,"image":{"width":640,"height":640}},"fileName":"What Skills do you Need to be a Graphic Designer?.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"12QIad2hrziFxOyUtzHw3V"}},{"sys":{"type":"Link","linkType":"Entry","id":"5QU9Tsl9cEHOJC50UvGdIl"}},{"sys":{"type":"Link","linkType":"Entry","id":"6TVx3UYkm6bWDe223mn0XP"}}],"openExternalLinksInNewTab":true}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1fINVUJiGA2nwaeRASuMfq","type":"Entry","createdAt":"2021-11-05T10:44:34.241Z","updatedAt":"2023-09-06T14:46:54.663Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":46,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Merlion Library for AutoML Forecasting Using Python","slug":"merlion-library-for-automl-forecasting-using-python","type":"Article","trackCategory":["Data Science"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"55HiOMbEVXarc2fnfuAOuN","type":"Entry","createdAt":"2019-09-18T07:37:47.286Z","updatedAt":"2019-09-18T07:37:47.286Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Machine Learning Tools & Libraries","trackParent":"Data Science"}}],"tags":["Python"],"creationDate":"2021-11-05","readTime":"15min","content":"### Introduction:\n\nThere are a large number of Python AutoML libraries for fasting and simplifying machine learning tasks, such as H20, Pycaret Automl, and more. Here we are going to discuss salesforce Merlion library which has more features than some other libraries.\n\n1.  It supports univariate and multivariate time series forecasting.\n\n2.  It automatically detects outliers and anomalies.\n\n3.  It supports hyperparameter tuning.\n\n4.  It has inbuilt ensemble techniques.\n\n5.  It has an automatic visualization part.\n\nThis library’s main aim is to provide fast and accurate machine learning models for their specific time series problem.\n\nThere are several modules to boost ease-of-use, including visualization, anomaly score calibration to boost interpretability, AutoML for hyperparameter tuning and model selection, and model ensembling.\n\n![image](//images.contentful.com/piwi0eufbb2g/6A6zhuVdnEMyW16a079JK9/53a49359fd5e9ffc68238421e158fe02/image.png)\n\n### Installation:\n\nMerlion has two main sub-libraries on its ts\\_datasets for loading time series datasets and machine learning processes like data processing, data visualization, anomaly detection, hyperparameter tuning, data forecasting, etc..\n\nThis library loads data in the form of pandas.DataFrame.\n\nYou can simply install the library by calling Pypi features in your command prompt or anaconda prompt - pip install salesforce-merlion. You can also install by visiting the official Github page of salesforce-merlion at this [Link](https://github.com/salesforce/Merlion). \n\nThen move on to the next part, which is installing external dependencies of this library. You can see this simply below.\n\n![image](//images.contentful.com/piwi0eufbb2g/Nc4ElPeYZXpLiAkdHLEpm/55db43690bf2f3c5f9e863b50982390b/image.png)\n\n1.  As we are working on ensemble modeling in this library, we also need to install the lightgbm using a simple pip install lightgbm.\n\n2.  Now we are working on anomaly detection so we also need to install the Java development kit, jdk using pip install openjdk.\n\n### Getting started:\n\nHere we see some practical implementation of Merlion’s library using a time series dataset of Merlion’s inbuilt dataset importing library.\n\n#### 1. Anomaly Detection:\n\nBegin by importing Merlion’s time series data using the data loader method. Anomalies mean outliers. Outliers are those data points which do not lie properly in our data distribution.\n\n```python\nfrom merlion.utils import TimeSeries\nfrom ts_datasets.anomaly import NAB\ntime_series, metadata = NAB(subset=\"realKnownCause\")[3]\ntrain_data = TimeSeries.from_pd(time_series[metadata.trainval])\ntest_data=TimeSeries.from_pd(time_series[~metadata.trainval])\ntest_labels=TimeSeries.from_pd(metadata.anomaly[~metadata.trainval])\n```\n\nNow before doing anomaly detection, we initialize our data model parameters then insert data into it.\n\n```python\nfrom merlion.models.defaults import DefaultDetectorConfig, DefaultDetector\nmodel = DefaultDetector(DefaultDetectorConfig())\nmodel.train(train_data=train_data)\ntest_pred = model.get_anomaly_label(time_series=test_data)\n```\n\nWe call the Merlion library visualization function. Using it we can see various parameters of our data objectively like stationarity, seasonality, trends, outliers, cyclicity, etc..\n\n```python\nfrom merlion.plot import plot_anoms\nimport matplotlib.pyplot as plt\nfig, ax = model.plot_anomaly(time_series=test_data)\nplot_anoms(ax=ax, anomaly_labels=test_labels)\nplt.show()\n```\n\n![image](//images.contentful.com/piwi0eufbb2g/5cJ7Fjk3UzHzRggFr11Oqq/671fd15666e75f357514db55558baf7b/image.png)\n\n### Evaluating Model:\nMerlion also has a model evaluation function in it where we can get the accuracy score, precision and recall, and more results of our model performance.\n\n```python\nfrom merlion.evaluate.anomaly import TSADMetric\np = TSADMetric.Precision.value(ground_truth=test_labels, predict=test_pred)\nr = TSADMetric.Recall.value(ground_truth=test_labels, predict=test_pred)\nf1 = TSADMetric.F1.value(ground_truth=test_labels, predict=test_pred)\nmttd = TSADMetric.MeanTimeToDetect.value(ground_truth=test_labels, predict=test_pred)\nprint(f\"Precision: {p:.4f}, Recall: {r:.4f}, F1: {f1:.4f}\\n\"\n      f\"Mean Time To Detect: {mttd}\")\n```\n\n### Forecasting:\nThis is the final and most important function of our Merlion library. We can forecast future data values on the basis of a date index. In this model we will initialize all the parameters of our library functions. \n\n```python\nfrom merlion.utils import TimeSeries\nfrom ts_datasets.forecast import M4\n\n# Data loader returns pandas DataFrames, which we convert to Merlion TimeSeries\ntime_series, metadata = M4(subset=\"Hourly\")[0]\ntrain_data = TimeSeries.from_pd(time_series[metadata.trainval])\ntest_data = TimeSeries.from_pd(time_series[~metadata.trainval])\nfrom merlion.models.defaults import DefaultForecasterConfig, DefaultForecaster\nmodel = DefaultForecaster(DefaultForecasterConfig())\nmodel.train(train_data=train_data)\ntest_pred, test_err = model.forecast(time_stamps=test_data.time_stamps)\n```\n\nAfter building the model we will visualize our complete prediction model.\n\n```python\nimport matplotlib.pyplot as plt\nfig, ax = model.plot_forecast(time_series=test_data, plot_forecast_uncertainty=True)\nplt.show()\n```\n\n![image](//images.contentful.com/piwi0eufbb2g/1NjlrH0CJB14BQT1Kr9dUv/15cfc69749ba81ee4f55e4516b667921/image.png)\n\nBelow is a summary of the above steps that we used for model forecasting.\n\n1.  Initialize a forecasting model (including ensembles and automatic model selectors) \n\n2.  Train the model\n\n3.  Produce a forecast with the model Visualizing \n\n4.  View the model’s predictions \n\n5.  Quantitatively evaluate the model \n\n6.  Save and load a trained model \n\n7.  Simulate the live deployment of a model","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7nzds1n2pv6LnYvwPgOO5V","type":"Asset","createdAt":"2021-11-05T10:38:00.136Z","updatedAt":"2023-09-06T14:45:27.235Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Merlion","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7nzds1n2pv6LnYvwPgOO5V/b365b1e6360ba6b21ac0aefe3a76ff14/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"phRCEOBFWzgGECLgjgpy6"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3EkFoVBEiQkBrkaWBgtOgT"}},{"sys":{"type":"Link","linkType":"Entry","id":"5Hf36i5Tn2gtfg0IjPeS0W"}},{"sys":{"type":"Link","linkType":"Entry","id":"3djlLWefn7rdC6Pqjhdclx"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5YddmJoyCue4bAErVt8M75","type":"Entry","createdAt":"2023-07-10T19:23:18.193Z","updatedAt":"2023-08-28T07:34:36.537Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":61,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Quality Assurance vs. Quality Control: A Guide to the Differences","slug":"quality-assurance-vs-quality-control-a-guide-to-the-differences","type":"Article","trackCategory":["QA"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"18iyI2bjOA7TozUFV8DFoB"}}],"tags":["Quality assurance","quality control","differences","benefits","implementation","high-quality product"],"creationDate":"2023-07-10","readTime":"10 min","content":"**Level up your game and leave no room for errors!**\n\nQuality refers to the degree a product meets or exceeds the expectations, requirements, and standards set by customers or stakeholders. A high-quality product is free from defects, satisfies user needs, and delivers a positive and satisfying user experience.\n\nWhen it comes to delivering top-notch products and services, understanding the dynamic duo of quality assurance (QA) and quality control (QC) is your ticket to success. Have a look at a brief breakdown of QA and QC.\n\n> QA and QC: A Partnership for Quality\n\n**Quality Assurance (QA):** The guardian angel of flawlessness, it swoops in to prevent defects from even thinking about spoiling your masterpiece. It accomplishes this by establishing and implementing processes that proactively prevent defects, including risk assessments, developing and implementing quality standards, employee training on quality procedures, and conducting audits.\n\n**Quality Control (QC):** The fearless warrior that hunts down and eradicates those quality issues that dare to slip through the cracks. QC is achievable through testing products, inspection of processes, and implementation of corrective actions as needed.\n\nGet ready to unlock the secrets of QA and QC and unleash the power of uncompromising quality. It's time to take control and assurance to a whole new level!\n\nWithin this article, we will explore the distinctions between QA and QC, delve into their implementation within your organization, and uncover the advantages that each brings.\n\n### **What is Quality Assurance?**\n\nIt is a proactive approach to ensuring quality. It aims to prevent defects from occurring in the first place. It focuses on identifying flaws in the development process, such as inefficient practices, inadequate documentation, or insufficient training.\n\nQA activities include planning project implementation, documenting processes, training staff, creating schedules, inspecting checklists, and conducting audits.\n\nThe primary goal of QA is to identify and address flaws in the software development process, aiming for a **\"Zero Defect Approach.\"**\n\n### **What is Quality Control?**\n\nIt is a reactive approach to ensuring quality. QC focuses on the identification and correction of defects that have already arisen.\n\nThe activities typically occur during the testing phase involve inspections, testing, debugging, and Validation.\n\nThe primary goal of QC is to detect defects in the final software product and address them before release, ensuring that the product meets the specified requirements and the product quality is high.\n\n### **The Relationship between QA and QC**\n\n|Features|QA|QC|\n|:----|:----|:----|\n|__Focus__|Preventing defects from occurring|Identifying and correcting defects  |\n|__Timing__|Pre-production|Post-production  |\n|__Responsibility__|The whole team is involved during the SDLC  |The testing team is involved in the STLC|\n|__Approach__|Proactive and process-oriented  |Reactive and product-oriented  |\n|__Activities__|Process checklists, standards, documentation, and project audits|Deliverable peer reviews, inspection, and the process of software testing|\n|__Outcome__|Verification - you are doing the right thing in the right manner|Validation - the product against the requirements|\n\nQA and QC are two important aspects of software development. QA focuses on preventing the problem from occurring. Whereas QC mainly focuses on finding and fixing errors after they have occurred. QA and QC are complementary; working together can help ensure high-quality software products.\n\nQA activities are typically carried out during the pre-production stage of the software development lifecycle (SDLC). In contrast, QC activities are often carried out by the testing team in the post-production stage of the software testing life cycle (STLC).\n\n### **How to Implement QA and QC**\n\n#### Quality Assurance (QA)\n\nThe goal of QA is to ensure that software products meet customer expectations. QA is achievable by following several steps, including:\n\n1. **Identify and mitigate potential problems:** Conduct a thorough analysis of potential risks and challenges that could affect the quality of the software product. Thus, develop strategies and action plans that could resolve these risks.\n\n2. **Define and implement quality standards:** Establish clear quality standards and guidelines that outline the desired level of quality for the software product. These standards should cover various aspects such as functionality, performance, security, and user experience.\n\n3. **Train employees on quality procedures:** Provide training and education to employees involved in the software development process. Ensure they understand and follow the established quality procedures, including best practices, coding standards, and testing methodologies.\n\n4. **Conduct regular audits:** Perform regular audits to assess compliance with quality standards and procedures. This entails reviewing the documentation, processes, and artifacts to identify areas needed for improvement and ensure the standards are being followed.\n\n5. **Promote a culture of quality:** Foster a quality culture within the organization by promoting collaboration, communication, and accountability. Encourage continuous improvement and empower team members to take collective ownership of the quality of their work.\n\n> Suppose you are developing a web application. You conduct a risk assessment and identify potential security vulnerabilities as part of QA. You then implement secure coding practices, perform regular security audits, and train the development team on secure coding techniques. Additionally, you establish quality standards for performance and user experience, ensuring the application meets specified requirements.\n\n#### Quality Control (QC)\n\nQC aims to identify and correct defects that have already occurred in the software product. QC is achievable by following several steps, including:\n\n1. **Testing the product:** Develop and execute a comprehensive testing strategy that includes functional testing, performance testing, security testing, and other relevant types of testing. Use appropriate tools and techniques to identify defects and ensure the software meets specified requirements.\n\n2. **Inspect the production process:** Perform inspections and reviews of the software development process to identify potential problems or deviations from established quality standards. It can involve code reviews, design reviews, and documentation reviews.\n\n3. **Take corrective action:** When defects are identified, take immediate disciplinary action to address them. It may involve debugging, fixing code, retesting, and ensuring the necessary modifications are made to meet the desired quality standards.\n\n4. **Monitor and measure quality metrics:** Establish and track quality metrics to measure the effectiveness of the QC process. This includes defect density, test coverage, and customer satisfaction metrics. Use these metrics to identify trends, make data-driven decisions, and drive continuous improvement.\n\n> During the QC phase, you conduct various types of testing, such as functional testing to check that all features operate as intended and performance testing to ensure the application functions appropriately under expected loads. You also examine the development process to look for deviations from the defined standards for quality. If any flaws are discovered, you immediately take corrective action to fix them and ensure the finished product is of the desired level of quality.\n\n### **The KEY Benefits of QA and QC**\n\n#### Benefits of QA :\n\n1. **Early bug identification and fixing:** QA helps identify and fix bugs at the beginning of the software development lifecycle (SDLC). It can save time and money, preventing the need to fix bugs later in the development process when they can be more difficult and expensive.\n\n2. **Reduced costs:** QA can help to reduce the overall cost of software development by preventing defects from occurring in the first place. It can be done by identifying and mitigating potential problems, developing and implementing quality standards, training employees on quality procedures, and conducting audits.\n\n3. **Compliance with regulations:** QA may assist organizations in complying with rules, laws, and industry standards. It can help the organization avoid costly fines and penalties while enhancing its reputation.\n\n4. **Improved process controls:** QA can help to improve the development process by identifying areas for optimization, efficiency gains, and quality enhancements. This can lead to shorter development cycles, higher-quality products, and increased customer satisfaction.\n\n5. **Easier and smoother QC:** By identifying and fixing bugs early in the SDLC, QA can make the work of the QC team easier and smoother. This is because the QC team will have fewer bugs to fix, and they will be able to focus on more high-level quality assurance activities.\n\n#### Benefits of QC :\n\n1. **Defect detection and correction:** QC focuses on identifying defects in the software product through testing, inspections, and reviews. It enables organizations to catch and address issues before the product is delivered to customers, improving overall product quality.\n\n2. **Continuous improvement:** QC activities provide valuable feedback and insights into the development process. By analyzing defects and gathering metrics, organizations can identify areas for improvement, refine development practices, and enhance future product iterations.\n\n3. **Improved customer satisfaction:** Defect-free software products significantly enhance customer satisfaction. When customers receive software that functions flawlessly, meets their requirements, and is free from bugs and errors, they are more likely to be satisfied with their purchase. Positive user experiences lead to greater customer loyalty and positive word-of-mouth recommendations.\n\n### Wrap Up\n\nThe article gave you a clear understanding of quality assurance and control concepts. Understanding distinctions between quality assurance and control will enable you to address the client's specific requirements and deliver high-quality software products that meet their expectations. Embracing quality assurance and quality control practices will help you establish a robust quality management framework and contribute to project success.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"239h0OBv0NnoVKO2FqTyQt","type":"Asset","createdAt":"2023-07-10T18:40:42.469Z","updatedAt":"2023-07-10T18:40:42.469Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"turned on black and grey laptop computer","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/239h0OBv0NnoVKO2FqTyQt/6783896940660baa8e235ecf68fd6d5f/photo-1504868584819-f8e8b4b6d7e3.avif","details":{"size":55904,"image":{"width":1476,"height":978}},"fileName":"photo-1504868584819-f8e8b4b6d7e3.avif","contentType":"image/avif"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6kIxt3XnHszjSpDpmJ0bqK","type":"Entry","createdAt":"2022-08-19T09:20:43.142Z","updatedAt":"2022-08-19T09:20:43.142Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Maryam Siddiqui","tcHandle":"maryamsidd"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"75xG9R2pApVSPLlIHk5y06"}},{"sys":{"type":"Link","linkType":"Entry","id":"36aTd2yYZO0xU30JtvkU5Q"}},{"sys":{"type":"Link","linkType":"Entry","id":"3Zq3Rp3z6PJd9vnUfPRl4f"}}],"openExternalLinksInNewTab":true}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2e0QaZujxZU5qUghAg6w0g","type":"Entry","createdAt":"2020-09-14T10:39:37.512Z","updatedAt":"2024-07-23T22:45:55.699Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":566,"revision":55,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Support FAQ","slug":"support-faq","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1bK2HNQwLuojOTW8pVbUhv","type":"Entry","createdAt":"2020-06-12T18:32:11.783Z","updatedAt":"2020-06-12T18:32:11.783Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Support","trackParent":"Topcoder"}}],"tags":["Support"],"creationDate":"2020-08-20","readTime":"10 min read","content":"### __Payment Related FAQ__\n__1. How do I withdraw my payments ?__\n   a. Please ensure you are logged in.\n   b. Navigate to [payments page](https://community.topcoder.com/PactsMemberServlet?module=PaymentHistory&full_list=false \"Payments Page\") and select the payments to withdraw.\n\n__2. I am unable to withdraw payments.__\n    a. Please check you have submitted applicable [tax form](https://www.topcoder.com/thrive/articles/payment-policies-and-instructions \"Tax form\").\n    b. Please ensure you have requested to setup your [payment method](https://www.topcoder.com/thrive/articles/Payment%20Methods \"Payment Method\").\n    c. The Release date of your payment has arrived.\n\n__3. Can I setup more than 1 payment method ?__\n The system supports only 1 active payment method at a time. Payments are always processed using the current active method. \n\n__4. I wish to change my payment method ?__\nIf you wish to change your active payment method, please setup your new [payment method](https://www.topcoder.com/thrive/articles/Payment%20Methods \"Payment Method\"). Please raise a support request for changing your current active method. \n\n__5. How do I know, whats my current payment method ?__\nPayment method is not displayed due to security reasons. Please save a copy of your email correspodence (that you have sent to support) for setting up payment method.\n\n__6. Does Topcoder recommend a payment method based on location ?__\nNo. The charges for each method may vary based on location. Please check with your payment provider support to know the exact fees & charges involved.\n\n__7. What is payment release date ?__\n   All payments are subject to [15 day hold](https://www.topcoder.com/thrive/articles/payment-policies-and-instructions). Payments can be withdrawn after the release date.\n\n__8. I see the release date is set to 30 days instead of 15 ?__\n   By default, payments are created with 30 day release window due to legacy reasons.They are auto set to release in 15 days in 2 business days.  \n\n__9. Is the payment auto transferred to my payment provider on release date ?__\n   No.Payments need to be explicitly withdrawn. \n\n__10. When are the weekly gig payments processed ?__\nWeekly gig payments are processed on every Tuesday (EST Time) for previous week. The payments will be usually be visible in PACTS in same day or the next day. If Tuesday falls on a public holiday, the payments will be processed on next business day.\n\n__11. How long it takes for the payments to reach the payment provider ?__\nIn case of Payoneer and Paypal, the transfer is made instantly after clicking the \"Pay Me\" button. However, it can take around 1 business day for the payment to appear in payment provide portal.\nWestern Union payments are [processed twice a month](https://www.topcoder.com/thrive/articles/Payment%20Methods \"Payment Method\"). The selected payments will be marked as \"Entered into payment system\" and will be processed in the next cycle. Western Union payments can take upto 3 business days to appear in user account, after processing.\n\n__12. What is the meaning of various payment statuses ?__\n   Please check the [help article](https://www.topcoder.com/thrive/articles/Payment%20Tracking \"Payment Tracking\") \n\n__13. I am from Wipro, how do I release my payments ?__\n   Wipro payments are auto processed by payroll. There is no requirement to submit any paperwork at Topcoder. All Wipro payments are initially created as \"On Hold\" status. The status is auto updated to \"Entered into Payment system\" into 2 business days.\n\n__14. I have a question related to tax form ?__\n    Topcoder cannot provide any tax advice due to legal reasons. Please         consult your tax advisor for guidance. Please write \"N/A\" for any field that you wish to leave blank, as the form doesn't accept blank responses.\n\n__15. Do payments have an expire date ?__\n   As per current policy, payments do not have an expiry date. Changes to policy, if any, will be communicated in advance to members. However, it’s recommended that members withdraw their payments within 6 months of its creation.\n\n__16. I have won a challenge but I don't see the payment in PACTS yet ?__\nPayments are processed in batches. It can take upto 12 hours for the payment to visible in PACTS, after challenge conclusion.\n\n__17. Can a minor claim prize money ?__\n  No, you must be the age of majority to participate or engage in activities involving payment. Please check our website [terms of use](https://www.topcoder.com/community/how-it-works/terms/ \"terms of use\") for details. If any payment is generated for a minor, it will be cancelled and will not be paid.\n\n__18. I am receiving an error \"Payoneer account is not active\" while withdrawing payments ?__\nThis error occurs, when you haven't completed the Payoneer linkage with Topcoder. Please check the invitation link, that was sent in payment steup ticket, and notify us that you have linked your Payoneer account from your side.\n\n__19. I am receiving the below error while withdrawing from Paypal ?__\n*Please confirm that your PayPal account is established properly and that any credit card on file with PayPal is \"verified\"*\n\nPlease consult Paypal support to resolve the error. It usually means the paypal account is not fully configured to accept international payments.\n","contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1oYlk9lUxTwEDGuQo80etF","type":"Entry","createdAt":"2019-11-25T19:12:49.106Z","updatedAt":"2019-11-25T19:12:49.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Jaya Dhaka","tcHandle":"jaya.dhaka"}}],"upvotes":21,"downvotes":3}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3AQk2ytPIewXiFFbB2gpIM","type":"Entry","createdAt":"2022-01-25T07:45:42.743Z","updatedAt":"2024-07-20T17:01:00.295Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":154,"revision":37,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Installing Topcoder's Vintage Arena","slug":"installing-topcoders-vintage-arena","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"n6mlhtkgBaqaEoDit68Rs","type":"Entry","createdAt":"2020-01-09T19:02:56.321Z","updatedAt":"2020-01-09T19:02:56.321Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Competitor Documentation","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"47m7HZF8X855k7uGl3IPxy","type":"Entry","createdAt":"2019-09-19T07:36:03.658Z","updatedAt":"2019-09-19T07:36:03.658Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Topcoder-Centric","trackParent":"Competitive Programming"}}],"tags":["Vintage Arena","JRE","Competitive Programming","JAVA"],"creationDate":"2022-01-25","readTime":"13min","content":"<iframe width=\"100%\" height=\"630\" src=\"https://www.youtube.com/embed/Xjdo63kiMeE\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"true\"></iframe>\n\nIf you would like to follow along with Pena in the video above, he will walk you through how to properly install the Topcoder Java Applet aka the Topcoder Vintage Arena.  Otherwise, you can follow the step by step instructions below.\n\n### Prerequisite\n\nYou must have the Java Runtime Environment (JRE) installed on your computer.  If you do not have it installed, you may go [here to download](http://java.com/en/download/index.jsp) it.  Once downloaded, open the file to install it.  This part should be pretty self explanatory.\n\nAlright, now we are ready to install the arena!\n\n### 1. Download the Arena\n\nIf you haven’t already, [download the arena](https://www.topcoder.com/contest/arena/ContestAppletProd.jnlp).\n\n### 2. Open the Executable\n\nOnce you download the file, go ahead and open it.  You will notice that you received a warning message.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/78KiAR7o4p2VJQmZfxPvTj/de5da12058ebeb4b12ce835d401062b6/Screen_Shot_2022-01-24_at_2.11.28_PM.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/78KiAR7o4p2VJQmZfxPvTj/de5da12058ebeb4b12ce835d401062b6/Screen_Shot_2022-01-24_at_2.11.28_PM.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/78KiAR7o4p2VJQmZfxPvTj/de5da12058ebeb4b12ce835d401062b6/Screen_Shot_2022-01-24_at_2.11.28_PM.png\" alt=\"image\" loading=\"lazy\"></picture>\nThis is what it would look like in __Windows__.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/6e55t43nyXZGhoyljsR3lw/dbb4f188fc07728e8f1abbb7bc8a3b29/Screen_Shot_2022-01-24_at_2.10.44_PM.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/6e55t43nyXZGhoyljsR3lw/dbb4f188fc07728e8f1abbb7bc8a3b29/Screen_Shot_2022-01-24_at_2.10.44_PM.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/6e55t43nyXZGhoyljsR3lw/dbb4f188fc07728e8f1abbb7bc8a3b29/Screen_Shot_2022-01-24_at_2.10.44_PM.png\" alt=\"image\" loading=\"lazy\"></picture>\nThis is what you would see on a __Mac__.\n\nThis is due to modern java security policies, so we will have to add some exceptions.\n\n### 3. Open Your Java Control Panel\nIf you are on __Windows__, to open the control panel, click your windows button on the bottom left and type in “Configure Java”.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5nos5X0Bt5qxxNdCxZ0VeX/e8bc6663de7f3d0143da8664c5d9b917/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5nos5X0Bt5qxxNdCxZ0VeX/e8bc6663de7f3d0143da8664c5d9b917/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/5nos5X0Bt5qxxNdCxZ0VeX/e8bc6663de7f3d0143da8664c5d9b917/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\nTo access the Java Control Panel on a __Mac__, open your System Preferences.  You should see a Java icon. Clicking on that will open the control panel in another window.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2cq1nnAtf2BdJrjtXsPXIU/187a13cfe05e5e09a5ed1bfac4164dcb/Screen_Shot_2022-01-24_at_2.43.09_PM.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2cq1nnAtf2BdJrjtXsPXIU/187a13cfe05e5e09a5ed1bfac4164dcb/Screen_Shot_2022-01-24_at_2.43.09_PM.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2cq1nnAtf2BdJrjtXsPXIU/187a13cfe05e5e09a5ed1bfac4164dcb/Screen_Shot_2022-01-24_at_2.43.09_PM.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### 4. Adding Exceptions\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/18CiFib8Oeem1LOyIUjpUA/339056504ff9893d6636627c1de395db/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/18CiFib8Oeem1LOyIUjpUA/339056504ff9893d6636627c1de395db/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/18CiFib8Oeem1LOyIUjpUA/339056504ff9893d6636627c1de395db/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\nOnce you are in the control panel, head on over to the “Security” tab.  Assure that the security level is set to “High” and not “Very High”.  Next, click “Edit Site List” and input the following endpoints one by one.\n\nhttp://www.topcoder.com\nhttps://www.topcoder.com\nhttp://arena.topcoder.com\nhttps://arena.topcoder.com\nhttps://topcoder.com,\nhttp://topcoder.com\n\nYou may receive a warning when inputting an “http” link.  Just press continue to move on.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4XPCEs9TrVRm789LBCb5du/d83d208ce897566fbc0ff17a1409a1ac/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4XPCEs9TrVRm789LBCb5du/d83d208ce897566fbc0ff17a1409a1ac/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4XPCEs9TrVRm789LBCb5du/d83d208ce897566fbc0ff17a1409a1ac/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\nOnce finished, press “Ok” and exit out of the Control Panel.\n\n### 5. Open The Arena\nDouble click on the ContestAppletProd.jnlp file again and you will find that it successfully opens to the arena’s login page.\n\n*There have been reports that on a Mac, there may be an extra step where you will have to click a checkbox and agree to launch the application.  It has also been reported that to open apps for the first time on a Mac, you need to right click -> open with -> Java Launcher app.*\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3JuV6zSoZ7l8SZwYBRN0ry/7a3b905cacb1ace2515ed4dac2468e50/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3JuV6zSoZ7l8SZwYBRN0ry/7a3b905cacb1ace2515ed4dac2468e50/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3JuV6zSoZ7l8SZwYBRN0ry/7a3b905cacb1ace2515ed4dac2468e50/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### 6. Final Step: Login with your Topcoder Account!\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4m4WLz3FfcnvgfFDQhgjER/a15b6d86dcefa86a9628f2fb77150234/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4m4WLz3FfcnvgfFDQhgjER/a15b6d86dcefa86a9628f2fb77150234/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4m4WLz3FfcnvgfFDQhgjER/a15b6d86dcefa86a9628f2fb77150234/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\nHopefully this was helpful to get you up and running with the Vintage Arena.  This article will be updated with other helpful “Getting Started in the Arena” articles, so check back in soon!\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7v2hlDsVep7FWufHw0lXpQ","type":"Asset","createdAt":"2021-08-03T09:25:08.111Z","updatedAt":"2021-08-03T09:25:08.111Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"locale":"en-US"},"fields":{"title":"default article banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7v2hlDsVep7FWufHw0lXpQ/2505e61a880e68fab4e80cd0e8ec1814/0C37CB5E-B253-4804-8935-78E64E67589E.png","details":{"size":88903,"image":{"width":445,"height":356}},"fileName":"0C37CB5E-B253-4804-8935-78E64E67589E.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2qRZaSBrCm3gt4mQDV8rzT","type":"Entry","createdAt":"2019-09-18T07:37:59.034Z","updatedAt":"2019-11-25T21:45:44.043Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nick Castillo","tcHandle":"nick.castillo","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48SmHD7c0d2X94RWb1Ug6j","type":"Asset","createdAt":"2019-11-25T21:44:05.698Z","updatedAt":"2019-11-25T21:46:46.988Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":12,"revision":3,"locale":"en-US"},"fields":{"title":"Nick Profile Mic","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/48SmHD7c0d2X94RWb1Ug6j/9e61ada513c7c4bdcd29662697faebbb/portrait_square.jpg","details":{"size":85529,"image":{"width":769,"height":769}},"fileName":"portrait_square.jpg","contentType":"image/jpeg"}}}}}],"upvotes":20,"downvotes":4,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"53DKhRPQZF8wHYXn3Nrpue","type":"Entry","createdAt":"2021-11-16T20:47:39.346Z","updatedAt":"2024-07-02T15:06:59.853Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":54,"revision":27,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competitive Programming at Topcoder: A Step by Step Guide","slug":"competitive-programming-at-topcoder-a-step-by-step-guide","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":67,"downvotes":5,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"aiNgKJ0eML1w5qUl2oa79","type":"Entry","createdAt":"2021-08-23T10:03:14.050Z","updatedAt":"2024-09-22T14:45:37.293Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":463,"revision":131,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"All about Topcoder Challenges, Tasks and Gig Work Opportunities","slug":"all-about-topcoder-challenges-tasks-and-gig-work-opportunities","type":"Video","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}}],"tags":["Help Article","Community","FAQs"],"creationDate":"2021-08-23","readTime":"13min","content":"\n- <AnchorLink href=\"#1\">What is a Topcoder Challenge?</AnchorLink>\n- <AnchorLink href=\"#2\">What is an SRM (Algorithm Challenge)</AnchorLink>\n- <AnchorLink href=\"#3\">What is a Development Challenge</AnchorLink>\n  - <AnchorLink href=\"#4\">What are RDMs</AnchorLink>\n  - <AnchorLink href=\"#12\">What are Skill Builder Competitions</AnchorLink>\n- <AnchorLink href=\"#41\">What is a First2Finish challenge</AnchorLink>\n- <AnchorLink href=\"#5\">What is a Design Challenge</AnchorLink>\n  - <AnchorLink href=\"#6\">What is LUX/RUX</AnchorLink>\n- <AnchorLink href=\"#7\">What is a QA challenge</AnchorLink>\n- <AnchorLink href=\"#8\">What is a Data Science Challenge</AnchorLink>\n  - <AnchorLink href=\"#9\">What is a Marathon Match</AnchorLink>\n- <AnchorLink href=\"#10\">What is Gig Work</AnchorLink>\n- <AnchorLink href=\"#11\">What is a Task</AnchorLink>\n<a id=\"1\"></a>\n### What is a Topcoder Challenge?\n\nTopcoder is a competition-based community at its heart. Let's go through the main kinds of challenges available at Topcoder. The common features of each challenge type are a strict timeline consisting of multiple phases and a score-based ranking system for competitors, based on their competition history.\n\n<a id=\"2\"></a>\n#### What is an SRM (Algorithm Challenge)\n\nSingle-round matches (SRM) are the oldest kind of challenge available at Topcoder. They are algorithm competitions, usually consisting of three problems (easy, medium and hard), that are solved by the contestants in a short time (often 75 minutes). A Rookie SRM is a variant of these competitions aimed at newer members. They have the exact same match structure, but the problems are easier and more approachable to people with less experience in algorithm competitions.\n\nA contest consists of a \n\n- **Registration Phase** - 24 Hours\n- **Coding Phase** - 75 mins\n- **Intermission Phase** - 5 mins\n- **Challenge Phase** \\- 15 mins\n- **System Tests**, which conclude the round. \n\nThe coding phase is the problem-solving part, during which the contestants write their code to solve the given problems. Competitors are divided into \"rooms\", consisting of twenty competitors each. \n\nDuring the challenge phase, the participants are given access to the code submitted by other competitors in the same room, and have the chance to \"challenge\" this code. A challenge consists of finding a test case for which the submitted code fails or gives a wrong answer. A successful challenge removes all preliminary points from that submission and grants the successful challenger +50 points. A failed challenge costs 25 points.\n\nAfter the challenge phase the system test phase begins, during which every submission is thoroughly tested for correctness. Failed submissions lose their score for that problem. Soon after the system test phase is finished ratings are updated.\n\nSee:\n\n[How to compete in SRMs](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20SRMs)\n\n[General Topcoder Arena Usage Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions)\n\n[How to compete in SRMs:Extras and FAQs](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20SRMs:%20Extras%20and%20FAQs)\n\n<a id=\"3\"></a>\n#### What is a Development Challenge\n\nDevelopment challenges usually run between a few days or one to two weeks. The task is usually to complete a piece of functionality in a software product or to create one from scratch.\n\nDevelopment Track at Topcoder consists of three types of challenges: \n\n-   First2Finish (F2F) challenges - First2Finish are quick challenges in which competitors are asked to fix bugs or do a small task. The challenge is open until the project manager or copilot running the challenge has a winning submission.\n\n-   Code Challenges - Code challenges ask you to develop code for apps, services, etc. Final fixes, which are sometimes required after a typical challenge, are not included in these types of challenges.  \n\n-   Ideation challenges - Ideation Challenges ask you to research and ideate a solution on the problem statement presented to you. \n\nThe most popular challenge type in the development track is the code challenge. The technologies are varied, ranging from AngularJS, Node.js, Java, iOS, Android, Python, and several others. \n\nIn a code challenge, you will develop code for apps, services, etc. You must ensure your submission addresses all the requirements mentioned in the challenge specification. You also need to ensure your code is modularized, clean and well documented, and you need to provide clean documentation for deployment and verification.\n\nSee: \n\n[How to compete in Development Challenges?](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20In%20Development)\n\n<a id=\"4\"></a>\n##### What are RDMs\n\nRapid development matches (RDMs) are quick, fast-paced ranked development challenges, where you have to develop an application strictly according to specification. Speed is of importance since the matches are rated. They usually last for one hour. They represent a great way to test and to improve your development skills. An RDM is structured similarly to an SRM algorithm match, there are three problems: easy, medium and hard. The competitors' submissions will be tested against an automatic tester that can provide instant feedback on the submissions.\n\nSee:\n\n[RDMs](https://www.topcoder.com/thrive/articles/rdm-competition-faqs-and-rules)\n\n<a id=\"12\"></a>\n##### What are Skill Builder Competitions\nSkill Builders Competitions are competitions meant to help you build proficiency in a certain technology or product. A Topcoder Skill Builder challenge consists of three consecutive problems: Easy, Medium and Hard. Each problem is usually related, such that they build on each other. There will be a separate leaderboard for a Skill Builder challenge that keeps track of points across all three problems. A Skill Builder challenge usually runs for an extended period of time, such as a month. During the first run of a challenge, there are usually prizes and swag as well, these are generally given to the first submissions that pass review. Skill Builder challenges are ranked, and grant verified skill badges for your Topcoder profile.\n\nSee:\n\n[Topcoder Skill Builder Competitions](https://www.topcoder.com/thrive/articles/topcoder-skill-builder-competitions)\n\n<a id=\"41\"></a>\n#### What is a First2Finish challenge\nA F2F (First2Finish) match is a kind of development or design challenge where, as the name implies, the winner is determined as the competitor with the first submission to pass the minimum requirements for the challenge. Due to the nature of the challenge, review is performed during the Submission Phase of the match as the submissions keep coming it. Once a passing submission is found, the winner is determined and the match ends. These challenges are usually reasonably small in scale, such as bug fixes or configuration work. Speed is of the essence here, so keep your eyes peeled on that [Challenge listing](https://www.topcoder.com/challenges?tracks[Dev]=true&types[]=F2F)!\n\n<a id=\"5\"></a>\n#### What is a Design Challenge\n\nTopcoder Design Challenges provide coverage for a full range of design needs, from responsive and mobile application user experience to marketing collateral creation and support. To be specific, there are seven types of design challenges that we offer in the Design track.\n\n-   Application Front End Design\n-   Web Design\n-   Widget or Mobile Screen Design\n-   Wireframes\n-   Print/Presentation\n-   Design First2Finish\n-   Idea Generation\n\nYou must ensure your design submission addresses all the requirements mentioned in the challenge specification, and ensure your design follows the best practice for the specific interface or devices. \n\nSee: \n\n[How to compete in Design Challenges?](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20Design)\n\n<a id=\"6\"></a>\n##### What is LUX/RUX\n\nThe Live User Experience (LUX) is a fast challenge that runs for 48 hours and has a number of big prizes. The LUX challenge takes place during a live event with Topcoder and a customer. The Rapid User Experience (RUX) is similar to a LUX but it runs for 72 hours and awards 5 big prizes. Both challenges run fast and are only a one round challenge.\n\nLUX & RUX challenges provide designers with the opportunity to show digital leaders from some of the largest companies in the world, just how good they are at creating concepts, User Experience (UX) Design, and User Interface (UI) Design. They are fast, fun, and designers have more chances to earn prize money! We even have leaderboards for these!\n\nSee:\n\n[A guide for creating Topcoder LUX RUX presentations](https://www.topcoder.com/blog/a-guide-for-creating-topcoder-lux-rux-presentations/)\n\n<a id=\"7\"></a>\n#### What is a QA challenge\n\nQuality assurance (QA) track competitions call for competitors to participate in organized QA testing of a piece of software. Technical background is not necessarily required, but experience plays an important part in gaining a good score and rating. \n\nThe QA Track, consists of four types of challenges: \n\n-   Unstructured Testing: In these types of challenges you are asked to test without predefined test cases, also known as Bug Hunt.\n\n-   Structured Testing: In these types of challenges you are asked to execute predefined test cases step by step and check if test results are correct\n\n-   Structured Test Case Writing: In these types of challenges you are asked to write test cases based on prototypes and functional requirement specifications.\n\n-   Automated Testing: In these types of challenges you are asked to use automation tools to execute test cases.\n\nThe most popular challenge type in the QA track is Bug Hunt. Here you are asked to report bugs including the steps to reproduce and the type of bug you found. While competing with others, you are paid for each verified bug and can also receive extra prize money for finding the most number of bugs. \n\nSee:\n\n[What is QA?](https://www.topcoder.com/thrive/articles/What%20is%20QA)\n\n[How to Compete in Testing Competitions](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20Testing%20Competitions)\n\n[What is a Bug Hunt?](https://www.topcoder.com/thrive/articles/What%20is%20a%20Bug%20Hunt)\n\n[How To Compete in a Bug Hunt Challenge](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20a%20Bug%20Hunt%20Challenge)\n\n<a id=\"8\"></a>\n#### What is a Data Science Challenge\n\nA data science challenge is a special kind of challenge for problems related to machine learning, data science, mathematics and statistics. They are typically longer in duration, usually at least a week, and often up to a month or more. The contestants are tasked with developing a data science solution that matches the given problem area and data as closely as possible. Some example cases might be the development of an image classification model, or to forecast data based on historical data points.\n\nSee:\n\n[Data Science Challenge Types](https://www.topcoder.com/thrive/articles/Data-Science-Challenge-Types)\n\n[Practical Skills Needed to Win Data Science Competitions](https://www.topcoder.com/thrive/articles/Practical%20Skills%20Needed%20to%20Win%20Data%20Science%20Competitions)\n\n<a id=\"9\"></a>\n##### What is a Marathon Match\n\nA marathon match is another old competition type at Topcoder. Marathon Matches are challenges where your submission is automatically scored according to the scoring details mentioned in the match specification.\n\nThey are longer than SRM matches, usually lasting one week. They consist of one difficult problem that may not have a single correct solution, but rather something where optimization must be used to create a solution that performs better than the competition. A problem may consist of a board game simulation that must be solved as efficiently as possible, or a machine learning-related task, such as classification.\n\nThese matches are mainly divided into two categories: \n\n-   **Algorithm Optimization Matches** \\- These matches are hosted by Topcoder for practice and fun. The problems are usually NP-Hard, so no optimal solution is known. The matches usually run for one week, in which you write a program to score as well as possible against the problem's scoring system. They are generally named as Marathon Match followed by a sequence number. Example: [Marathon Match 118](https://www.topcoder.com/challenges/70402b3e-fb5b-4d3d-9277-20c1fa512806)\n\n-   **Machine Learning / Data Analytics / Image Processing / Predictive Analytics etc** - These matches are designed with the help of our customers. They involve tasks with real-world applications and datasets. Example: [CDC Text Classification - Marathon Match](https://www.topcoder.com/challenges/30103825)\n\nSee:\n\n[How to compete in a Marathon Match](https://www.topcoder.com/thrive/articles/How%20To%20Compete%20in%20a%20Marathon%20Match)\n\n[Curated Marathon Matches Guide](https://www.topcoder.com/blog/complete-guide-topcoder-marathon-matches-curated-just/)\n\n<a id=\"10\"></a>\n### What is Gig Work\n\nGig work is the latest addition to the numerous ways you can challenge yourself and earn money on Topcoder. Gig work is contract work for a fixed duration in a specific role for a client. You can apply to these freelance positions from the gig work page LINK, and if your skills are a match for the role, you will be contacted for an interview. Gig work provides you a way to earn a safe, fixed income for a duration. Gigs usually last at least one month and often longer. Your Topcoder profile will be valuable in proving your skills for a successful gig application.\n\nSee: \n\n[Gig Work at Topcoder](https://www.topcoder.com/thrive/articles/gig-work-at-topcoder)\n\n<a id=\"11\"></a>\n### What is a Task\n\nA private task is a special challenge given to only a single person. This person is usually the winner of a competition or a series of competitions. Through the task, they are given a special appointment to add extra features or to do some other extra work related to the challenges they've done. A task may also be unrelated to a specific challenge, but still target a highly qualified member with the right skills for it. To gain tasks, you should compete and place highly in competitions, and also be active on Slack, where new tasks are often posted.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3g1nKR4UqmmAfvEfYXCIjB","type":"Entry","createdAt":"2021-06-30T05:59:50.778Z","updatedAt":"2021-08-23T13:07:02.867Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Pentti Sunila","tcHandle":"pena","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}}],"upvotes":41,"downvotes":2}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3YeSXGR5CUPgq9NkzBGOdr","circular":true}}],"journeyPrevious":{"sys":{"type":"Link","linkType":"Entry","id":"3YeSXGR5CUPgq9NkzBGOdr","circular":true}}}}]}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3PHRAcMYy9zmi1RpRClDub","type":"Entry","createdAt":"2019-12-29T13:15:31.543Z","updatedAt":"2024-07-20T05:59:16.158Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":302,"revision":63,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Usable Code in Dev Challenges","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-03-06","readTime":"10 min read","content":"#### What types of existing code can you use in a development challenge?\nThere are a few rules that need to be followed when submitting code as part of a contest. Here are a set of guidelines to help you determine if your code is acceptable or not:\n\n##### 1. Third-Party Code/Libraries\nWe absolutely encourage not reinventing the wheel.  However we need to be careful about third-party code/libraries, please note the following:\n\n1. All third-party code must be listed in the challenge specification or be approved by the challenge manager either through the \"Contact Form\" or in the challenge forums.\n2. All third-party code/libraries must be included as a separate library and must include the license in your submission. You can include a link to an online version of the license and library in the readme file with your submission.\n3. Submissions that include third-party code without the proper license information will be disqualified if the third-party code is found to be unusable due to license restrictions\n\n##### 2. Open Source Licenses\n\nPlease note that challenge contest specs can always overrule these guidelines.  Listed below are the most common licenses we come across.  They are listed in order of chances of being accepted.  Remember you must __ALWAYS__ ask in the forums if you are using a third party library.\n\na. MIT\n\nb. ISC\n\nc. Apache\n\nd. BSD (older versions are not compatible)\n\ne. LGPL\n\nf. GPL\n\n##### 3. What is fair reuse of code?\n\nAny code you submit as part of your solution, you must own.  You must not copy code from other libraries or previously written code that has been paid and delivered in other challenges or to other clients.  Once Topcoder has paid you for code you are not allowed to reuse it at Topcoder unless it is licensed appropriately or you have received permission.\n\nIf you want to reuse code from other sources please follow the previous section: 1. Third-Party Code/Libraries.\n\n##### 4. What are Starter Packs? How are they created? Who owns the IP?\n\nStarter Packs are small sets of code that that can serve as a starting point for application development. Topcoder owns the IP for Starter Packs, and we absolutely encourage you to re-use them for all projects. With Starter Packs, you’ll be able to:\n\n- Jumpstart application development with some solid code that can then be extended and tailored.\n- Take advantage of the best solutions out there (from the TC community).\n- Demonstrate (in code) some of the most commonly requested features.\n- Development of long term patterns that can produce even better results, more quickly.\n\nWe've started with an Ionic Starter Pack (running against a Node.js backend) to get some initial feedback. This is just a single Starter Pack, we're looking to extend this concept to create packs for many different purposes.\n\nCheck out some or our Starter Packs in Github:\n\n- [Ionic Starter Pack](https://github.com/topcoderinc/Topcoder-StarterPack_Ionic)\n- [Node.js Backend Starter Pack](https://github.com/topcoderinc/Topcoder-StarterPack_Node-Backend)\n- [API Starter Pack](https://github.com/topcoderinc/Topcoder-StarterPack_API)\n- Continuous Integration Starter Packs\n      - [Web App](https://github.com/cwdcwd/continuous-baerigration)\n      - [iOS App](https://github.com/cwdcwd/continuous-baerigration-ios)\n      - Docs\n\n##### 5. Can I reuse code that I wrote from a different challenge?\n\nIf the code you submitted wins a prize (i.e 1st, 2nd or 3rd place), then your code cannot be used in another contest for another project. The only exception is if the contest is for the same client / project, then the code can be reused. To be safe, always check with the copilot/challenge manager.\n\nFor more details on submission copyrights & intellectual property rights, please see “Winnings Submissions” and “Other Submissions” in the [Topcoder Terms & Conditions](https://www.topcoder.com/community/how-it-works/terms/).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":34,"downvotes":1,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"52WcjauIcDVJBw9awCbt6x","type":"Entry","createdAt":"2019-12-28T15:06:30.240Z","updatedAt":"2020-05-17T11:23:43.013Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":74,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Reliability Ratings and Bonuses","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-12","readTime":"5 min read","content":"Member profiles reflect reliability factors for the last 15 projects in each track. The reliability factor is calculated as the percentage of the last 15 projects that a member registers for in which that same member presents a timely submission that passes review. The projects before the first passing submission do not count against a member's reliability history.<br/><br/>\n\nSeparate reliability ratings are kept for each track. Some of the tracks have unrated past projects that do not count for the reliability rating in this track. Below is the cut-off dates for different tracks. The past projects before these dates do not count for the reliability.<br/><br/>\n\n| Track                 | Date            |\n|-----------------------|-----------------|\n| Component Design      | 05 October 2005 |\n| Component Development | 05 October 2005 |\n| Conceptualization     | 23 March 2009   |\n| Specification         | 23 March 2009   |\n| Architecture          | 23 March 2009   |\n| Assembly              | 23 March 2009   |\n| Test Suites           | 23 March 2009   |\n| Test Scenarios        | 23 March 2009   |\n| Content Creation      | 23 March 2009   |\n| UI Prototype          | 01 August 2009  |\n| RIA Build             | 01 June 2010    |\n<br/><br/>\n\nThe reliability bonus for each particular project depends on the reliability rating at the moment of registration for that project. A participant with no previous projects is considered to have no reliability rating, and therefore gets no bonus.<br/><br/>\n\nMembers are eligible to receive a bonus on top of any prize money won if their Reliability Ratings are equal to or exceed 80%. Winning members with Reliability Ratings equal to or exceeding 80% and less than 90% will receive a bonus equal to 10% of the prize. For Reliability Ratings equal to or exceeding 90% and less than 95%, winning members will receive a bonus equal to 15% of the prize. And winning members with a Reliability Rating equal to or exceeding of 95% will receive a bonus equal to 20% of the prize. The following is an example of payouts based on the member's Reliability Rating:<br/><br/>\n\n| 0% - 79% | 80% - 89% | 90% - 94% | 95% - 100% |\n|----------|-----------|-----------|------------|\n| $5,000   | $5,500    | $5,750    | $6,000     |\n| $2,000   | $2,200    | $2,300    | $2,400     |\n| $500     | $550      | $575      | $600       |\n| $200     | $220      | $230      | $240       |\n| $100     | $110      | $115      | $120       |\n<br/>*Please note: reliability bonuses do not apply to Digital Run winnings.*<br/><br/>\n\nSince reliability rating is based on the past 15 projects, it can only have 15 discrete values (assuming you have submitted at least 15 times). Here are the bonuses earned for these actual reliability levels:<br/><br/>\n\n| Detail | Rating | Bonus     |\n|--------|--------|-----------|\n| 15/15  | 100%   | 20% bonus |\n| 14/15  | 93%    | 15% bonus |\n| 13/15  | 87%    | 10% bonus |\n| 12/15  | 80%    | 10% bonus |\n| other  | <80%   | No bonus  |","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"6ngUtH10teJTtReGlKdjMF"}},{"sys":{"type":"Link","linkType":"Entry","id":"2CIz9PQ9P7uSSuCiYaqa4o"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"sys":{"type":"Link","linkType":"Entry","id":"6RtWLyyPIjfqoG7K6pAfGJ","circular":true}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"sys":{"type":"Link","linkType":"Entry","id":"6RtWLyyPIjfqoG7K6pAfGJ","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2fIVeKCycrgf9oe4FsqNJj","type":"Entry","createdAt":"2022-07-15T15:53:54.843Z","updatedAt":"2024-07-19T07:24:16.913Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":139,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Python - Data Structures and Algorithms","slug":"data-structures-and-algorithms-in-python-2","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Python","Data Structures","Algorithm"],"creationDate":"2022-07-08","readTime":"18min","content":"Python built-in data structures help developers and data scientists store, organize, and manage efficient data access and tampering. There are various built-in data structures that will aid in algorithms, which include the following:\n1. List\n2. Tuple\n3. Set\n4. Dictionaries\n\nThere are other data structures that are user-defined, namely: __graphs__, __trees__, __linked lists__, and __searching__ and sorting __algorithms__.\n\n### Python List\nThe list is expounded using a square bracket and the data held in it is separated by commas. A list can be changed, thus it is mutable and ordered.  A list contains the following data: integers, strings, boolean etc. \nBefore we proceed to insert lists, here is an example of a Python list: \n\n```python\n#A list with variable items\nitems= [12, True, \"shop\", 23.00]\n\n#print the list items\nprint(items) \n\n#Append a value in a list\nitems.append(‘products’)\n\n#Print the list items\nprint(items)\n```\n\nBelow is the result of the above lines of code:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5TmQ7eCKrwE8giCewvuJSS/81fb0d9bb273169d281e87210c37dc9c/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss1.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5TmQ7eCKrwE8giCewvuJSS/81fb0d9bb273169d281e87210c37dc9c/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss1.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/5TmQ7eCKrwE8giCewvuJSS/81fb0d9bb273169d281e87210c37dc9c/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss1.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n__NB__: From the example above, we have added a value “products” in the list, hence we will be able to insert values to the items variable. \n\n#### Python `insert()` list method\nThe Python method insert() helps to insert elements to the list to a specific index as shown in the below code:\n\n```python\n#A list with variable items\nitems= [12, True, \"shop\", 23.00]\n\n#print the list items\nprint(items) \n\n#Using the insert() method to insert ‘sugar’ at index 3(4th position) \nitems.insert(3, “sugar”)\n\n#Print the List items\nprint(items)\n```\n\nThe result of the above insert() method is displayed in the below image:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3jhlT4jJStwRXf1wgCurUw/6d2a94a38180579cf1cc00e99d9faf5d/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss2.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3jhlT4jJStwRXf1wgCurUw/6d2a94a38180579cf1cc00e99d9faf5d/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss2.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3jhlT4jJStwRXf1wgCurUw/6d2a94a38180579cf1cc00e99d9faf5d/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss2.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nThe list insert `method()` has parameters which include:\n- Index parameter - The element is inserted on the index. When the index is 1 then it is the second value of the list. \n- Element parameter - It is inserted in the Python list. \n\n#### `Insert()` return value\nThe list insert method returns None, but only updates the list. The process of the return value is shown below:\n```python\n#Creating a list of even numbers\neven_numbers = [2, 4, 6, 8 ]\n\n#Insert 10 at index 4\neven_numbers.insert(4, 10)\n\n#print the even_numbers\nprint(even_numbers)\n```\n\nThe list will be updated and at index 4 a value/element will be added in the list as displayed in the below output:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3DjmWGEsDAckyGfcKv9GnH/bbb88ad0daef5240c91398518f718ded/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss3.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3DjmWGEsDAckyGfcKv9GnH/bbb88ad0daef5240c91398518f718ded/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss3.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3DjmWGEsDAckyGfcKv9GnH/bbb88ad0daef5240c91398518f718ded/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss3.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n__NB__: A tuple can be inserted into a list as displayed below: \n```python\n#A list that is mixed\nnumbers = [{3, 4}, [6, 7, 8]]\n\n#A tuple to be inserted\nn_tuple = (4, 9)\n\n#Insert a tuple to the list\nnumbers.insert(1, n_tuple)\n\n#print the updated list\nprint(numbers)\n```\n\nThe result/output of the above-inserted tuple is displayed below: \n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4yc2dk4dpFN5RRhJCMmv9u/c863e0cdfd2498d3d3646f24af59a16a/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss4.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4yc2dk4dpFN5RRhJCMmv9u/c863e0cdfd2498d3d3646f24af59a16a/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss4.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4yc2dk4dpFN5RRhJCMmv9u/c863e0cdfd2498d3d3646f24af59a16a/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss4.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n### Python Tuple\nA tuple is a data type that cannot be changed (immutable) and ordered by elements. Immutable means one cannot add or remove elements. A tuple contains various data types which help in placing a sequence of values and separating them by commas, use of parentheses, and also without commas. \nExample of a Python tuple:\n\n```python\n#create a tuple without a parentheses\nnew_tuple = 23, “sample”\n\n#print the tuple without parentheses\nprint(new_tuple)\n\n#create a tuple with a parentheses\ntwo_tuple = (66, 49, “variable”)\n\n#print the tuple with a parentheses\nprint(two_tuple)\n```\n\n### String Literals in Python\nString literals are created by writing a group of characters enclosed by single (‘’), double (“”) and triple quotes. The string literal helps to specify the contents in a program with strings. Below is a sample string literal: \n```python\n# string literal with single quote\nb1 = ‘A literal string’\n\n#string literal with double quotes \nb2 = “A literal string”\n\n#string literal with triple quotes\nb3 = ‘’’  this is \n                the new\n                       rule’’’\n\n#Print all the string literals\nprint(b1)\nprint(b2)\nprint(b3)\n\n```\n\n__NB__: Strings cannot be changed (immutable). Modifying a string will result in a new copy of the string. \n\n### Python Array\nA Python array is a group of items that are stored at adjacent memory locations. Arrays help to keep multiple items of the same category together. An array is a special variable that stores values. Create an array by importing array modules as shown below:\n\n```python\n#importing arrays\nimport  array as arr\n\n#create an array with integers\nb = arr.array(‘j’, [2, 4, 6])\n\n#print the original array\nprint (“This is an array: ”, end=” “)\nfor j in range(0, 3):\n     print (b[j], end =” ”)\nprint()\n```\n\nThe output of the above code is displayed below:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7heKbiRKgUEefy780T7j8P/b760adc6c00f2e4cb63ac3d3123b951b/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss5.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7heKbiRKgUEefy780T7j8P/b760adc6c00f2e4cb63ac3d3123b951b/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss5.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/7heKbiRKgUEefy780T7j8P/b760adc6c00f2e4cb63ac3d3123b951b/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss5.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nArray in Python append using the `append()` function\nUsing the `append()` function helps to add elements or arrays to another array. Python lists are dynamic arrays in which the `append()` function helps to add elements at the end of the list. \nAn example of the `append()` function to the list:\n```python\nlisting = [10, 12, 14, 16, 18]\ny = [20, 21, 23]\n\n#append the second list to the listing\nlisting.append(y)\n\n#print the list\nprint(listing)\n```\n\nHow to initialize the array using the array module using the `append()` function is shown below:\n```python\n#Importing the array module\nimport array\n\n#use of array module\ny  = array.array(‘c’, [3.4, 4.4])\nz  = 20\n\n#use the append() function\ny.append(z)\n\n#print the output\nprint(y)\n```\n\n#### Using the `append()` function with NumPy array\nPython NumPy module is used to generate an array and manipulate mathematical function datasets. There are various syntaxes while using the NumPy `append()` function as described below:\n```python\nnumpy.append(array, value, axis)\n```\n- Array - it is in which data is appended\n- Axis -  data added to an array\n- Value - specific row or column operations\n__NB__: We will use the numpy.arange() method in creating an array.\n\n```python\n#importing the numpy library\nimport numpy as np\n\nx  = np.arange(4)\nprint(x)\n\nz = np.arange(20, 25)\nprint(z)\n\n#Create a new variable and append an array\nnes  = np.append(x, z)\n\n#print the result\nprint(nes)\n```\n\nThe output of the above code of NumPy array is displayed below:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2hJNIooE1ewXrRXQbWO2CG/ddf65087e81299ac705c7336494f9ea2/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss6.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2hJNIooE1ewXrRXQbWO2CG/ddf65087e81299ac705c7336494f9ea2/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss6.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2hJNIooE1ewXrRXQbWO2CG/ddf65087e81299ac705c7336494f9ea2/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss6.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n__NOTE FOR PYTHON ARRAY:__\nFor an array to be created, there are steps to follow:\na. Python NumPy array\nb. Python array from using array module\nc. Python list\n\n### Python Dictionaries\nA Python dictionary is a collection of data (unordered) that stores data in a format of key: value pair, in which indexing of a dictionary is done by using keys. A dictionary is identified using the curly braces {} to the data types such as tuples, strings, and numbers.  \nExample of Python dictionary:\n\n```python\n#create a python dictionary with a key and a value\ndict  = {‘name’: ‘topcoder’, 1: [2, 4, 6, 8]}\n\n#print the dictionary\nprint(dict)\n\n#How to access an element using  a key\nprint(dict[‘name’])\n\n#Using the get() method to access the element\nprint(dict.get(1))\n```\n\nBelow is the result of the above dictionaries:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2yLfuOg750tF8grNdULHw8/fbcf5b3913f6ed3d6474f135b16c0a01/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss7.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2yLfuOg750tF8grNdULHw8/fbcf5b3913f6ed3d6474f135b16c0a01/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss7.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2yLfuOg750tF8grNdULHw8/fbcf5b3913f6ed3d6474f135b16c0a01/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss7.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n### Python Sets\nA set is a changeable (mutable) and unordered collection of elements. Sets help to test membership and eliminate duplicate entries. Sets are created using the built-in set() function method and placed in a sequence separated by commas or curly braces.\nExample of creating a Python set:\n\n```python\n#creating a set in python with the use of a string\nset2  = set()\n\n#print the set\nprint(set2)\n\n#Use of a string\nset2  = set(“this is a string set”)\nprint(set2)\n\n#Create a set using a constructor\ntexts = “this is a string set”\nset2  = set(texts)\n\n#print the set\nprint(set2) \n\n#Create a set using a python list\nset2  = set([“These”, “nice”, “shop”])\n\n#print the set\nprint(set2)\n```\n\nThe output of the above code is displayed below: \n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5TbOcrtLRf2rNyoiuM8UjG/300b2fd0e001c22e276d83b9872de2c6/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss8.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5TbOcrtLRf2rNyoiuM8UjG/300b2fd0e001c22e276d83b9872de2c6/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss8.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/5TbOcrtLRf2rNyoiuM8UjG/300b2fd0e001c22e276d83b9872de2c6/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss8.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nUsing the `add()` function method to add elements in a set\nElements are added to a set using a built-in add() method. Lists cannot be added to a set because they can be changed while tuples cannot be changed (immutable). The use of add() function method is displayed below:\n\n```python\nset2  = set()\n\n#print the set\nprint(set2)\n\n#Add elements and tuples to a set\nset2.add(6)\nset2.add(8)\nset2.add(10, 12)\n\n#print the set2\nprint(set2)\n\n#Add elements to a set with an Iterator\nfor  j in range((2, 8)):\n      set2.add(j)\nprint(set2)  #print the addition of elements\n```\n\nThe output of the above code is displayed below:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/6oll8RXCLBDV65kQghDWYy/f0eee025f3fb385b6fb0ed8c9793cc04/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss9.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/6oll8RXCLBDV65kQghDWYy/f0eee025f3fb385b6fb0ed8c9793cc04/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss9.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/6oll8RXCLBDV65kQghDWYy/f0eee025f3fb385b6fb0ed8c9793cc04/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss9.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n#### Accessing a Set Using a For Loop\nAn item in a set can only be accessed using a for loop. The example is shown below on how items of a specified value can be accessed in a set:\n```python\n#access elements in a set\nset2  = set([“these”, “are”, “new”])\nprint(set2)\n\n#Access the element using the For Loop\nfor  j in set2:\n      print(j, end=” “)\n\n#Check the element using a keyword\nprint(“these” in set2)\n```\n\nThe output of the above code is displayed below in an image:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1NqjH2OG0BOvga7MB0RVUV/dd6bb4be91f4dd4255304c260c4628f9/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss10.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1NqjH2OG0BOvga7MB0RVUV/dd6bb4be91f4dd4255304c260c4628f9/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss10.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1NqjH2OG0BOvga7MB0RVUV/dd6bb4be91f4dd4255304c260c4628f9/Robinson_Muiru_-_Data_Structures_and_Algorithms_in_Python_-_ss10.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\n### Algorithms\nAfter studying the different types of data structures such as lists, tuples, sets, dictionaries, etc., we can learn about algorithms. \n#### Sorting Algorithm \nThe sorting algorithm is used to help sort data to a given order, which is classified as bubble sort or merge sort. A bubble sort does a comparison and sorts the adjacent elements as displayed below: \n```python\n#write a function for the bubble sort \ndef sort_bubble(new_list):\n      a = len(new_list)-1   #the minus 1 is the iteration\n      for  y in range(a):\n            for z in range(a-y):\n                 If new_list[z]>new_list[y+1]:\n                      new_list[z], new_list[z+1]=new_list[+1],new_list[y]\n\n            return  new_list\n\nnew_list =[20, 2, 8, 4]\nsort_bubble(new_list)\n```\n\n#### Searching Algorithm\nSearching algorithms help to seek elements present in a dataset. There are various types of search algorithms which include: Binary search, linear search, interpolation search, and exponential search. Example of a linear search algorithm is displayed below:\n```python\ndef linear_search(new_list, key):\n      for index in range(0, len(new_list)):\n           if (new_list[index]  == key):\n              return  index\n      else:\n             return “not available”\n\nnew_list  = [20, 2, 8, 4]\nlinear_search(new_list, 24)\n```\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6QLzQzBkpSu4Gc8lhd8GgL","type":"Asset","createdAt":"2022-07-08T14:13:18.057Z","updatedAt":"2022-07-08T14:13:18.057Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"Data Structures and Algorithms in Python","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6QLzQzBkpSu4Gc8lhd8GgL/5ebfde8ae7ab831cbcbc03d3a1085cff/campaign-creators-pypeCEaJeZY-unsplash.jpg","details":{"size":509040,"image":{"width":3008,"height":2177}},"fileName":"campaign-creators-pypeCEaJeZY-unsplash.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1Gih7PRzBW0uTm7VCeS9mm","type":"Entry","createdAt":"2021-09-21T09:34:07.920Z","updatedAt":"2021-09-21T09:34:07.920Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Robinson Muiru","tcHandle":"Rokit12"}}],"upvotes":5,"downvotes":1,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"34zIQNVTXVHI5WguauMsWx","type":"Entry","createdAt":"2020-12-18T08:52:04.288Z","updatedAt":"2024-07-15T11:27:39.055Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":26,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Getting Started with Python","slug":"getting-started-with-python","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"sys":{"type":"Link","linkType":"Entry","id":"Caw9t2fdYN3diW6ITAg20"}}],"tags":["Python"],"creationDate":"2020-12-18","readTime":"15min","content":"This article will cover almost everything you need to get started with Python. Python has become one of the most popular programming languages and is used every day by programmers to do cool things like automate, build applications and websites like Instagram, and it is used in Artificial Intelligence (AI). \nNo one is too old or too young to learn Python. Python is very easy to learn.\n\n### Installing Python:\n1. Download Python from this link -> https://www.python.org/downloads/.\n2. Install after downloading the latest Python from the above link.\n3. Don't forget to click on check Add Python 3.x to PATH.\n\n### About IDEs:\n\nIDE stands for Integrated Development Environment. It enables programmers to combine different aspects of writing code. IDEs increase programmer’s productivity by simplifying common activities in a single application like editing source code, debugging and building executables. There are different IDEs available like PyCharm, VS Code, Sublime text, and IDLE (default).\n\n#### Why PyCharm and why it is better than other IDEs?\n\n1. The intelligent code editor provided by PyCharm enables programmers to write a high quality Python code.\n2. The editor enables programmers to read code easily through color schemes, and auto indents on new lines automatically.\n3.The smart code navigation option provided by PyCharm helps programmers to edit and improve the code quality without putting in extra time. It makes both local and global changes very quickly and efficiently.\n4. PyCharm comes with a local terminal which enables the programmers to continue coding and testing without leaving the IDE.\n\n### Setting up IDE for Python:\n1. Download [PyCharm from this link](https://www.jetbrains.com/pycharm/download/#section=windows).\n2. Install Pycharm.\n3. Click on the new Project.\n4. Make sure in Project Interpreter, the base interpreter is set to your installed python version.\n\n![Screenshot 2020-12-18 10:34:50](//images.ctfassets.net/piwi0eufbb2g/1wV1DfEV8hT5wDDyZj2DTV/4da57cec5900cac1f30d4f2151ea9378/Screenshot_2020-12-18_10_34_50.png)\n\nWriting First Python Program\n\n1. Right-click on the new project created.\n2. New -> Python File\n3. Give `<Filename>.py`\n4. Type print(‘This is my first python program’)\n5. Click on run\n\n![Screenshot 2020-12-18 10:35:51](//images.ctfassets.net/piwi0eufbb2g/1Dyo4GsyUZhRip5edJY73y/23cfe00eaccf612469264ab2904ab6f2/Screenshot_2020-12-18_10_35_51.png)\n\nPython executes the program line by line.\n\nFor reference,users can read documentation at: [Read Docs](https://docs.python.org/release/3.7.9/tutorial/index.html) and can also read sample codes here: [Samples](https://www.programiz.com/python-programming/examples)\n\n### Python Variables:\n\nVariables are used in programming languages to temporarily store data in a computer's memory.\nFor example:\n\n![Screenshot 2020-12-18 10:37:01](//images.ctfassets.net/piwi0eufbb2g/353KBMKnGCzDjuktxdkmx3/454676aeddbc4853c1583473aa3de5f2/Screenshot_2020-12-18_10_37_01.png)\n\nWhen Python interpreter executes this code, it will allocate some memory and thenstore the number 29 in the memory and attach 29 to the label age. \n\nInteger, float, string, and Boolean are the data types in Python.\n\n![Screenshot 2020-12-18 10:37:48](//images.ctfassets.net/piwi0eufbb2g/nFeimIQyg8S3JJYPhgVEJ/ef1843ecbc96877d6add45be82d67c10/Screenshot_2020-12-18_10_37_48.png)\n\n### PYTHON STRINGS:\nA string is a sequence of characters. To make a string, we may enclose a sequence of characters between single, double, or triple quotes. \nThus, 'Hello world', ' \"Hello \" ', \"what's \", '''today's \"action\" plan?''' are the examples of strings.\n\n```\nprint('Hello world')\nprint(\"What’s \")\nprint('''today's plan?''' )\n```\n\n![Screenshot 2020-12-18 10:38:40](//images.ctfassets.net/piwi0eufbb2g/7d4mD9wE1aKcFpbBtCUATb/e61ddd9a765d34a00eb9c149c71ed5b0/Screenshot_2020-12-18_10_38_40.png)\n\n### OPERATORS IN PYTHON\n#### RELATION OPERATORS\nThese operators are used to compare two expressions and returns either true or false. These are greater than (>), less than (<), equals to (==), greater than equal to (>=), less than equal to (<=), not equal to (! =), they can be used for any data types.\n\n![Screenshot 2020-12-18 10:39:32](//images.ctfassets.net/piwi0eufbb2g/407HxnRem5pjDqpWAZFlln/27be9c3a569080cfa0a6e4c83f86f0d1/Screenshot_2020-12-18_10_39_32.png)\n\n#### LOGICAL OPERATORS:\n\nThe logical operators not, and, and or are applied to logical operands true and false, also called Boolean values, and yield either true or false. Not is an unary operator it requires only one operand.\n\n*and operator – It returns true only when both the expressions are true else false.\n* or operator – It returns true if any one of the expressions is true else false.\n* not operator – It returns the opposite of the expression.\n\n![Screenshot 2020-12-18 10:40:22](//images.ctfassets.net/piwi0eufbb2g/6d5P3wcGfvG6bL2Quq3Svn/8dae71553bf9f529112a74f43e53dd67/Screenshot_2020-12-18_10_40_22.png)\n\n#### BITWISE OPERATORS\n\nBitwise operators are the operators that operate on integers interpreted as strings of binary digits 0 and 1, also called bits. \n\n- Bitwise and (&)\n- Bitwise or (|)\n- Bitwise complement (~)\n- Bitwise Exclusive to (^)\n- Left Shift (<<)\n- Right Shift (>>)\n\n### BUILT-IN FUNCTIONS\nBuilt-in functions are the predefined functions that are already available in Python.\n#### input() function:\n\nThe function input enables us to accept an input string from the user without evaluating its value. The function input continues to read input text from the user until it encounters a new line, for example:\n\n![Screenshot 2020-12-18 10:41:45](//images.ctfassets.net/piwi0eufbb2g/1PW2GbdDTIrH8AfZvB0jPz/561a646839d771020b204a4268d79d60/Screenshot_2020-12-18_10_41_45.png)\n\n#### eval() function:\nThis function is used to evaluate the value of the string.\n\n![Screenshot 2020-12-18 10:42:24](//images.ctfassets.net/piwi0eufbb2g/1nFikLmcT7D536zYKGlMJQ/2d0bdbe70974f0c2e87ca9d3d91ca744/Screenshot_2020-12-18_10_42_24.png)\n\n#### print() Function:\n\nprint() function enables us to produce output in Python. Print function can also have an escape sequence which can print different types of data at a time separating the values with a comma.\n\n![Screenshot 2020-12-18 10:42:59](//images.ctfassets.net/piwi0eufbb2g/2Hr4yvbGcRptANb9Bg0pq9/39db8912b78a16c7edfe309a976fc3b6/Screenshot_2020-12-18_10_42_59.png)\n\n#### Other functions:\n__type() Function:__ It returns the data type of the parameter.\n\n![Screenshot 2020-12-18 10:43:37](//images.ctfassets.net/piwi0eufbb2g/21w2aN0Mjnw17PjcJVBiuy/29709a67ace01dcf3905f830074eb4a4/Screenshot_2020-12-18_10_43_37.png)\n\n__max(), min() Function:__ It returns the maximum and minimum value of the data given.\n\n![Screenshot 2020-12-18 10:44:31](//images.ctfassets.net/piwi0eufbb2g/7HRLB4ZcZw0dpg8nDeBQy3/e4e652dbd0e8fc6d6241c013ec452759/Screenshot_2020-12-18_10_44_31.png)\n\n__round() Function:__ It rounds the value of the parameter and returns the  rounded value.\n\n![Screenshot 2020-12-18 10:45:21](//images.ctfassets.net/piwi0eufbb2g/63GkyF8v9j8Xb6o0GV9Ujq/d74a747800523ac66c1acd8d3187bb77/Screenshot_2020-12-18_10_45_21.png)\n\n__pow() Function:__ It takes two values, number and exponent, and returns number to the power of exponent.\n\n![Screenshot 2020-12-18 10:46:49](//images.ctfassets.net/piwi0eufbb2g/7iu4RXIjHDf0HBCbkFGQnH/9c013dac26c084558cd3399947a1a109/Screenshot_2020-12-18_10_46_49.png)\n\n[HERE IS A LIST OF OTHER BUILT-IN FUNCTIONS](https://docs.python.org/3/library/functions.html#float)\n\nTry it yourself:\n1. Create a variable name which will take the input from the user and print it.\n2. Print the maximum and minimum values out of four values.\n3. Input five values and print their respective data types.\n4. Input two numbers x and y and print x raised to power y.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3kNHPHf18iXXpDrqcCvljE"}}],"upvotes":25,"downvotes":0}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7jXzj0Re46Izgnuy04I5X8","type":"Entry","createdAt":"2022-07-15T15:51:22.672Z","updatedAt":"2022-07-25T02:36:55.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":122,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","slug":"python-data-structures-strings","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"1XKgff9ovQ0Qb7cPbG37Un"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Python","Data Structures"],"creationDate":"2022-07-07","readTime":"10min","content":"Data structures are used to store and organize data efficiently. They allow you to quickly access and manipulate the data. Python includes many built-in data structures for easy data management.\nIn this article we will learn about one of Python's most important data structures: Strings. \n\nWorking on real-world projects will make you realize how significant strings are as a data type in Python. Since working with strings seems simple but solving problems is complex, the majority of problem statements in interviews and written examinations are based on string manipulation.\nIn this article we cover everything about strings.\n\n### Brief Overview of Python String Data Type\n\nStrings are a collection of Unicode characters that are used specifically in Python. A string is the language or text we use to communicate. However, machines can only read binary, they cannot comprehend text. As a result, ASCII numbers are initially generated from characters before being transformed to binary representation. However, ASCII is exclusively used for the English language, and when programming languages are used in other nations, they are translated to 16-bit characters known as Unicode.\n\n##### Creating Strings\n\nPython offers several methods for creating strings, including single, double, and triple quotes. When constructing a string, if the string contains any kind of quote, you should use a separate kind of quote in the declaration to prevent an error. Try the example below in any Python IDE or code editor for a better understanding.\n\n```python\ns = 'Good Morning' #single quotes\ns = 'It's been a great day' #syntax error (It confuses where string starts and ends)\ns = \"It's been a great day\" #correct way\ns = '''Good Morning''' #multi-line strings\n```\n\nWhen declaring or referencing a lengthy paragraph use triple quotes. Any other data type can be declared as a string or converted using an internal function.\n\n```python\na = 99 #int\nprint(str(a)) #int to str\n```\n\n##### Accessing Substring from String\n\nTo address a specific use case, it may occasionally be essential to access portions of a string. We shall discuss indexing and slicing, which enable us to extract a specific section of the text as output.\n\n#### Indexing\n\nIndexing a string with zeros is the same as indexing an array. Simply put, the zero indexes in a string represent the first character, and as the index rises, the string advances. Positive and negative indexing are the two categories of indexing in Python.\n\n##### Positive Indexing\n\nPositive indexing is moving from zero to the end length of a string. It is also known as zero-based indexing.\n\n```python\ns = 'GoodMorning' \nprint(s[0])  \nprint(s[2])  \nprint(s[4])  \nprint(s[len(s)-1]) \nprint(len(s))\n```\n\n__output:__\n```python\nG\no\nM\ng\n11\n```\n\n__Note__: If access s(11), program returns a Index error\n\n##### Negative Indexing\n\nAccessing string elements using a negative index means going backward in time. It usually  takes a long time to access the last character in a string if we use positive indexing since we have to calculate the length of the string and then take one off of it. In this situation, we can just use the negative indexing.\n\n```python\ns = 'GoodMorning' \nprint(s[-1])  \nprint(s[-2])\n```\n__output:__\n```python\ng\nn\n```\n\n##### Slicing\nThe concept of slicing, which is accomplished using the colon operator, comes into play when we have long strings, such as sentences or paragraphs, and we want to access specific pieces, like whole words, but we cannot do so merely using indexing. To ensure that the output is a portion of the string from a start index to an end index less one, we must specify the starting index and end index in square brackets that are separated by colons.\n\n```python\ns = 'Good Morning' \nprint(s[1:4])\n```\n\n__output:__\n```python\nood\n```\n\nStart with the first index in the example above and retrieve the character all the way to the third index. Now that there are various slicing variations, let's examine them practically using the code sample below.\n\n```python\ns = 'GoodMorning' \nprint(s[1:])  \nprint(s[:4])\nprint(s[:])\nprint(s[0:8:3])\nprint(s[::-1])\n```\n\n__output:__\n```python\noodMorning\t\t#It will print the entire string starting from index 1\nGood\t\t\t#It will print the entire string starting from index 0 to 3\nGoodMorning\t\t#It will print the entire string \nGdr\t\t\t\t#It will print zero index and skip two index and take third index till eighth index\ngninroMdooG #It will print the string in reverse order\n```\n\n### Editing and Deleting Python Strings\n\nSince strings in Python are immutable data types, attempting to change one will result in a type error. The existing string cannot be changed or added to, but it can be assigned to a separate variable to produce a new string. Let's examine the practical effects of deleting and altering strings to see whether we experience any errors.\n\nSince strings are immutable, we cannot directly reassign the value of the particular string in the below snippet.\n\n```python\ns = 'GoodMorning' \ns[0] = \"M\" \t\t #This operation is not allowed and it will return not support Item assignment error\n\n```\n\nInstead, the below combination will work\n\n```python\ns = 'GoodMorning' \na = \"M\" + s[1:]\t \nprint(a) \n```\n\n__output:__\n```python\nMoodMorning\n```\n\nDeleting the strings won't work well and the below statements will generate errors saying we can't delete the string.\n\n```python\ndel s[0]    \ndel s[:3:2] \n```\n\nIt is crucial to comprehend that strings cannot be changed; nothing can be added or removed from an existing string.\n\n### Operations on Python String\n\n#### Arithmetic Operations\n\n##### Addition(+)\n\nConcatenation, as it is also known, allows us to link any amount of strings by using the addition operator.\n\n```python\ns = \"Good\" + \"-\" + \"Morning\"\nprint(s) \n```\n__output:__\n```python\nGood-Morning\n```\n\n##### Multiplication(*)\n\nTo repeat a certain string before the multiplication operator any number of times is known as string repetition. When we want a pattern, we use it.\n\n```python\ns = \"Good\" \nprint(s*3) \n```\n__output:__\n```python\nGoodGoodGood\n```\n\n#### Relational Operations \n\nRelational operators display the relationship between two terms and determine whether a particular condition is true or false, producing a boolean result.\n```python\nprint(\"Hello\" == \"World\")  \nprint(\"Hello\" != \"World\")  \n```\n__output:__\n```python\nFalse\nTrue\n```\n\nWhen we apply the larger than and less than operators the situation becomes more intriguing.\n```python\nprint(\"Mumbai\" > \"Pune\")  \nprint(\"Goa\" < \"Indore\") \n```\n\n__output:__\n```python\nFalse\nTrue\n````\n\nYou might be wondering how it compares two strings. As a result, it lexicographically compares a string. As P follows M in the alphabetical order in the first case, the statement is false. Lowercase characters are placed after uppercase because occasionally people mistake the two case types.\n\n#### Logical Operations\nWhen you use the AND, OR, and NOT logical operators on strings, Python returns false for empty strings and true for non-empty strings.\n\n```python\nprint(\"Hello\" and \"World\") #True and True -> True (O/P -> World)\nprint(\"\" and \"World\") #False and True -> False (O/P -> \"\")\nprint(\"\" or \"World\") #False OR True -> True (O/P -> \"World\")\nprint(not \"Hello\") #opposite of True -> False\nprint(not \"\") #True\n```\n\n##### Loops\nSlicing allows us to loop over strings starting at any index. To access distinct characters or create a pattern in a string, we can use both a where and a for loop.\n\n```python\ns = 'GoodMorning' \nfor i in s:\n\tprint(i)\n```\n\n__output:__\n```python\nG\no\no\nd\nM\no\nr\nn\ni\nn\ng\n```\n\n#### Membership Operators\nPython's in and NOT in membership operators are used to determine whether any element is present in any sequence data structure.\n\n```python\ns = 'GoodMorning' \nif 'M' in s:\n\tprint('true')\n```\n__output:__\n```python\ntrue\n```\n\n### Python String Functions\nThe most important parts of a string are string functions which you use everywhere whenever you build any project. Now we will study all-important string functions which are frequently used.\nCommon Functions:\n\nThese are the same functions that are available for all other iterator data types, including list, tuple, set, and string.\n\n1. length - It provides the string's length.\n2. minimum - This function returns the smallest character in a string, as determined by ASCII.\n3. maximum - The largest character found in the string, as determined by ASCII, is provided by the third option, maximum.\n4. sorted - The string is sorted in either ascending or descending order using the ASCII character sequence. This function always returns a list of characters as its result.\n\n```python\ns = 'GoodMorning' \nprint(len(s))\nprint(min(s))\nprint(max(s))\nprint(sorted(s))\nprint(sorted(s,reverse=True))\n```\n\n__output:__\n```python\n11\nG\nr\n['G', 'M', 'd', 'g', 'i', 'n', 'n', 'o', 'o', 'o', 'r']\n['r', 'o', 'o', 'o', 'n', 'n', 'i', 'g', 'd', 'M', 'G']\n```\n\n#### Some Specific Purpose Functions in Strings\nThe functions we'll look at here only work with strings.\n\n##### Title or capitalize\nThe title function capitalizes the first letter of each word, whereas the capitalize function capitalizes the first letter of a string.\n```python\ns = \"its raining outside\"\nprint(s.capitalize()) #O/P -> Its raining outside\nprint(s.title()) \t #O/P -> Its Raining Outside\n```\n\n##### Upper / lower / swap case\nIn string each character is converted in the upper function to lowercase characters. Swap case changes an upper to a lower case character, and vice versa.\n```python\ns = \"Its Raining Outside\"\nprint(s.upper()) #O/P -> ITS RAINING OUTSIDE\nprint(s.lower()) #O/P -> its raining outside\nprint(s.swapcase()) #O/P -> iTS rAINING oUTSIDE\n```\n\n##### Count\nIt provides the number of any substrings that are present in a string. It outputs 0 if the substring is missing from the string. It is used to determine how often a given substring occurs in a string.\n```python\ns = \"Its Raining Outside\"\nprint(s.count(\"i\")) #3\nprint(s.count(\"ing\")) #1\n```\n\n###### Find / Index\nBoth functions operate in exactly the same manner. Both locate the position of a substring within a string. The sole distinction between the two functions is that while index gives an error when the substring is absent, string find produces a negative value when this occurs.\n```python\ns = \"Its Raining Outside\"\nprint(s.find(\"ing\")) #8\nprint(s.index(\"ing\")) #8\nprint(s.find(\"down\")) #-1\nprint(s.index(\"down\")) #error\n```\n\n### Conclusion\nIn this article we have learned about string literals in Python. We have started by getting ideas about string and covered how to use, create, and play with string and string functions. Hope you enjoyed it. \n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3NYB2aT7Gq3kJRqScz4IPw","type":"Asset","createdAt":"2022-07-08T03:28:13.117Z","updatedAt":"2023-09-14T11:30:09.820Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3NYB2aT7Gq3kJRqScz4IPw/7478abbc77e49c6af713855f234d3e34/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"34zIQNVTXVHI5WguauMsWx","type":"Entry","createdAt":"2020-12-18T08:52:04.288Z","updatedAt":"2024-07-15T11:27:39.055Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":26,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Getting Started with Python","slug":"getting-started-with-python","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"sys":{"type":"Link","linkType":"Entry","id":"Caw9t2fdYN3diW6ITAg20"}}],"tags":["Python"],"creationDate":"2020-12-18","readTime":"15min","content":"This article will cover almost everything you need to get started with Python. Python has become one of the most popular programming languages and is used every day by programmers to do cool things like automate, build applications and websites like Instagram, and it is used in Artificial Intelligence (AI). \nNo one is too old or too young to learn Python. Python is very easy to learn.\n\n### Installing Python:\n1. Download Python from this link -> https://www.python.org/downloads/.\n2. Install after downloading the latest Python from the above link.\n3. Don't forget to click on check Add Python 3.x to PATH.\n\n### About IDEs:\n\nIDE stands for Integrated Development Environment. It enables programmers to combine different aspects of writing code. IDEs increase programmer’s productivity by simplifying common activities in a single application like editing source code, debugging and building executables. There are different IDEs available like PyCharm, VS Code, Sublime text, and IDLE (default).\n\n#### Why PyCharm and why it is better than other IDEs?\n\n1. The intelligent code editor provided by PyCharm enables programmers to write a high quality Python code.\n2. The editor enables programmers to read code easily through color schemes, and auto indents on new lines automatically.\n3.The smart code navigation option provided by PyCharm helps programmers to edit and improve the code quality without putting in extra time. It makes both local and global changes very quickly and efficiently.\n4. PyCharm comes with a local terminal which enables the programmers to continue coding and testing without leaving the IDE.\n\n### Setting up IDE for Python:\n1. Download [PyCharm from this link](https://www.jetbrains.com/pycharm/download/#section=windows).\n2. Install Pycharm.\n3. Click on the new Project.\n4. Make sure in Project Interpreter, the base interpreter is set to your installed python version.\n\n![Screenshot 2020-12-18 10:34:50](//images.ctfassets.net/piwi0eufbb2g/1wV1DfEV8hT5wDDyZj2DTV/4da57cec5900cac1f30d4f2151ea9378/Screenshot_2020-12-18_10_34_50.png)\n\nWriting First Python Program\n\n1. Right-click on the new project created.\n2. New -> Python File\n3. Give `<Filename>.py`\n4. Type print(‘This is my first python program’)\n5. Click on run\n\n![Screenshot 2020-12-18 10:35:51](//images.ctfassets.net/piwi0eufbb2g/1Dyo4GsyUZhRip5edJY73y/23cfe00eaccf612469264ab2904ab6f2/Screenshot_2020-12-18_10_35_51.png)\n\nPython executes the program line by line.\n\nFor reference,users can read documentation at: [Read Docs](https://docs.python.org/release/3.7.9/tutorial/index.html) and can also read sample codes here: [Samples](https://www.programiz.com/python-programming/examples)\n\n### Python Variables:\n\nVariables are used in programming languages to temporarily store data in a computer's memory.\nFor example:\n\n![Screenshot 2020-12-18 10:37:01](//images.ctfassets.net/piwi0eufbb2g/353KBMKnGCzDjuktxdkmx3/454676aeddbc4853c1583473aa3de5f2/Screenshot_2020-12-18_10_37_01.png)\n\nWhen Python interpreter executes this code, it will allocate some memory and thenstore the number 29 in the memory and attach 29 to the label age. \n\nInteger, float, string, and Boolean are the data types in Python.\n\n![Screenshot 2020-12-18 10:37:48](//images.ctfassets.net/piwi0eufbb2g/nFeimIQyg8S3JJYPhgVEJ/ef1843ecbc96877d6add45be82d67c10/Screenshot_2020-12-18_10_37_48.png)\n\n### PYTHON STRINGS:\nA string is a sequence of characters. To make a string, we may enclose a sequence of characters between single, double, or triple quotes. \nThus, 'Hello world', ' \"Hello \" ', \"what's \", '''today's \"action\" plan?''' are the examples of strings.\n\n```\nprint('Hello world')\nprint(\"What’s \")\nprint('''today's plan?''' )\n```\n\n![Screenshot 2020-12-18 10:38:40](//images.ctfassets.net/piwi0eufbb2g/7d4mD9wE1aKcFpbBtCUATb/e61ddd9a765d34a00eb9c149c71ed5b0/Screenshot_2020-12-18_10_38_40.png)\n\n### OPERATORS IN PYTHON\n#### RELATION OPERATORS\nThese operators are used to compare two expressions and returns either true or false. These are greater than (>), less than (<), equals to (==), greater than equal to (>=), less than equal to (<=), not equal to (! =), they can be used for any data types.\n\n![Screenshot 2020-12-18 10:39:32](//images.ctfassets.net/piwi0eufbb2g/407HxnRem5pjDqpWAZFlln/27be9c3a569080cfa0a6e4c83f86f0d1/Screenshot_2020-12-18_10_39_32.png)\n\n#### LOGICAL OPERATORS:\n\nThe logical operators not, and, and or are applied to logical operands true and false, also called Boolean values, and yield either true or false. Not is an unary operator it requires only one operand.\n\n*and operator – It returns true only when both the expressions are true else false.\n* or operator – It returns true if any one of the expressions is true else false.\n* not operator – It returns the opposite of the expression.\n\n![Screenshot 2020-12-18 10:40:22](//images.ctfassets.net/piwi0eufbb2g/6d5P3wcGfvG6bL2Quq3Svn/8dae71553bf9f529112a74f43e53dd67/Screenshot_2020-12-18_10_40_22.png)\n\n#### BITWISE OPERATORS\n\nBitwise operators are the operators that operate on integers interpreted as strings of binary digits 0 and 1, also called bits. \n\n- Bitwise and (&)\n- Bitwise or (|)\n- Bitwise complement (~)\n- Bitwise Exclusive to (^)\n- Left Shift (<<)\n- Right Shift (>>)\n\n### BUILT-IN FUNCTIONS\nBuilt-in functions are the predefined functions that are already available in Python.\n#### input() function:\n\nThe function input enables us to accept an input string from the user without evaluating its value. The function input continues to read input text from the user until it encounters a new line, for example:\n\n![Screenshot 2020-12-18 10:41:45](//images.ctfassets.net/piwi0eufbb2g/1PW2GbdDTIrH8AfZvB0jPz/561a646839d771020b204a4268d79d60/Screenshot_2020-12-18_10_41_45.png)\n\n#### eval() function:\nThis function is used to evaluate the value of the string.\n\n![Screenshot 2020-12-18 10:42:24](//images.ctfassets.net/piwi0eufbb2g/1nFikLmcT7D536zYKGlMJQ/2d0bdbe70974f0c2e87ca9d3d91ca744/Screenshot_2020-12-18_10_42_24.png)\n\n#### print() Function:\n\nprint() function enables us to produce output in Python. Print function can also have an escape sequence which can print different types of data at a time separating the values with a comma.\n\n![Screenshot 2020-12-18 10:42:59](//images.ctfassets.net/piwi0eufbb2g/2Hr4yvbGcRptANb9Bg0pq9/39db8912b78a16c7edfe309a976fc3b6/Screenshot_2020-12-18_10_42_59.png)\n\n#### Other functions:\n__type() Function:__ It returns the data type of the parameter.\n\n![Screenshot 2020-12-18 10:43:37](//images.ctfassets.net/piwi0eufbb2g/21w2aN0Mjnw17PjcJVBiuy/29709a67ace01dcf3905f830074eb4a4/Screenshot_2020-12-18_10_43_37.png)\n\n__max(), min() Function:__ It returns the maximum and minimum value of the data given.\n\n![Screenshot 2020-12-18 10:44:31](//images.ctfassets.net/piwi0eufbb2g/7HRLB4ZcZw0dpg8nDeBQy3/e4e652dbd0e8fc6d6241c013ec452759/Screenshot_2020-12-18_10_44_31.png)\n\n__round() Function:__ It rounds the value of the parameter and returns the  rounded value.\n\n![Screenshot 2020-12-18 10:45:21](//images.ctfassets.net/piwi0eufbb2g/63GkyF8v9j8Xb6o0GV9Ujq/d74a747800523ac66c1acd8d3187bb77/Screenshot_2020-12-18_10_45_21.png)\n\n__pow() Function:__ It takes two values, number and exponent, and returns number to the power of exponent.\n\n![Screenshot 2020-12-18 10:46:49](//images.ctfassets.net/piwi0eufbb2g/7iu4RXIjHDf0HBCbkFGQnH/9c013dac26c084558cd3399947a1a109/Screenshot_2020-12-18_10_46_49.png)\n\n[HERE IS A LIST OF OTHER BUILT-IN FUNCTIONS](https://docs.python.org/3/library/functions.html#float)\n\nTry it yourself:\n1. Create a variable name which will take the input from the user and print it.\n2. Print the maximum and minimum values out of four values.\n3. Input five values and print their respective data types.\n4. Input two numbers x and y and print x raised to power y.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3kNHPHf18iXXpDrqcCvljE"}}],"upvotes":25,"downvotes":0}},{"sys":{"type":"Link","linkType":"Entry","id":"79Q3wxU7N1THUOilI7RUtq"}},{"sys":{"type":"Link","linkType":"Entry","id":"6GBXhy7l8ghq5l4eIZSLDp"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2TKYKf2Q8PtfYpLSU6RsKB","type":"Entry","createdAt":"2022-07-15T15:52:22.395Z","updatedAt":"2022-07-18T03:50:20.674Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":89,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Python Data Structures - List and Tuples","slug":"python-data-structures-list-and-tuples","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Python","Data Structures"],"creationDate":"2022-07-07","readTime":"10min","content":"Data structures are used for storing and organizing data efficiently. They allow you to quickly access and manipulate the data. Python includes many built-in data structures that enable easy data management. In this article, we will learn about two of Python's most important data structures, lists & tuples.\n\n### Data Structure #1: Lists in Python\n\nThe most flexible data structure in Python is a list. They are used to store a variety of data items, ranging from integers to strings and even another list! They are mutable, meaning their elements can be changed even after the list has been created.\n\n#### Creating Lists\nLists are formed by enclosing elements within [square] brackets and separating each item with a comma.\n\n```python\n#creating a list \ntest_list = ['Engineer', 'Doctor', 'Architect']\nprint (type(test_list))\nprint (test_list)\n```\n\n__output:__\n```python\n<class 'list'>\n['Engineer', 'Doctor', 'Architect']\n```\n\n#### Accessing List Elements\nIndexing is used to access list elements. Each list element has an index corresponding to its position in the list. The first item on the list has an index of 0, the second has an index of 1, and so on. The list's final element has an index that is one less than the list's length.\n\n```python\n#creating a list \ntest_list = ['Engineer', 'Doctor', 'Architect']\nprint (test_list[0])\nprint (test_list[1])\nprint (test_list[2])\n```\n\n__output:__\n```python\nEngineer\nDoctor\nArchitect\n```\n\nThere are a few unique features in the list data structure. \nWe can have duplicate values in the list since each element has its position, and using that, we can access the element.\n\n```python\n#creating a list with duplicate values\ntest_list = ['Engineer', 'Doctor', 'Architect', 'Doctor']\nprint (test_list[1])\nprint (test_list[3])\n```\n\n__output:__\n```python\nDoctor\nDoctor\n```\n\nWe can have different types of values in the same list.\n```python\n#creating a list with different types of values\ntest_list = ['Engineer', 10, 10.5, 'Doctor', -1]\nprint (test_list[1])\nprint (test_list[2])\nprint (test_list[4])\n```\n\n__output:__\n```python\n10\n10.5\n-1\n```\nIn the list, we can access the elements using negative indexes.\n```python\n#accessing the list with negative indexes\ntest_list = ['Engineer', 'lawyer', 'Architect', 'Doctor',' Accountant']\nprint (test_list[-1]) # it will print last element in the list\nprint (test_list[-2])\t # it will print second last element in the list\nprint (test_list[-3]) # it will print third last element in the list\nprint (test_list[-4]) # it will print fourth last element in the list\nprint (test_list[-5]) # it will print fifth last element in the list\n```\n\n__output:__\n```python\nAccountant\nDoctor\nArchitect\nlawyer\nEngineer\n```\n\nWe can return the range of elements between two positions in the list. This concept is called slicing. To return the elements in the range, we need to supply the start and end indexes like this List_name[start : end]. This will print the elements between including the start index and excluding the end index.\n```python\n#accessing the list to return the range of elements\ntest_list = ['Engineer', 'lawyer', 'Architect', 'Doctor',' Accountant']\nprint (test_list[1:3])\nprint (test_list[2:4])\n```\n\n__output:__\n```python\n['lawyer', 'Architect']\n['Architect', 'Doctor',' Accountant']\n```\n#### Appending Values in Lists\nWe can add new members to an existing list using the `append()` or `insert()` methods.\n\n##### `append()`\n\nThis operation will add the particular element to the last position. \n```python\n#appending the elements to the list\ntest_list = ['Engineer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.append('Designer')\nprint (test_list)\n```\n\n__output:__\n```python\n['Engineer', 'lawyer', 'Architect', 'Doctor', 'Accountant', 'Designer']\n```\n\n##### `insert()`\nThis operation will insert the particular element to the specified position.\n```python\n#inserting the elements to the list\ntest_list = ['Engineer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.insert(1, 'Designer')\nprint (test_list)\n```\n\n__output:__\n```python\n['Engineer', 'Designer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\n```\n\n#### Removing Elements From Lists\nUsing the `remove()` or `pop()` methods, we can remove elements from a list just like adding them using `append()` or `insert()`.\n##### `remove()`\nThis operation will remove the first occurrence from the list that matches a specified value.\n```python\n#removing the elements from the list\ntest_list = ['Engineer', 'Designer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.remove('Designer')\nprint (test_list)\n```\n\n__output:__\n```python\n['Engineer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\n```\n\n##### `pop()`\nThis operation will remove an element at a specified index from the list. If no index is specified, then the last element will be removed.\n```python\n#removing the element at the particular index from the list\ntest_list = ['Engineer', 'Designer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.pop(3)\nprint (test_list)\n```\n__output:__\n```python\n['Engineer', 'Designer', 'lawyer', 'Doctor', 'Accountant']\n```\n\n#### Sorting Lists\nSorting is an important operation in data structures, and we will be using this operation most of the time. In Python, we can use the sort() function and it will allow you to reorder your list either in ascending or descending order.\n\n```python\n#sorting ascending & descending\nprime_numbers = [5,7,2,13,11,3,17]\nprime_numbers.sort()\nprint(prime_numbers)\nprime_numbers.sort(reverse=True)\nprint(prime_numbers)\n```\n\n__output:__\n```python\n[2, 3, 5, 7, 11, 13, 17]\n[17, 13, 11, 7, 5, 3, 2]\n```\n\nBut this is not a straightforward thing when it comes to sorting the list which has string values. These string elements are stored as ASCII values. Each character in the string has an integer value associated with it and with that we use these values to sort the strings.\n```python\ntest_list = ['Engineer','Designer', 'Lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.sort()\nprint(test_list)\ntest_list.sort(reverse=True)\nprint(test_list)\n```\n\n__output:__\n```python\n['Accountant', 'Architect', 'Designer', 'Doctor', 'Engineer', 'Lawyer']\n['Lawyer', 'Engineer', 'Doctor', 'Designer', 'Architect', 'Accountant']\n```\n\n#### Concatenating Lists\nTwo or more lists can be concatenated using the '+' symbol. This will return a single list with two or more lists combined.\n\n```python\n#concatenating two lists\ntest_list1 = ['Engineer', 'Designer', 'Lawyer']\ntest_list2 = ['Architect', 'Doctor', 'Accountant']\ntest_list = test_list1 + test_list2\nprint(test_list)\n```\n\n__output:__\n```python\n['Engineer', 'Designer', 'Lawyer', 'Architect', 'Doctor', 'Accountant']\n```\n\n##### List Comprehensions\nList comprehension offers a convenient method of producing new lists. By performing an operation on each element of an existing list, these new lists are generated.\n\n```python\nnum = [1,2,3,4]\ncube = []\nfor x in num:\n\tcube.append(x**3)\nprint(cube)\n```\n\n__output:__\n```python\n[1, 8, 27, 64]\n```\n\nThe above traditional for-loop can be concisely written into a single line of code using list comprehensions.\n\n```python\nnum = [1,2,3,4]\ncube = [x**3 for x in num]\nprint(cube)\n```\n\n__output:__\n```python\n[1, 8, 27, 64]\n```\n\n#### Stacks & Queues Using Lists\nPython comes with a built-in data structure called a list. However, we can employ it to produce custom data structures. Stacks and queues are two extremely well-liked user-defined data structures created using lists.\n\n##### Stacks\nStacks are lists of elements where new elements are added at the start of the list or removed at the end of the list. Imagine it as a pile of books. You always work your way up the stack whenever you need to add or remove a book. It employs the straightforward Last-In-First-Out principle.\n\n```python\nstack = [1,2,3,4]\nstack.append(5)\nprint(stack)\nstack.pop()\nprint(stack)\n```\n\n__output:__\n```python\n[1, 2, 3, 4, 5]\n[1, 2, 3, 4]\n```\n\n##### Queue\nOn the other hand, a queue is a list of elements in which new elements are added to the end of the list and old elements are removed from the front of the list. It is comparable to standing in a line in the real world. The line gets shorter as those at the front of the line leave. It gets longer when a new person joins the queue from the back. It takes advantage of the First-In-First-Out principle.\n\n```python\nqueue = [1,2,3,4]\nqueue.append(5)\nprint(queue)\nqueue.pop(0)\nprint(queue)\n```\n\n__output:__\n```python\n[1, 2, 3, 4, 5]\n[2, 3, 4, 5]\n```\n\n### Data Structure #2: Tuples in Python\nAnother well-liked built-in data structure in Python is the tuple. These are quite similar to lists with one exception - their immutability. \nThis implies that a tuple cannot be modified or added to after it has been formed. Let's see how to create a tuple in Python and how to play with it below.\n\n#### Creating Tuples in Python\nYou can create tuples by enclosing data in parenthesis and separating each piece with a comma. You can create a tuple even if you write a number of items in a row without any parenthesis and assign them to a variable.\n\n```python\ncountry = ('india','canada','u.s.a')\nprint(type(country))\nprint(country)\ncurrency = (85, 'inr', 'usd', 'cad')\nprint(type(currency))\nprint(currency)\n\n<class 'tuple'>\n('india', 'canada', 'u.s.a')\n<class 'tuple'>\n(85, 'inr', 'usd', 'cad')\n```\n\nNow that we have created tuples let's see about their immutable nature.\n\n#### Immutability of Tuples\nImmutable in Python refers to something that cannot be changed after creation. The two types of objects in the Python programming language are mutable and immutable.\nLists, dictionaries, and sets are examples of mutable objects which can be altered after creation. We shall explore these in the following sections. In contrast, immutable objects include integers, floating-point numbers, boolean values, strings, and tuples. What, then, makes them unchangeable?\nEverything in Python is an object. As a result, we may check an object's memory address using the built-in id() method. This is known as the identity of the object. Let's make a list then locate the list and all of its components.\n\n```python\nthislist = [\"apple\", \"banana\", \"cherry\"]\nprint(id(thislist))\nprint(id(thislist[0]))\n```\n\n__output:__\n```python\n47251449707712\n47251450601840\n```\nYou can see that the list and its elements are stored in different parts of memory. We can change the value of a list's elements since we know that lists are mutable. Let's try that and watch how the location values change.\n\n```python\nthislist[0] = \"grape\"\nprint(id(this list))\nprint(id(thislist[0]))\n```\n\n__output:__\n```python\n47251449707712\n47251450602288\n```\n\nThe element's location changed, but the list's placement remained the same. It denotes the creation of a new object for the element and its saving in the list. The term \"mutable\" refers to this. An immutable object cannot change its state or contents after being created, although a mutable object may.\n\nTuples are called pseudo-immutable; though they are immutable they can contain mutable objects whose values can be modified.\n\n```python\nmytuple = (1,2,3,[4,5,6])\nprint(id(mytuple))\nprint(id(mytuple[-1]))\n```\n\n__output:__\n```python\n22916022675872\n22916023512128\n```\n\n```python\nmytuple[-1].append(7)\nprint(id(mytuple))\nprint(id(mytuple[-1]))\nprint(mytuple)\n```\n\n__output:__\n```python\n22916022675872\n22916023512128\n(1, 2, 3, [4, 5, 6, 7])\n```\n\nAs the above code exhibits, we can alter the values of immutable objects, i.e., the list contained within the tuple.\n\n#### Tuple Assignment and Changing Tuples Values\nWith tuple packing and unpacking, we can assign values to a tuple of elements from another tuple in a single line.\n\n```python\nmytuple = (\"apple\", \"banana\", \"cherry\")\na,b,c = mytuple\nprint(a)\nprint(b)\nprint(c)\n```\n\n__output:__\n```python\napple\nbanana\ncherry\n```\n\nAlthough tuple values cannot be modified, you can alter them by turning them into a list with list(). When you are finished with your data processing, you can use the tuple function to convert it back to a tuple().\n\n```python\nmytuple = (\"apple\", \"banana\", \"cherry\")\nconv_list = list(mytuple)\nprint(type(conv_list))\nconv_list.append(\"grape\")\nprint(conv_list)\ntuple_fruits = tuple(conv_list)\nprint(type(tuple_fruits))\nprint(tuple_fruits)\n```\n\n__output:__\n```\n<class 'list'>\n['apple', 'banana', 'cherry', 'grape']\n<class 'tuple'>\n('apple', 'banana', 'cherry', 'grape’)\n```\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3NYB2aT7Gq3kJRqScz4IPw","type":"Asset","createdAt":"2022-07-08T03:28:13.117Z","updatedAt":"2023-09-14T11:30:09.820Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3NYB2aT7Gq3kJRqScz4IPw/7478abbc77e49c6af713855f234d3e34/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"34zIQNVTXVHI5WguauMsWx","type":"Entry","createdAt":"2020-12-18T08:52:04.288Z","updatedAt":"2024-07-15T11:27:39.055Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":26,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Getting Started with Python","slug":"getting-started-with-python","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"sys":{"type":"Link","linkType":"Entry","id":"Caw9t2fdYN3diW6ITAg20"}}],"tags":["Python"],"creationDate":"2020-12-18","readTime":"15min","content":"This article will cover almost everything you need to get started with Python. Python has become one of the most popular programming languages and is used every day by programmers to do cool things like automate, build applications and websites like Instagram, and it is used in Artificial Intelligence (AI). \nNo one is too old or too young to learn Python. Python is very easy to learn.\n\n### Installing Python:\n1. Download Python from this link -> https://www.python.org/downloads/.\n2. Install after downloading the latest Python from the above link.\n3. Don't forget to click on check Add Python 3.x to PATH.\n\n### About IDEs:\n\nIDE stands for Integrated Development Environment. It enables programmers to combine different aspects of writing code. IDEs increase programmer’s productivity by simplifying common activities in a single application like editing source code, debugging and building executables. There are different IDEs available like PyCharm, VS Code, Sublime text, and IDLE (default).\n\n#### Why PyCharm and why it is better than other IDEs?\n\n1. The intelligent code editor provided by PyCharm enables programmers to write a high quality Python code.\n2. The editor enables programmers to read code easily through color schemes, and auto indents on new lines automatically.\n3.The smart code navigation option provided by PyCharm helps programmers to edit and improve the code quality without putting in extra time. It makes both local and global changes very quickly and efficiently.\n4. PyCharm comes with a local terminal which enables the programmers to continue coding and testing without leaving the IDE.\n\n### Setting up IDE for Python:\n1. Download [PyCharm from this link](https://www.jetbrains.com/pycharm/download/#section=windows).\n2. Install Pycharm.\n3. Click on the new Project.\n4. Make sure in Project Interpreter, the base interpreter is set to your installed python version.\n\n![Screenshot 2020-12-18 10:34:50](//images.ctfassets.net/piwi0eufbb2g/1wV1DfEV8hT5wDDyZj2DTV/4da57cec5900cac1f30d4f2151ea9378/Screenshot_2020-12-18_10_34_50.png)\n\nWriting First Python Program\n\n1. Right-click on the new project created.\n2. New -> Python File\n3. Give `<Filename>.py`\n4. Type print(‘This is my first python program’)\n5. Click on run\n\n![Screenshot 2020-12-18 10:35:51](//images.ctfassets.net/piwi0eufbb2g/1Dyo4GsyUZhRip5edJY73y/23cfe00eaccf612469264ab2904ab6f2/Screenshot_2020-12-18_10_35_51.png)\n\nPython executes the program line by line.\n\nFor reference,users can read documentation at: [Read Docs](https://docs.python.org/release/3.7.9/tutorial/index.html) and can also read sample codes here: [Samples](https://www.programiz.com/python-programming/examples)\n\n### Python Variables:\n\nVariables are used in programming languages to temporarily store data in a computer's memory.\nFor example:\n\n![Screenshot 2020-12-18 10:37:01](//images.ctfassets.net/piwi0eufbb2g/353KBMKnGCzDjuktxdkmx3/454676aeddbc4853c1583473aa3de5f2/Screenshot_2020-12-18_10_37_01.png)\n\nWhen Python interpreter executes this code, it will allocate some memory and thenstore the number 29 in the memory and attach 29 to the label age. \n\nInteger, float, string, and Boolean are the data types in Python.\n\n![Screenshot 2020-12-18 10:37:48](//images.ctfassets.net/piwi0eufbb2g/nFeimIQyg8S3JJYPhgVEJ/ef1843ecbc96877d6add45be82d67c10/Screenshot_2020-12-18_10_37_48.png)\n\n### PYTHON STRINGS:\nA string is a sequence of characters. To make a string, we may enclose a sequence of characters between single, double, or triple quotes. \nThus, 'Hello world', ' \"Hello \" ', \"what's \", '''today's \"action\" plan?''' are the examples of strings.\n\n```\nprint('Hello world')\nprint(\"What’s \")\nprint('''today's plan?''' )\n```\n\n![Screenshot 2020-12-18 10:38:40](//images.ctfassets.net/piwi0eufbb2g/7d4mD9wE1aKcFpbBtCUATb/e61ddd9a765d34a00eb9c149c71ed5b0/Screenshot_2020-12-18_10_38_40.png)\n\n### OPERATORS IN PYTHON\n#### RELATION OPERATORS\nThese operators are used to compare two expressions and returns either true or false. These are greater than (>), less than (<), equals to (==), greater than equal to (>=), less than equal to (<=), not equal to (! =), they can be used for any data types.\n\n![Screenshot 2020-12-18 10:39:32](//images.ctfassets.net/piwi0eufbb2g/407HxnRem5pjDqpWAZFlln/27be9c3a569080cfa0a6e4c83f86f0d1/Screenshot_2020-12-18_10_39_32.png)\n\n#### LOGICAL OPERATORS:\n\nThe logical operators not, and, and or are applied to logical operands true and false, also called Boolean values, and yield either true or false. Not is an unary operator it requires only one operand.\n\n*and operator – It returns true only when both the expressions are true else false.\n* or operator – It returns true if any one of the expressions is true else false.\n* not operator – It returns the opposite of the expression.\n\n![Screenshot 2020-12-18 10:40:22](//images.ctfassets.net/piwi0eufbb2g/6d5P3wcGfvG6bL2Quq3Svn/8dae71553bf9f529112a74f43e53dd67/Screenshot_2020-12-18_10_40_22.png)\n\n#### BITWISE OPERATORS\n\nBitwise operators are the operators that operate on integers interpreted as strings of binary digits 0 and 1, also called bits. \n\n- Bitwise and (&)\n- Bitwise or (|)\n- Bitwise complement (~)\n- Bitwise Exclusive to (^)\n- Left Shift (<<)\n- Right Shift (>>)\n\n### BUILT-IN FUNCTIONS\nBuilt-in functions are the predefined functions that are already available in Python.\n#### input() function:\n\nThe function input enables us to accept an input string from the user without evaluating its value. The function input continues to read input text from the user until it encounters a new line, for example:\n\n![Screenshot 2020-12-18 10:41:45](//images.ctfassets.net/piwi0eufbb2g/1PW2GbdDTIrH8AfZvB0jPz/561a646839d771020b204a4268d79d60/Screenshot_2020-12-18_10_41_45.png)\n\n#### eval() function:\nThis function is used to evaluate the value of the string.\n\n![Screenshot 2020-12-18 10:42:24](//images.ctfassets.net/piwi0eufbb2g/1nFikLmcT7D536zYKGlMJQ/2d0bdbe70974f0c2e87ca9d3d91ca744/Screenshot_2020-12-18_10_42_24.png)\n\n#### print() Function:\n\nprint() function enables us to produce output in Python. Print function can also have an escape sequence which can print different types of data at a time separating the values with a comma.\n\n![Screenshot 2020-12-18 10:42:59](//images.ctfassets.net/piwi0eufbb2g/2Hr4yvbGcRptANb9Bg0pq9/39db8912b78a16c7edfe309a976fc3b6/Screenshot_2020-12-18_10_42_59.png)\n\n#### Other functions:\n__type() Function:__ It returns the data type of the parameter.\n\n![Screenshot 2020-12-18 10:43:37](//images.ctfassets.net/piwi0eufbb2g/21w2aN0Mjnw17PjcJVBiuy/29709a67ace01dcf3905f830074eb4a4/Screenshot_2020-12-18_10_43_37.png)\n\n__max(), min() Function:__ It returns the maximum and minimum value of the data given.\n\n![Screenshot 2020-12-18 10:44:31](//images.ctfassets.net/piwi0eufbb2g/7HRLB4ZcZw0dpg8nDeBQy3/e4e652dbd0e8fc6d6241c013ec452759/Screenshot_2020-12-18_10_44_31.png)\n\n__round() Function:__ It rounds the value of the parameter and returns the  rounded value.\n\n![Screenshot 2020-12-18 10:45:21](//images.ctfassets.net/piwi0eufbb2g/63GkyF8v9j8Xb6o0GV9Ujq/d74a747800523ac66c1acd8d3187bb77/Screenshot_2020-12-18_10_45_21.png)\n\n__pow() Function:__ It takes two values, number and exponent, and returns number to the power of exponent.\n\n![Screenshot 2020-12-18 10:46:49](//images.ctfassets.net/piwi0eufbb2g/7iu4RXIjHDf0HBCbkFGQnH/9c013dac26c084558cd3399947a1a109/Screenshot_2020-12-18_10_46_49.png)\n\n[HERE IS A LIST OF OTHER BUILT-IN FUNCTIONS](https://docs.python.org/3/library/functions.html#float)\n\nTry it yourself:\n1. Create a variable name which will take the input from the user and print it.\n2. Print the maximum and minimum values out of four values.\n3. Input five values and print their respective data types.\n4. Input two numbers x and y and print x raised to power y.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3kNHPHf18iXXpDrqcCvljE"}}],"upvotes":25,"downvotes":0}},{"sys":{"type":"Link","linkType":"Entry","id":"6GBXhy7l8ghq5l4eIZSLDp"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7jXzj0Re46Izgnuy04I5X8","type":"Entry","createdAt":"2022-07-15T15:51:22.672Z","updatedAt":"2022-07-25T02:36:55.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":122,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","slug":"python-data-structures-strings","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"1XKgff9ovQ0Qb7cPbG37Un"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Python","Data Structures"],"creationDate":"2022-07-07","readTime":"10min","content":"Data structures are used to store and organize data efficiently. They allow you to quickly access and manipulate the data. Python includes many built-in data structures for easy data management.\nIn this article we will learn about one of Python's most important data structures: Strings. \n\nWorking on real-world projects will make you realize how significant strings are as a data type in Python. Since working with strings seems simple but solving problems is complex, the majority of problem statements in interviews and written examinations are based on string manipulation.\nIn this article we cover everything about strings.\n\n### Brief Overview of Python String Data Type\n\nStrings are a collection of Unicode characters that are used specifically in Python. A string is the language or text we use to communicate. However, machines can only read binary, they cannot comprehend text. As a result, ASCII numbers are initially generated from characters before being transformed to binary representation. However, ASCII is exclusively used for the English language, and when programming languages are used in other nations, they are translated to 16-bit characters known as Unicode.\n\n##### Creating Strings\n\nPython offers several methods for creating strings, including single, double, and triple quotes. When constructing a string, if the string contains any kind of quote, you should use a separate kind of quote in the declaration to prevent an error. Try the example below in any Python IDE or code editor for a better understanding.\n\n```python\ns = 'Good Morning' #single quotes\ns = 'It's been a great day' #syntax error (It confuses where string starts and ends)\ns = \"It's been a great day\" #correct way\ns = '''Good Morning''' #multi-line strings\n```\n\nWhen declaring or referencing a lengthy paragraph use triple quotes. Any other data type can be declared as a string or converted using an internal function.\n\n```python\na = 99 #int\nprint(str(a)) #int to str\n```\n\n##### Accessing Substring from String\n\nTo address a specific use case, it may occasionally be essential to access portions of a string. We shall discuss indexing and slicing, which enable us to extract a specific section of the text as output.\n\n#### Indexing\n\nIndexing a string with zeros is the same as indexing an array. Simply put, the zero indexes in a string represent the first character, and as the index rises, the string advances. Positive and negative indexing are the two categories of indexing in Python.\n\n##### Positive Indexing\n\nPositive indexing is moving from zero to the end length of a string. It is also known as zero-based indexing.\n\n```python\ns = 'GoodMorning' \nprint(s[0])  \nprint(s[2])  \nprint(s[4])  \nprint(s[len(s)-1]) \nprint(len(s))\n```\n\n__output:__\n```python\nG\no\nM\ng\n11\n```\n\n__Note__: If access s(11), program returns a Index error\n\n##### Negative Indexing\n\nAccessing string elements using a negative index means going backward in time. It usually  takes a long time to access the last character in a string if we use positive indexing since we have to calculate the length of the string and then take one off of it. In this situation, we can just use the negative indexing.\n\n```python\ns = 'GoodMorning' \nprint(s[-1])  \nprint(s[-2])\n```\n__output:__\n```python\ng\nn\n```\n\n##### Slicing\nThe concept of slicing, which is accomplished using the colon operator, comes into play when we have long strings, such as sentences or paragraphs, and we want to access specific pieces, like whole words, but we cannot do so merely using indexing. To ensure that the output is a portion of the string from a start index to an end index less one, we must specify the starting index and end index in square brackets that are separated by colons.\n\n```python\ns = 'Good Morning' \nprint(s[1:4])\n```\n\n__output:__\n```python\nood\n```\n\nStart with the first index in the example above and retrieve the character all the way to the third index. Now that there are various slicing variations, let's examine them practically using the code sample below.\n\n```python\ns = 'GoodMorning' \nprint(s[1:])  \nprint(s[:4])\nprint(s[:])\nprint(s[0:8:3])\nprint(s[::-1])\n```\n\n__output:__\n```python\noodMorning\t\t#It will print the entire string starting from index 1\nGood\t\t\t#It will print the entire string starting from index 0 to 3\nGoodMorning\t\t#It will print the entire string \nGdr\t\t\t\t#It will print zero index and skip two index and take third index till eighth index\ngninroMdooG #It will print the string in reverse order\n```\n\n### Editing and Deleting Python Strings\n\nSince strings in Python are immutable data types, attempting to change one will result in a type error. The existing string cannot be changed or added to, but it can be assigned to a separate variable to produce a new string. Let's examine the practical effects of deleting and altering strings to see whether we experience any errors.\n\nSince strings are immutable, we cannot directly reassign the value of the particular string in the below snippet.\n\n```python\ns = 'GoodMorning' \ns[0] = \"M\" \t\t #This operation is not allowed and it will return not support Item assignment error\n\n```\n\nInstead, the below combination will work\n\n```python\ns = 'GoodMorning' \na = \"M\" + s[1:]\t \nprint(a) \n```\n\n__output:__\n```python\nMoodMorning\n```\n\nDeleting the strings won't work well and the below statements will generate errors saying we can't delete the string.\n\n```python\ndel s[0]    \ndel s[:3:2] \n```\n\nIt is crucial to comprehend that strings cannot be changed; nothing can be added or removed from an existing string.\n\n### Operations on Python String\n\n#### Arithmetic Operations\n\n##### Addition(+)\n\nConcatenation, as it is also known, allows us to link any amount of strings by using the addition operator.\n\n```python\ns = \"Good\" + \"-\" + \"Morning\"\nprint(s) \n```\n__output:__\n```python\nGood-Morning\n```\n\n##### Multiplication(*)\n\nTo repeat a certain string before the multiplication operator any number of times is known as string repetition. When we want a pattern, we use it.\n\n```python\ns = \"Good\" \nprint(s*3) \n```\n__output:__\n```python\nGoodGoodGood\n```\n\n#### Relational Operations \n\nRelational operators display the relationship between two terms and determine whether a particular condition is true or false, producing a boolean result.\n```python\nprint(\"Hello\" == \"World\")  \nprint(\"Hello\" != \"World\")  \n```\n__output:__\n```python\nFalse\nTrue\n```\n\nWhen we apply the larger than and less than operators the situation becomes more intriguing.\n```python\nprint(\"Mumbai\" > \"Pune\")  \nprint(\"Goa\" < \"Indore\") \n```\n\n__output:__\n```python\nFalse\nTrue\n````\n\nYou might be wondering how it compares two strings. As a result, it lexicographically compares a string. As P follows M in the alphabetical order in the first case, the statement is false. Lowercase characters are placed after uppercase because occasionally people mistake the two case types.\n\n#### Logical Operations\nWhen you use the AND, OR, and NOT logical operators on strings, Python returns false for empty strings and true for non-empty strings.\n\n```python\nprint(\"Hello\" and \"World\") #True and True -> True (O/P -> World)\nprint(\"\" and \"World\") #False and True -> False (O/P -> \"\")\nprint(\"\" or \"World\") #False OR True -> True (O/P -> \"World\")\nprint(not \"Hello\") #opposite of True -> False\nprint(not \"\") #True\n```\n\n##### Loops\nSlicing allows us to loop over strings starting at any index. To access distinct characters or create a pattern in a string, we can use both a where and a for loop.\n\n```python\ns = 'GoodMorning' \nfor i in s:\n\tprint(i)\n```\n\n__output:__\n```python\nG\no\no\nd\nM\no\nr\nn\ni\nn\ng\n```\n\n#### Membership Operators\nPython's in and NOT in membership operators are used to determine whether any element is present in any sequence data structure.\n\n```python\ns = 'GoodMorning' \nif 'M' in s:\n\tprint('true')\n```\n__output:__\n```python\ntrue\n```\n\n### Python String Functions\nThe most important parts of a string are string functions which you use everywhere whenever you build any project. Now we will study all-important string functions which are frequently used.\nCommon Functions:\n\nThese are the same functions that are available for all other iterator data types, including list, tuple, set, and string.\n\n1. length - It provides the string's length.\n2. minimum - This function returns the smallest character in a string, as determined by ASCII.\n3. maximum - The largest character found in the string, as determined by ASCII, is provided by the third option, maximum.\n4. sorted - The string is sorted in either ascending or descending order using the ASCII character sequence. This function always returns a list of characters as its result.\n\n```python\ns = 'GoodMorning' \nprint(len(s))\nprint(min(s))\nprint(max(s))\nprint(sorted(s))\nprint(sorted(s,reverse=True))\n```\n\n__output:__\n```python\n11\nG\nr\n['G', 'M', 'd', 'g', 'i', 'n', 'n', 'o', 'o', 'o', 'r']\n['r', 'o', 'o', 'o', 'n', 'n', 'i', 'g', 'd', 'M', 'G']\n```\n\n#### Some Specific Purpose Functions in Strings\nThe functions we'll look at here only work with strings.\n\n##### Title or capitalize\nThe title function capitalizes the first letter of each word, whereas the capitalize function capitalizes the first letter of a string.\n```python\ns = \"its raining outside\"\nprint(s.capitalize()) #O/P -> Its raining outside\nprint(s.title()) \t #O/P -> Its Raining Outside\n```\n\n##### Upper / lower / swap case\nIn string each character is converted in the upper function to lowercase characters. Swap case changes an upper to a lower case character, and vice versa.\n```python\ns = \"Its Raining Outside\"\nprint(s.upper()) #O/P -> ITS RAINING OUTSIDE\nprint(s.lower()) #O/P -> its raining outside\nprint(s.swapcase()) #O/P -> iTS rAINING oUTSIDE\n```\n\n##### Count\nIt provides the number of any substrings that are present in a string. It outputs 0 if the substring is missing from the string. It is used to determine how often a given substring occurs in a string.\n```python\ns = \"Its Raining Outside\"\nprint(s.count(\"i\")) #3\nprint(s.count(\"ing\")) #1\n```\n\n###### Find / Index\nBoth functions operate in exactly the same manner. Both locate the position of a substring within a string. The sole distinction between the two functions is that while index gives an error when the substring is absent, string find produces a negative value when this occurs.\n```python\ns = \"Its Raining Outside\"\nprint(s.find(\"ing\")) #8\nprint(s.index(\"ing\")) #8\nprint(s.find(\"down\")) #-1\nprint(s.index(\"down\")) #error\n```\n\n### Conclusion\nIn this article we have learned about string literals in Python. We have started by getting ideas about string and covered how to use, create, and play with string and string functions. Hope you enjoyed it. \n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3NYB2aT7Gq3kJRqScz4IPw","type":"Asset","createdAt":"2022-07-08T03:28:13.117Z","updatedAt":"2023-09-14T11:30:09.820Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3NYB2aT7Gq3kJRqScz4IPw/7478abbc77e49c6af713855f234d3e34/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"34zIQNVTXVHI5WguauMsWx","type":"Entry","createdAt":"2020-12-18T08:52:04.288Z","updatedAt":"2024-07-15T11:27:39.055Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":26,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Getting Started with Python","slug":"getting-started-with-python","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"sys":{"type":"Link","linkType":"Entry","id":"Caw9t2fdYN3diW6ITAg20"}}],"tags":["Python"],"creationDate":"2020-12-18","readTime":"15min","content":"This article will cover almost everything you need to get started with Python. Python has become one of the most popular programming languages and is used every day by programmers to do cool things like automate, build applications and websites like Instagram, and it is used in Artificial Intelligence (AI). \nNo one is too old or too young to learn Python. Python is very easy to learn.\n\n### Installing Python:\n1. Download Python from this link -> https://www.python.org/downloads/.\n2. Install after downloading the latest Python from the above link.\n3. Don't forget to click on check Add Python 3.x to PATH.\n\n### About IDEs:\n\nIDE stands for Integrated Development Environment. It enables programmers to combine different aspects of writing code. IDEs increase programmer’s productivity by simplifying common activities in a single application like editing source code, debugging and building executables. There are different IDEs available like PyCharm, VS Code, Sublime text, and IDLE (default).\n\n#### Why PyCharm and why it is better than other IDEs?\n\n1. The intelligent code editor provided by PyCharm enables programmers to write a high quality Python code.\n2. The editor enables programmers to read code easily through color schemes, and auto indents on new lines automatically.\n3.The smart code navigation option provided by PyCharm helps programmers to edit and improve the code quality without putting in extra time. It makes both local and global changes very quickly and efficiently.\n4. PyCharm comes with a local terminal which enables the programmers to continue coding and testing without leaving the IDE.\n\n### Setting up IDE for Python:\n1. Download [PyCharm from this link](https://www.jetbrains.com/pycharm/download/#section=windows).\n2. Install Pycharm.\n3. Click on the new Project.\n4. Make sure in Project Interpreter, the base interpreter is set to your installed python version.\n\n![Screenshot 2020-12-18 10:34:50](//images.ctfassets.net/piwi0eufbb2g/1wV1DfEV8hT5wDDyZj2DTV/4da57cec5900cac1f30d4f2151ea9378/Screenshot_2020-12-18_10_34_50.png)\n\nWriting First Python Program\n\n1. Right-click on the new project created.\n2. New -> Python File\n3. Give `<Filename>.py`\n4. Type print(‘This is my first python program’)\n5. Click on run\n\n![Screenshot 2020-12-18 10:35:51](//images.ctfassets.net/piwi0eufbb2g/1Dyo4GsyUZhRip5edJY73y/23cfe00eaccf612469264ab2904ab6f2/Screenshot_2020-12-18_10_35_51.png)\n\nPython executes the program line by line.\n\nFor reference,users can read documentation at: [Read Docs](https://docs.python.org/release/3.7.9/tutorial/index.html) and can also read sample codes here: [Samples](https://www.programiz.com/python-programming/examples)\n\n### Python Variables:\n\nVariables are used in programming languages to temporarily store data in a computer's memory.\nFor example:\n\n![Screenshot 2020-12-18 10:37:01](//images.ctfassets.net/piwi0eufbb2g/353KBMKnGCzDjuktxdkmx3/454676aeddbc4853c1583473aa3de5f2/Screenshot_2020-12-18_10_37_01.png)\n\nWhen Python interpreter executes this code, it will allocate some memory and thenstore the number 29 in the memory and attach 29 to the label age. \n\nInteger, float, string, and Boolean are the data types in Python.\n\n![Screenshot 2020-12-18 10:37:48](//images.ctfassets.net/piwi0eufbb2g/nFeimIQyg8S3JJYPhgVEJ/ef1843ecbc96877d6add45be82d67c10/Screenshot_2020-12-18_10_37_48.png)\n\n### PYTHON STRINGS:\nA string is a sequence of characters. To make a string, we may enclose a sequence of characters between single, double, or triple quotes. \nThus, 'Hello world', ' \"Hello \" ', \"what's \", '''today's \"action\" plan?''' are the examples of strings.\n\n```\nprint('Hello world')\nprint(\"What’s \")\nprint('''today's plan?''' )\n```\n\n![Screenshot 2020-12-18 10:38:40](//images.ctfassets.net/piwi0eufbb2g/7d4mD9wE1aKcFpbBtCUATb/e61ddd9a765d34a00eb9c149c71ed5b0/Screenshot_2020-12-18_10_38_40.png)\n\n### OPERATORS IN PYTHON\n#### RELATION OPERATORS\nThese operators are used to compare two expressions and returns either true or false. These are greater than (>), less than (<), equals to (==), greater than equal to (>=), less than equal to (<=), not equal to (! =), they can be used for any data types.\n\n![Screenshot 2020-12-18 10:39:32](//images.ctfassets.net/piwi0eufbb2g/407HxnRem5pjDqpWAZFlln/27be9c3a569080cfa0a6e4c83f86f0d1/Screenshot_2020-12-18_10_39_32.png)\n\n#### LOGICAL OPERATORS:\n\nThe logical operators not, and, and or are applied to logical operands true and false, also called Boolean values, and yield either true or false. Not is an unary operator it requires only one operand.\n\n*and operator – It returns true only when both the expressions are true else false.\n* or operator – It returns true if any one of the expressions is true else false.\n* not operator – It returns the opposite of the expression.\n\n![Screenshot 2020-12-18 10:40:22](//images.ctfassets.net/piwi0eufbb2g/6d5P3wcGfvG6bL2Quq3Svn/8dae71553bf9f529112a74f43e53dd67/Screenshot_2020-12-18_10_40_22.png)\n\n#### BITWISE OPERATORS\n\nBitwise operators are the operators that operate on integers interpreted as strings of binary digits 0 and 1, also called bits. \n\n- Bitwise and (&)\n- Bitwise or (|)\n- Bitwise complement (~)\n- Bitwise Exclusive to (^)\n- Left Shift (<<)\n- Right Shift (>>)\n\n### BUILT-IN FUNCTIONS\nBuilt-in functions are the predefined functions that are already available in Python.\n#### input() function:\n\nThe function input enables us to accept an input string from the user without evaluating its value. The function input continues to read input text from the user until it encounters a new line, for example:\n\n![Screenshot 2020-12-18 10:41:45](//images.ctfassets.net/piwi0eufbb2g/1PW2GbdDTIrH8AfZvB0jPz/561a646839d771020b204a4268d79d60/Screenshot_2020-12-18_10_41_45.png)\n\n#### eval() function:\nThis function is used to evaluate the value of the string.\n\n![Screenshot 2020-12-18 10:42:24](//images.ctfassets.net/piwi0eufbb2g/1nFikLmcT7D536zYKGlMJQ/2d0bdbe70974f0c2e87ca9d3d91ca744/Screenshot_2020-12-18_10_42_24.png)\n\n#### print() Function:\n\nprint() function enables us to produce output in Python. Print function can also have an escape sequence which can print different types of data at a time separating the values with a comma.\n\n![Screenshot 2020-12-18 10:42:59](//images.ctfassets.net/piwi0eufbb2g/2Hr4yvbGcRptANb9Bg0pq9/39db8912b78a16c7edfe309a976fc3b6/Screenshot_2020-12-18_10_42_59.png)\n\n#### Other functions:\n__type() Function:__ It returns the data type of the parameter.\n\n![Screenshot 2020-12-18 10:43:37](//images.ctfassets.net/piwi0eufbb2g/21w2aN0Mjnw17PjcJVBiuy/29709a67ace01dcf3905f830074eb4a4/Screenshot_2020-12-18_10_43_37.png)\n\n__max(), min() Function:__ It returns the maximum and minimum value of the data given.\n\n![Screenshot 2020-12-18 10:44:31](//images.ctfassets.net/piwi0eufbb2g/7HRLB4ZcZw0dpg8nDeBQy3/e4e652dbd0e8fc6d6241c013ec452759/Screenshot_2020-12-18_10_44_31.png)\n\n__round() Function:__ It rounds the value of the parameter and returns the  rounded value.\n\n![Screenshot 2020-12-18 10:45:21](//images.ctfassets.net/piwi0eufbb2g/63GkyF8v9j8Xb6o0GV9Ujq/d74a747800523ac66c1acd8d3187bb77/Screenshot_2020-12-18_10_45_21.png)\n\n__pow() Function:__ It takes two values, number and exponent, and returns number to the power of exponent.\n\n![Screenshot 2020-12-18 10:46:49](//images.ctfassets.net/piwi0eufbb2g/7iu4RXIjHDf0HBCbkFGQnH/9c013dac26c084558cd3399947a1a109/Screenshot_2020-12-18_10_46_49.png)\n\n[HERE IS A LIST OF OTHER BUILT-IN FUNCTIONS](https://docs.python.org/3/library/functions.html#float)\n\nTry it yourself:\n1. Create a variable name which will take the input from the user and print it.\n2. Print the maximum and minimum values out of four values.\n3. Input five values and print their respective data types.\n4. Input two numbers x and y and print x raised to power y.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3kNHPHf18iXXpDrqcCvljE"}}],"upvotes":25,"downvotes":0}},{"sys":{"type":"Link","linkType":"Entry","id":"79Q3wxU7N1THUOilI7RUtq"}},{"sys":{"type":"Link","linkType":"Entry","id":"6GBXhy7l8ghq5l4eIZSLDp"}}],"openExternalLinksInNewTab":true}}],"openExternalLinksInNewTab":true}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1JVIxb4EpfhK6ael92fX17","type":"Entry","createdAt":"2019-12-18T08:41:46.690Z","updatedAt":"2024-07-19T04:06:02.154Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":97,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Understanding the Voice of the Customer: An application of Joint Topic-Sentiment Model","type":"Article","trackCategory":["Data Science"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"53oKQPGiJK8wNDULvktVy3","type":"Entry","createdAt":"2019-08-27T12:33:19.508Z","updatedAt":"2019-08-27T12:33:19.508Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Data Analysis & Pattern Matching","trackParent":"Data Science"}}],"tags":["AI","Topic Modeling","Sentiment Analysis"],"creationDate":"2019-12-17","readTime":"13 - 15 mins","content":"With the rise of Web 1.0 and Web 2.0, technology has brought the world into the palm of our hands. We the consumers have a plethora of options in almost every domain of needs – e-commerce, health care, finance and many more. Hence, it has become very critical for providers to receive feedback from customers to make their experience better and achieve customer loyalty. Every day we express our likes, dislikes, and opinions on different social media platforms, websites, and feedback channels. In traditional quality improvement efforts, companies use root cause analysis and data analytics tools. Recently there have been some developments around using topic modeling, sentiment analysis, and opinion mining to extract hidden information from customer feedback data. However, these methods fail to capture customers’ perceptions at a granular level. Joint topic-sentiment models can offer that which is lacked by those traditional methods.\n\n![Screenshot from 2019-12-18 10-26-55](//images.ctfassets.net/piwi0eufbb2g/19AC7nkQvaOO3GEqTM3RBa/a7497d19a9027e24bb4168fd61bf893f/Screenshot_from_2019-12-18_10-26-55.png)\nFigure 1: Sample Output from typical Topic Models and Sentiment Analysis\n\n![Screenshot from 2019-12-18 10-26-59](//images.ctfassets.net/piwi0eufbb2g/2LYB0dDonsBYzEdWFm0OLo/286e231d6ced70d82082f59cac0becf4/Screenshot_from_2019-12-18_10-26-59.png)\nFigure 2: Expected Output from Joint Topic-Sentiment Model\n\n## How Topic Modeling Works\nTopic modeling is an unsupervised natural language processing (NLP) technique that learns latent semantic topical representation from text corpus. Topic models use co-occurrences of words in different texts to capture the relationship between words. They learn a probabilistic representation of topics in terms of words and probabilistic representation of text data in terms of topics. For example, from a corpus of news text data, topic model can identify key topics like “sports”, “politics”, “entertainment”, “international” etc. Each topic is characterized by a set of words with corresponding weights. The topic “sports” will have higher weight for sports-related words like – “baseball”, “soccer” etc. than other words. Similarly, “politics” will have higher weight on “policy”, “government”, “election” etc.\n\n![Screenshot from 2019-12-18 10-29-59](//images.ctfassets.net/piwi0eufbb2g/6TyHlDXIVU2WrkXfv5PRHo/3a5ed374c3f79da9b51228e4b99f485d/Screenshot_from_2019-12-18_10-29-59.png)\nFigure 3a: Sample Topic Model Output for Text 1\n\n![Screenshot from 2019-12-18 10-30-48](//images.ctfassets.net/piwi0eufbb2g/1aVlS8f4Y4lFOzL68y9uzm/ee9527e6aa35cbdb2785d9559d2812e0/Screenshot_from_2019-12-18_10-30-48.png)\nFigure 3b: Sample Topic Model Output for Text 2\n\nIn the above two images, we can see how a topic model can assign different topics into two different texts based on the words they contain.\n\n## Sentiment Analysis\nSentiment analysis, aka polarity identification, emotion classification is the task for understanding opinions expressed in a text. In sentiment analysis we typically classify a text in “positive”, “neutral” or “negative” classes. Sentiment analysis can be performed in both  a supervised and unsupervised manner. In supervised learning, the luxury of having text data with manual labels can be used to calculate sentiment classes for unseen data. In unsupervised learning, however, we use external knowledge in terms of sentiment word lexicon and linguistic knowledge to calculate sentiment.\nFor example, given the text “he is an excellent writer”, unsupervised methods can classify it as “positive”.\n\n![Screenshot from 2019-12-18 10-36-01](//images.ctfassets.net/piwi0eufbb2g/3EC1KvouZK5vtNGpOlZ64g/34e9ebfdc9304ed80c30340b6e724bc8/Screenshot_from_2019-12-18_10-36-01.png)\nFigure 4: Sample Word Sentiment Lexicon (1 means positive, 0 means negative)\n\n## Joint Topic-Sentiment Model\nJoint topic-sentiment model or, JST, is a class of unsupervised techniques that use the best of both worlds. Like traditional topic models (LDA and co.), JST models use a probabilistic graphical generative approach. Particularly in JST, we assume – \nEvery document is a mixture of topic and sentiment\nEvery topic can be represented as a mixture of words and sentiment\nIn a typical generative model, we sample the variables (the latent attributes we are trying to learn – topics, topic-sentiment, etc.) and based on the probabilities of the samples, we calculate the likelihood of generating a text by multiplying the likely values of all the words contained in the text. During the learning process, we maximize the likelihood value and achieve the optimal values of the latent parameters. Different techniques like EM algorithm, Variational Inference, and Gibbs Sampling are used for the training process.\nIn JST, latent (learnable) parameters are topic distribution for each sentiment class for each document, sentiment distribution for each document and word distribution for each topic-sentiment pair. In contrast, LDA (Latent Dirichlet Allocation) learns only topic distribution for each document and word distribution for each topic.\n\n![Screenshot from 2019-12-18 10-36-09](//images.ctfassets.net/piwi0eufbb2g/2eiC0Hknqdoaj9kB0fnDfw/8eb74a5c7a6fea6c496ea0b89512993a/Screenshot_from_2019-12-18_10-36-09.png)\nFigure 5a: LDA Model\n\n![Screenshot from 2019-12-18 10-36-10](//images.ctfassets.net/piwi0eufbb2g/7t9wma92440LPFJUbhb4lA/3b9c3d0f13f70a4e5509ca56632c12a6/Screenshot_from_2019-12-18_10-36-10.png)\nFigure 5b: JST Model\n\nIn LDA (Figure 5a) θ is the topic distribution for each document; φ is the topic distribution for each document; T is the number of topics; D is the number of documents; α, β are additional hyperparameters.\nIn JST (Figure 5b) θ is the topic distribution for each sentiment class and document; φ is the word distribution for each topic-sentiment pair; π is the sentiment distribution for each document; α, β, γ, and λ are hyperparameters.\nThe expected output from the JST model is – \n\n![Screenshot from 2019-12-18 10-36-13](//images.ctfassets.net/piwi0eufbb2g/7yfyhHspji07uGlegicGH1/cb6600c8874f4b4d348e034e36e3afbb/Screenshot_from_2019-12-18_10-36-13.png)\nFigure 6: JST Output \n\nFrom the above output, we can extract the key areas (“camera” and “price”) where the customer is having a positive opinion and also the key pain point areas (“display”) with a probability of 60%. Additionally, the model was also able to identify the overall “positive” sentiment with 65% probability. This information can be leveraged to understand the user’s preference and relative importance placed on different features of a product/service. This will allow companies to cater to personalized requests and help them to engage their customers better.\n\n__Reference__\nhttp://www.jmlr.org/papers/volume3/blei03a/blei03a.pdf\n[A Comparative Study of Bayesian Models for Unsupervised Sentiment Detection](https://www.researchgate.net/publication/47454505_oroopenacuk_A_Comparative_Study_of_Bayesian_Models_for_Unsupervised_Sentiment_Detection)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"25IGVOZ5BEPsskug7znVSS","type":"Asset","createdAt":"2019-12-18T08:25:08.779Z","updatedAt":"2023-09-08T07:03:19.095Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"locale":"en-US"},"fields":{"title":"man-with-headphones-facing-computer-monitor-845451","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/25IGVOZ5BEPsskug7znVSS/0193b9d63fb7eabac8f1f891e10172b0/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"26YGMSUIj6nj3lzQPhM1HM","type":"Entry","createdAt":"2019-12-17T10:05:01.265Z","updatedAt":"2019-12-17T10:05:01.265Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Ayan Sengupta","tcHandle":"ayan007"}}],"upvotes":3,"downvotes":2}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"PUWESKbtUNYvThmqPuxbB","type":"Entry","createdAt":"2023-09-14T05:53:41.324Z","updatedAt":"2024-07-18T11:01:42.814Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":32,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Unlocking the Potential of Figma: Answering the 7 Most Common Questions about this Cloud-based Design Tool","slug":"unlocking-the-potential-of-figma-answering-the-7-most-common-questions-about","type":"Article","trackCategory":["Design"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5W8yVIchiseIGTWrWKXN57","type":"Entry","createdAt":"2019-09-18T07:36:54.570Z","updatedAt":"2023-09-06T19:01:10.075Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Design"}}],"tags":["web design","UI","UX"],"creationDate":"2023-09-14","readTime":"10min","content":"In today's fast-paced digital world, a design tool that can keep up with efficiency, collaboration, and scalability demands is a must-have. Figma is one tool that has been making waves in the design industry. But before diving into the seven most common questions about Figma, let's first take a step back and understand what it is exactly.\n\nFigma is a widely acclaimed design tool renowned for its prowess in creating and prototyping user interfaces. It enables seamless real-time collaboration among teams and offers comprehensive support for every stage of the design process, from wireframes to mockups and interactive prototypes. One of its key features is its cloud-based, browser-based interface, which eliminates the need for additional software installations and makes it easy for both remote and in-house teams. Additionally, Figma offers version control, design handoff, and integration with other tools, making it a popular choice among digital product designers.\n\n## 1. How does Figma handle team collaboration and version control?\n\n**Example: I am working on a design project with a remote team; how can we use Figma to collaborate and keep track of changes?**\n\nFigma allows real-time collaboration and version control through \"teams\" and \"projects.\" Within a team, multiple users can work on a single design file simultaneously, with changes being synced and visible to all members in real-time. Figma also allows for \"comments\" and \"mentions\" to facilitate communication and feedback within the design process.\n\nRegarding version control, Figma automatically saves file versions as changes are made, allowing users to revert to previous iterations if needed swiftly. It also offers the option to \"lock\" specific frames or elements to prevent accidental changes and \"clone\" a file to create a new version with all the changes saved on the original file. Additionally, Figma allows for file access permissions for specific team members, ensuring that only those who need to access a file can do so. This way, it guarantees that all team members are working on the latest version of the design and keep track of changes made by each team member.\n![1](//images.ctfassets.net/piwi0eufbb2g/3VlY7oS5cexp7qnjRUiNmg/4ade250debda6d85705aa48a9dcce7b3/1.png)\n![2](//images.ctfassets.net/piwi0eufbb2g/1dp4vQ6E5CY4daLevGiWyD/38b5272e4bc2a823f948fce3478d23b0/2.png)\n## 2. Can Figma be used to create web and mobile app designs?\n**Example: I am a designer and want to design web and mobile apps. Is Figma a suitable tool for this?**\n\nYes, Figma can be used for creating designs for both web and mobile apps. No doubt, it has a wide range of features and tools that support the design process for both web and mobile platforms. Figma allows you to design layouts, create wireframes, and develop high-fidelity mockups for both web and mobile. It also offers a variety of pre-built UI elements and components that can be used for web and mobile design. Additionally, Figma allows you to create custom UI elements and reusable components to design a consistent look and feel across all platforms.\n\nMoreover, Figma supports responsive design, allowing you to create designs that adapt to different screen sizes and orientations. Artboards can be resized from desktop to mobile format, and the designed content automatically adjusts responsively. This feature ensures that your designs are well-optimized for various devices, providing a seamless user experience across different platforms.\n\n## 3. What are some popular integrations for Figma?\n\n**Example: I want to integrate Figma with my project management tool; what are some popular options?**\n\nFigma offers various integrations with popular project management, development, and collaboration tools. Some of the popular integrations include:\n\n1.  **Jira**: Seamlessly integrate design files with Jira to facilitate developer handoff and project tracking.\n\n2.  **Trello**: Integrate design files into Trello boards for effective project management and task tracking.\n\n3.  **Slack**: Receive real-time notifications and updates on design changes directly to your Slack channel.\n\n4.  **Notion**: Connect Figma with Notion, an all-in-one workspace for notes, tasks, and collaboration.\n\n5.  **Microsoft Teams**: Collaborate efficiently by integrating Figma with Microsoft Teams, a famous team communication platform.\n\n6.  **GitHub**: Integrate Figma with GitHub to streamline design collaboration with developers.\n\n![3](//images.ctfassets.net/piwi0eufbb2g/4cKyhgd8T1jQjzklv0J8Nw/2a540592bb471bb9845d7f8f77a4c8f6/3.png)\nPlease note that the availability of integrations may vary based on your Figma plan and the developer's ongoing efforts to enhance Figma's integration capabilities. For a comprehensive list of Figma integrations, you can visit Figma's official website: [Figma Product Integrations](https://www.figma.com/product-integrations/)\n\nIntegrating Figma with these popular tools can streamline the design process, improve collaboration, and increase efficiency across your team.\n\n## 4. Can Figma be used for creating animations and interactive prototypes?\n\n**Example: I want to create an interactive prototype for a web app. Is Figma a suitable tool for this?**\n\nYes, Figma can be used for creating animations and interactive prototypes. Figma incorporates an integrated prototyping feature that empowers you to craft interactive mockups of your designs. You can use this feature to create animations, transitions, and interactions, to create a realistic and engaging prototype of your web or mobile app.\n\nThe prototyping feature allows you to create links between frames and design elements to simulate navigation and user flow. You can also set triggers and actions to create animations, hover effects, and other interactive features that affect the final product. Additionally, Figma allows you to test your prototypes on different devices, including web and mobile, and share them with others for feedback.\n![4](//images.ctfassets.net/piwi0eufbb2g/2QUrH4SEclCJOJLb29OBYj/40b596c696e26aa349119c88ea0a479f/4.png)\nFigma is a highly suitable tool for designing animations and interactive prototypes for web and mobile applications. Figma provides an array of features and tools that support the prototyping process.\n\n## 5. How does Figma handle design assets management?\n\n**Example: I want to store and organize my design assets; how does Figma handle this?**\n\nFigma has a variety of features that enable you to store and organize your design assets easily:\n\n1. **Components:** Figma allows you to create reusable components, which can be used across different design files. This makes it easy to ensure consistency across your designs and also makes it easy to update all instances of a component when needed.\n\n2. **Libraries:** Figma allows you to create and share libraries of design elements, symbols, and styles across your team. This feature allows for easy organization and management of design assets.\n\n3. **Plugins:** Figma also has many plugins to help you manage and organize your design assets. For example, some plugins allow you to automatically generate a style guide from your design or plugins that will enable you to export design assets to different file formats easily.\n\n4. **File Management:** Figma lets you quickly move, copy, and archive files to organize your design assets. You can create folders, add labels, and share files with specific team members or stakeholders.\n\nFigma has various features that allow you to easily store and organize your design assets and ensure consistency across your designs. This feature will enable designers to control their assets better and keep them organized in one place.\n\n## **6. How to share the design in Figma with clients or stakeholders?**\n\n**Example: I want to share my designs with clients and stakeholders; how does Figma facilitate this process?**\n\nFigma offers three primary methods to share designs with clients or stakeholders:\n\n1.  **Share link**: Easily share a link to your Figma design file with clients or stakeholders. They can view the entire design in a web browser without needing a Figma account. Furthermore, you have the flexibility to set permissions, allowing you to control whether they can view only or have edit access to the file. This method is ideal for showcasing the entire design and giving stakeholders an overview of the project.\n![5](//images.ctfassets.net/piwi0eufbb2g/6wUhr1oU2x4hCmJ936Ofkr/3adb63b709bbc2e78ef3684a07cc03b7/5.png)\n2.  **Prototype sharing or Presentation mode**: Figma's Presentation mode is explicitly designed for designers to showcase their prototypes in a full-screen view. During the presentation, designers can add comments and notes to specific parts of the design, guiding stakeholders' attention to crucial aspects. This enables real-time discussions and feedback.\n![6.1](//images.ctfassets.net/piwi0eufbb2g/6RUXptGgzbZpLkSagslrqC/4f009a483e77d3d755fb3bcfcf4d1921/6.1.png)\n![6.2](//images.ctfassets.net/piwi0eufbb2g/488ZdpHLNbX8TJZ0qkFd8W/d9aee4f1dc10706caf9a6073db56d1bf/6.2.png)\n3.  **Export options**: Figma provides various export options, allowing you to generate downloadable files in different formats, such as PDF, PNG, or SVG. This is useful for sharing static representations of the design, which can be easily shared via email or other communication channels.\n\n![7](//images.ctfassets.net/piwi0eufbb2g/442JKj6hmOY4GlRcEpKjAU/1094c07fd2de02153c45a711c06ced00/7.png)\nBy utilizing these sharing options in Figma, you can effectively collaborate with clients and stakeholders, gather feedback, and ensure everyone involved is on the same page throughout the design process.\n\n## 7. How does Figma handle design for accessibility?**\n\n**Example: I want to create an accessible design; how does Figma help me achieve this?**\n\nFigma offers several features to help you create accessible designs, with the most relevant ones listed first:\n\n1.  **Color Contrast**: Figma has a built-in color contrast checker that ensures text is legible and meets accessibility guidelines. This tool checks text and background color combinations, helping you achieve the minimum contrast ratio required for readability, especially for visual-impaired users.\n\n2.  **Accessibility Plugins**: Figma supports various accessibility plugins to assist in creating accessible designs. For example, the \"Accessibility Checker\" plugin helps you identify and fix potential accessibility issues, ensuring that your design meets accessibility standards and guidelines.\n\n3.  **Text Styles**: You can create and save text styles in Figma, making it easy to ensure that all text in your design complies with accessibility guidelines. Consistent use of text styles helps maintain legibility and readability throughout the design.\n\n4.  **Keyboard Navigation**: Figma enables you to create interactive prototypes that can be tested with keyboard navigation. This feature is vital for users with mobility impairments who rely on keyboard inputs for navigation.\n\n5.  **Text Resizing**: Figma allows you to resize text easily without affecting the overall layout of your design. By offering this flexibility, Figma ensures that text remains readable and accessible to users with visual impairments who might need larger font sizes.\n\n6.  **Accessibility Guidelines**: Figma provides built-in accessibility guidelines to assist you in designing accessible layouts. These guidelines cover various aspects of accessibility, including typography, color, interactive elements, and more. They serve as a valuable reference to ensure that your design adheres to accessibility best practices.\n\nBy prioritizing these features and utilizing accessibility plugins, Figma empowers designers to create more inclusive and accessible designs. These design considerations contribute to better user experiences and ensure that digital products can be used by a diverse audience, including individuals with disabilities.\n\n## WRAP UP\nIn conclusion, Figma is a powerful and versatile cloud-based design tool revolutionizing the design industry. It enables efficient team collaboration, real-time version control, and seamless integration with other tools, making it an excellent choice for designers working on projects with remote or in-house teams.\n\nFigma's capabilities extend to web and mobile app design, offering a wide range of features and tools to support the entire design process, from wireframes to interactive prototypes. Its responsive design support ensures that designs adapt gracefully to various screen sizes and orientations, enhancing the user experience across different platforms.\n\nThe platform's rich integration options with project management and communication tools streamline the design process and improve team collaboration, while its plugins extend functionality and assist designers in ensuring accessibility and adhering to design best practices.\n\nMoreover, Figma's commitment to accessibility is evident through features like color contrast checking, keyboard navigation support, and accessibility guidelines, making it easier for designers to create inclusive and user-friendly designs for all users, including those with disabilities.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1Bg3agf5Sp99NMpQyD2nig","type":"Asset","createdAt":"2020-01-23T07:45:47.503Z","updatedAt":"2023-09-10T10:36:23.350Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"adult-books-business-coffee-374016","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1Bg3agf5Sp99NMpQyD2nig/63bc7f1a839182d35ce1e74c24a6e04d/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6kIxt3XnHszjSpDpmJ0bqK","type":"Entry","createdAt":"2022-08-19T09:20:43.142Z","updatedAt":"2022-08-19T09:20:43.142Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Maryam Siddiqui","tcHandle":"maryamsidd"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5qUC92WWB9Cr7ufhEZaaSB","type":"Entry","createdAt":"2023-07-10T17:20:53.883Z","updatedAt":"2023-07-10T19:29:39.960Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":155,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Information Architecture vs UX Design: What's the Difference? ","slug":"information-architecture-vs-ux-design-whats-the-difference","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}}],"tags":["UX","Information Architecture"],"creationDate":"2023-07-10","readTime":"10 min","content":"In the world of digital design, two pillars stand tall, shaping our interactions with websites, apps, and digital products: Information Architecture (IA) and User Experience Design (UX Design). Like two skilled architects, they work diligently to create seamless and captivating digital landscapes. In this piece, we'll find out what sets them apart and how they complement each other.\n\n## Information Architecture In A Nutshell\n\nInformation Architecture, the mastermind behind seamless digital journeys, is all about organizing information in a captivating, logical, and user-friendly way. It's the secret sauce that ensures users find what they're looking for and understand it effortlessly.\n\n### The Key Elements Of Information Architecture\n\nThese elements are the secret that enables IA to transform design chaos into clarity and make the digital world a user's playground. They include the following;\n\n__1\\. Organization and Structure:__ IA focuses on arranging information logically and coherently. It involves determining hierarchies, categorizing content, and establishing relationships between different pieces of information.\n\n__2\\. Navigation Systems:__ IA designs intuitive navigation systems that help users easily move through the digital product. This includes creating menus, navigation bars, search functionalities, and other elements that aid in exploration and discovery.\n\n__3\\. Taxonomy and Labelling:__ IA employs effective labeling and categorization systems to make information findable and understandable. This involves creating consistent and meaningful labels, defining categories, and developing taxonomies that reflect user mental models.\n\n__4\\. Search Functionality:__ IA considers the implementation of robust search features to enable users to quickly locate specific information within a digital product. This includes designing search interfaces, integrating search algorithms, and optimizing search results.\n\n__5\\. Content Hierarchy:__ IA establishes a clear hierarchy of content, ensuring that important information receives prominence while maintaining a logical flow of information. This hierarchy helps users prioritize their attention and understand the relative importance of different elements.\n\n### The Key Processes And Methods In Information Architecture\n\nBy following the IA processes and methods listed below, information architects can create a well-structured and user-centered information architecture that enhances usability, and overall user experience within a digital product.\n\n__1\\. Research:__ IA begins with thorough research. This involves understanding user needs, business goals, and studying existing content. User research methods like interviews, surveys, and observation help gain insights into user behaviors, preferences, and mental models. Competitor analysis helps identify best practices and learn from existing solutions.\n\n__2\\. Information Organisation:__ Once the research phase is complete, IA professionals delve into organizing the information. They create content hierarchies by determining the relationships and priorities between different content elements. This involves categorizing information, establishing logical structures, and defining taxonomies. The goal is to ensure that users can easily navigate and comprehend the content.\n\n__3\\. Wireframing and Prototyping:__ IA practitioners employ wireframes and prototypes to visually represent the information architecture. Wireframes are skeletal layouts that depict the structure and placement of content elements. Prototypes are interactive representations that allow users to navigate and interact with the proposed IA. These visual representations help validate the effectiveness of the IA design, identify potential issues, and iterate on the structure as needed.\n\n__4\\. Card Sorting:__ Card sorting is a technique used in IA to involve users in the process of organizing information. It involves providing users with physical or virtual cards representing different content elements and asking them to group and categorize them based on their understanding. This exercise helps IA professionals understand users' mental models, preferences, and expectations, guiding the creation of an IA that aligns with user needs.\n\n__5\\. User Flows:__ User flows visually map out the paths and steps that users take to accomplish specific tasks within a digital product. They illustrate the sequence of interactions and decisions a user makes, helping IA professionals identify potential bottlenecks or gaps in the user journey. User flows enable them to optimize the IA by streamlining the navigation and ensuring a seamless user experience.\n![image5-userflows](//images.ctfassets.net/piwi0eufbb2g/3M8xwDjFNyeBKxa94qk6B/206ba558e4ee9da7e27ae35d08445214/image5.jpg)\n*Image is taken from Unsplash.com*\n\n__6\\. Site Maps:__ Site maps are visual representations of the overall structure and hierarchy of a website or app. They provide an overview of the content organization, showcasing the relationships between different pages or sections. Sitemaps aid in understanding the scope of the IA, identifying content gaps or redundancies, and facilitating collaboration between IA professionals and other stakeholders.\n\nTo put IA in perspective, let's take a look at how [Adidas](https://www.adidas.com/us) has made shopping easy on its website.\n\n1.  Clever navigation structure - As large as its catalog, the homepage is divided into several sections, each of which contains information about a different product category or topic. We can see that users will not experience a hard time finding the products of choice.\n![adidas-nav](//images.ctfassets.net/piwi0eufbb2g/4i9LA92vwbGcwXFCfUSyAq/be44229f114e1a793f201dbd8fc62610/adidas-nav.png)\n*[Adidas](https://www.adidas.com/us)' homepage navigation*\n\\.\n\n1.  Search bar - The Adidas website also has a search bar that allows users to search for specific products or information. The search bar is located in the top right corner of the website, and it is easy to find and use.\n![adidas-search](//images.ctfassets.net/piwi0eufbb2g/72hZaXhbuMdA1Yha0mhmkX/d25320f3591e56881daba7722c0fbfd2/adidas-search.png)\n*The search bar on the [Adidas](https://www.adidas.com/us) homepage*\n\nThe Adidas search bar also comes loaded with popup suggestions per category. It makes it easy to find products as it filters the search result according to input.\n![adidas-advanced-search](//images.ctfassets.net/piwi0eufbb2g/2mLuP5HnWjNfSN7U566qI9/4bc132d2f80b9fe5737001def43eb498/adidas-advanced-search.png)\n*[Adidas](https://www.adidas.com/us) advanced search*\n\n### What Tools Do Information Architects Use?\n\nInformation Architects (IAs) use various tools to support their work and streamline the process of designing and implementing effective information architectures. Some of the commonly used tools by IAs are;\n\n__1\\. Diagramming and Wireframing Tools:__ Tools such as Adobe XD, Sketch, Axure RP, FigJam, and Balsamiq allow IAs to create wireframes and visual representations of the information architecture. They help in organizing content, designing navigation systems, and showcasing the structure and layout of digital products.\n\n__2\\. Prototyping Tools:__ Prototyping tools like InVision, Figma, Proto.io, Adobe XD, and Marvel enable IAs to create interactive prototypes that simulate user interactions and flows. These prototypes help test and validate the information architecture, gather user feedback, and refine the design.\n\n__3\\. Card Sorting Tools:__ Online card sorting tools like OptimalSort, Treejack, and UserZoom facilitate remote and online card sorting exercises. These tools enable IAs to collaborate with users, collect data on how users categorize and group information, and gain insights into user mental models.\n\n__4\\. Collaborative Design and Documentation Tools:__ Tools like Miro, Mural, and Google Workspace (formerly G Suite) provide collaborative spaces for IAs to work with cross-functional teams. These tools allow for real-time collaboration, brainstorming, and documentation of the information architecture process.\n\n__5\\. Diagramming and Visualization Tools:__ Tools like Microsoft Visio, Lucidchart, and draw.io assist IAs in creating flowcharts, site maps, and visual representations of the information architecture. These tools help in communicating and presenting the IA design to stakeholders and development teams.\n\n## Understanding UX Design\n\nUX Design is the art of understanding users' desires, dreams, and frustrations and translating them into unforgettable digital encounters. Its purpose? To create digital masterpieces that leave users in awe.\n\n### The Key Elements of UX Design\n\nThese are often referred to as the Five Planes of UX. They work together harmoniously to create a remarkable user experience. They include;\n\n__1\\. Strategy:__ The strategy sets the course for our journey, guiding us toward creating an exceptional user experience. It involves understanding business goals, and target audience, and defining the overall vision for the product. The strategy lays the foundation for our design decisions, ensuring that we're headed in the right direction.\n\n__2\\. Scope:__ Think of scope as setting the boundaries for our design expedition. It helps us determine what features and functionalities will be included in the product. We carefully consider the needs and expectations of our users, balancing them with practical constraints like time, resources, and technical limitations. Defining the scope ensures that we focus on creating a valuable and achievable user experience.\n\n__3\\. Structure:__  This is the sturdy backbone of our design. It's about organizing and arranging information in a logical and user-friendly manner. We create a clear and intuitive navigation system, making it a breeze for users to explore and find what they need. By structuring the content and interactions, we ensure that users can easily navigate through the product, saving them from any frustrating detours.\n\n__4\\. Skeleton:__ This serves as the essential framework of our design, setting the stage for the key elements and interactions. Within this foundation, we determine the arrangement and positioning of buttons and menus, as well as establish the flow of interactions. This framework allows us to visualize the overall structure of the product and anticipate how users will engage with it.\n\n__5\\. Surface:__ This is where we add delightful visual touches to our design. We apply color, typography, imagery, and other visual elements to create an engaging and visually pleasing experience. The surface gives our design its personality, reflecting the brand identity and evoking emotions in our users.\n\n### UX Design Processes And Methods\n\nThese are integral to creating successful and user-centered digital experiences. Let's explore some of the key UX Design processes and methods.\n\n__1\\. Research and Analysis:__ UX Design begins with thorough research and discovery to gain insights into user needs, behaviors, and preferences. This involves conducting user interviews, surveys, and usability testing, as well as analyzing market trends and competitor analysis. The goal is to understand the target audience and their goals to inform the design process.\n\n__2\\. User Persona Development:__ User personas serve as fictional representations of various user types derived from thorough research. UX designers employ personas to add a human touch to the target audience and gain insights into their motivations, needs, and challenges. These personas play a pivotal role in steering design choices, ensuring that the product is customized to cater to specific user groups.\n\n__3\\. User Journey Mapping:__ User journey mapping involves visualizing the end-to-end experience of users as they interact with a product or service. It identifies touchpoints, emotions, and pain points throughout the user's journey. User journey maps provide a holistic view of the user's experience, helping UX designers identify opportunities for improvement and create seamless interactions.\n\n__4\\. Information Architecture:__ Information Architecture (IA) is a critical component of UX Design. It involves organizing and structuring the content and information within a product logically and intuitively. IA ensures that users can easily navigate and find the information they need, enhancing the overall user experience. A part of the deliverables for IA is wireframes and prototypes.\n![image7](//images.ctfassets.net/piwi0eufbb2g/6rBQIieP7vJoKdNJilcmGt/0175df252703f563ba03547d0fc2b609/image7.jpg)\n*Image is taken from Unsplash.com*\n\nWireframing is the process of creating low-fidelity visual representations of the user interface. It focuses on the layout and structure of the design without getting into visual details. Prototyping, on the other hand, involves creating interactive and more high-fidelity representations of the design. Wireframes and prototypes allow designers to test and iterate on the design before development, ensuring usability and user satisfaction.\n\n__5\\. Usability Testing:__ Usability testing involves observing and gathering feedback from users as they interact with a prototype or a live product. This method helps identify usability issues, pain points, and areas for improvement. UX designers conduct usability tests to validate design decisions, make data-driven improvements, and enhance the user experience.\n\n__6\\. Iterative Design:__ UX Design follows an iterative approach, constantly refining and enhancing the design based on user feedback and data. This ongoing improvement process ensures that the design evolves and aligns with user expectations.\n\nLet's take a look at some of [Apple's](https://www.apple.com/) website features that make it a great UX site.\n\n1\\.  The use of white space - Whitespace is the space between elements on a webpage. It is often used to create a sense of space and organization. On Apple's website, whitespace is used effectively to make the website easy to scan and to focus attention on the most important content. This reduces distraction for users, hence a good UX.\n\nWhile this feature almost goes unnoticed, it goes a long way in creating a positive, long-lasting impression for users.\n![apple-whitespace](//images.ctfassets.net/piwi0eufbb2g/1zlbTkCUh7JHyLLuxwfciq/53eab8558e4959fbafffac43f3871a90/apple-whitespace.png)\n*[Apple'](http://apple.com)s watch series page shows the use of whitespace*\n\n2\\.  Use of cool animations - Another important feature of Apple's website design is the use of animated images. We can see in the screenshot below how Apple cleverly showcases its products using subtle yet effective techniques to capture attention. Likewise, users can interact with the animation by clicking on different parts of the screen. This allows users to explore the product in more detail, and it helps them to learn more about its features. This helps to create a positive emotion with the product.\n![apple-interaction](//images.ctfassets.net/piwi0eufbb2g/38yzGAUiFtRomQPnEiXKGr/4eede04660bce7b65a322f05a2a788f8/apple-interaction.gif)\n*[Apple's](http://apple.com) homepage with animated images.*\n\n### Tools Employed By UX Designers\n\nUX designers utilize a variety of tools to aid them in the design process and create exceptional user experiences. Listed are some commonly employed tools by UX designers:\n\n__1\\. Design and Prototyping Tools:__ Tools like Sketch, Adobe XD, Figma, and InVision enable UX designers to create high-fidelity mockups, wireframes, and interactive prototypes. They offer features for designing user interfaces, creating animations, and simulating user interactions, allowing designers to visualize and test their design concepts before implementation.\n\n__2\\. User Research Tools:__ User research tools help UX designers gather valuable insights into user behavior and preferences. Tools such as UserTesting, Optimal Workshop, and UserZoom enable designers to conduct remote usability testing, surveys, card sorting, and other research methods. These tools provide feedback, analytics, and user behavior data that inform design decisions.\n\n__3\\. Collaboration and Communication Tools:__ Collaboration and communication tools facilitate teamwork and streamline communication among UX designers, stakeholders, and developers. Tools like Slack, Microsoft Teams, and Asana enable designers to collaborate on projects, share design files, provide feedback, and manage tasks efficiently. These tools promote effective collaboration and project coordination.\n\n__4\\. Accessibility Testing Tools__: Accessibility testing tools help UX designers ensure that their designs are inclusive and accessible to users with disabilities. Tools like WebAIM, WAVE, and AChecker evaluate web accessibility compliance, identify accessibility issues, and provide recommendations for improvement. These tools assist designers in creating products that adhere to accessibility standards and guidelines.\n\n__5\\. Usability Testing Tools:__ Usability testing tools aid UX designers in evaluating the usability and effectiveness of their designs. Tools like Maze, UserZoom, and Lookback facilitate remote user testing, screen recording, and user feedback collection. These tools help designers observe user interactions, gather qualitative and quantitative data, and refine the design based on user insights.\n\n## Information Architecture vs UX Design: What's the Difference\n\nIt's important to note that  IA can exist separately from UX, however, UX cannot exist without IA. Let's take a look at an overview of the overlapping and complementing areas of Information Architecture and UX Design.\n\n|Factor|Information Architecture (IA)|UX Design|\n|:----|:----|:----|\n|__Focus__|Content structuring and organization for easy finding|Emotions and psychology of the users. Overall user satisfaction and usability|\n|__Key Elements__|Content hierarchy, navigation systems, taxonomy, search functionality|User research, interaction design, visual design, usability testing|\n|__Objectives__|Optimize information findability and comprehension|Create enjoyable and intuitive user experiences|\n|__Key Activities__|Organizing content, creating taxonomies, designing navigation systems|User research, wireframing, prototyping, usability testing|\n|__Deliverables__|Site maps, content hierarchies, labeling systems, metadata, wireframes, prototypes|User personas, experience maps, empathy maps, journey maps|\n|__Scope__|Primarily focuses on information structure and organization|Holistic approach encompassing aesthetics, interactions, and usability|\n|__Timeframe__|Often established in the early stages of the design process|Spanning the entire design process, from research to implementation|\n|__Overlapping Areas__|UX Design incorporates IA principles to create a seamless user experience|IA benefits from UX Design's insights on user needs and interactions|\n\n## Final Thoughts\n\nInformation Architecture (IA) and User Experience Design (UX Design) are two essential disciplines that work hand in hand to create exceptional digital experiences. While IA focuses on organizing and structuring information to optimize findability and comprehension, UX Design takes a broader approach, considering overall user satisfaction and usability.\n\nSo, the next time you're navigating a well-organized website or enjoying a user-friendly app, remember that Information Architecture and UX Design have worked hand in hand to create that delightful experience.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4MvV4MKBVxBwYrrrE2PNlw","type":"Asset","createdAt":"2023-07-10T11:03:28.308Z","updatedAt":"2023-07-10T11:03:28.308Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"ux-versus-ia","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4MvV4MKBVxBwYrrrE2PNlw/f74026d7fd00b73102cdabee82b8bab3/ux-process.png","details":{"size":293363,"image":{"width":445,"height":355}},"fileName":"ux-process.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"4rUnTz3X10yfndHMECQ6kG"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"QUWD2QS7RiuC12nzWW4Ai","type":"Entry","createdAt":"2022-10-07T10:12:11.131Z","updatedAt":"2022-10-07T10:12:11.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"UX Design","slug":"ux-design","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}},{"sys":{"type":"Link","linkType":"Entry","id":"6kbzSOMPOI8eWQV2cJzrHR"}}],"tags":["UX"],"creationDate":"2022-10-06","readTime":"7min","content":"UX design is an essential part of the design or redesign of any product. However, more often than not, UX design principles are confused with the design process. It should be noted that the UX design and the design process are similar but different. UX design is the standard principle for a product design, while the design process is the step-by-step guide a designer takes in designing a product. The design process typically varies based on the designer and the effect the designer is trying to create or redesign. \n\nTherefore, here we will be looking at carrying out a UX design while you design an app based on the principles learned and adequately document your design process. Note that the UX design should be based on the needs of the user and the stakeholder. Simply put, your UX design must solve the users' needs and meet business goals.\n\nAccording to the Stanford school of design the UX design comprises:\n- Product definition\n- Research\n- Analysis\n- Design\n- Validation\n\n### Product definition\nThis is the first phase in the user design process. This is where the design team understands the problem they are trying to solve and the context in which the product is being formed. This is where the \"whys” of the design are discussed. This is where the designer will collect the user needs based on business goals. Any mistakes in understanding the scope will lead to a product in the market that is not required. At this stage, the designer has stakeholder meetings in which he meets with the business manager, the product manager, and the lead developer. It is here we determine what our product is all about, who will use our product, and why they will be using our product. The entire team will have to consult with customers in their environment and analyze what they want within the framework of your operation. At this stage, critical KPIs are set, and success metrics are determined.\n\n### Research\nAfter you have adequately defined those, we move further into carrying out our research. This is very important because it helps save us time, money, and effort early in our design process. We identify pain points, needs, wants, and desires, and knowing our user's wants we can design a solution that will solve their problem. Research also involves competitive analysis where we check out what is already in mind and what we can add or remove that would give us an edge in the market. This aids us in entering the market faster.\nWe also look into the latest trends in UI design and design guidelines during the research process.\n\n### Analysis\nThis is where we combine and analyze the information gathered during research to get what we need from the data. We produce storyboards, user stories, personas, and experience maps, among other things. At this point, the designer shifts their focus from what to why a user needs or wants something. The designer has an initial guess about what the user might need, but they are not sure at this point in the user experience design process.\n\nAfter conducting enough studies and assessing the data obtained from research, we confirm our assumptions at this point.\n- __Fictional Personas:__ Developing fictional scenarios enables the designer to understand the many customers of your product better. It allows a realistic portrayal of the finished product. The design team can determine how it will seem following delivery.\n- __Experience Maps:__ These diagrams depict how users move through your finished product. This is accomplished through visual representation and suitable interactions with the customer.\n- __User story:__ A user story is a tool designers can use to better comprehend how users engage with a product or service. As a [user], I want to [objective to attain] so that [motive], which is the typical definition.\n- __Storyboarding:__ Designers can connect user personas and user stories with the storyboarding method. It's a story about a user interacting with your product, as the name suggests.\n\n### Design\nWhen product designers have a strong understanding of what customers want, need, and expect from a product, they move on to the design phase. Product teams work on various projects at this stage, from creating an Information Architecture (IA) to UI design in practice. A successful design phase is highly collaborative (every team member involved in product design must actively participate in this phase), iterative, and combined (meaning it cycles back upon itself to validate ideas).\n\nTypically, the design phase entails:\n- __Sketching:__ The quickest and most straightforward approach to visualize our ideas is through sketches. This can be accomplished by hand-drawing on paper, on a whiteboard, or with a computer tool. It may let the team see a wide range of design possibilities before determining which one to use, which makes it particularly helpful during brainstorming sessions.\n- __Wireframing:__ A wireframe is a tool designers may use to see the essential components of a future page and how they will work together. Wireframing is the product's backbone, and designers frequently utilize it as a foundation for mockups and prototypes.\n- __Prototyping:__ While wireframes are primarily concerned with structure and visual hierarchy (the look), prototypes are concerned with the actual interaction experience (the look and feel). A prototype resembles a simulation of the finished product and ranges from low-fidelity (clickable wireframes) to high-fidelity (coded prototypes) depending on the specific screens.\n- __Design specifications:__ They include user flow and task flow diagrams. It shows how the UI/UX product will generally function and its stylistic needs. It explains the procedures and visual components needed to produce fantastic user experiences.\n- __The development of design systems:__ Designers frequently construct a system of components, patterns, and styles for significant projects to enable designers and developers to stay on the same page with the design.\n\n### Validation or Testing\nTesting is the stage that establishes the final product's overall quality. When something has to be fixed, the testers make notes and submit them back to the appropriate team so they can fix the mistakes. Although some businesses conduct internal tests, doing so is not recommended because it is likely that these individuals have a basic understanding of how these apps operate and are prejudiced in favor of the product. \n\nThe validation process typically begins after the high-fidelity design is completed because testing with high-fidelity methods yields more insightful feedback from end-users. It is, however, also advisable to carry out tests also on your low-fi design; this helps in knowing that your user can carry out given actions with the barest minimum. During several user testing sessions, the team validates the product with stakeholders and end-users. \n\nThe following activities may be included in the validation phase of the UX process: \n- __Testing sessions:__ User testing sessions with participants who correspond to your target market are crucial. There are numerous forms to experiment with, such as moderated/unmoderated usability testing, focus groups, beta testing, and A/B testing.\n- __Surveys:__ Surveys are a fantastic tool for gathering quantitative and qualitative data from actual people. Open-ended questions, such as \"What portion of the product do you dislike?\" might be added by UX designers to elicit user feedback on specific features. \n- __Analytics:__ Quantitative data (clicks, navigation time, search queries, and so on) from an analytics tool can be helpful in determining how users engage with your product.\n\nThere are a few things to consider while assessing your finished project. Some are:\n- Is the system simple to use? \n- Is it adaptable and straightforward to use? \n- Does it resolve the client's problem? \n- Does it have credibility and entice customers to return when they require your service?\n\nIt should be noted that the UX design process is an iterative process where the designer performs back and forth movement based on findings from user testing sessions and meetings with stakeholders and our developers. \n\n### Conclusion\nOne must adopt a systematic approach to create excellent UX/UI interfaces. To do this, we need a UI/UX design process technique. The entire design team will participate in the process. In this increasingly competitive world, this is one of the most acceptable methods to maintain present clients and attract new ones.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"KLiU6Wijp0SYkFb5R8l8O"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}},{"sys":{"type":"Link","linkType":"Entry","id":"2uvUxTj7xgbHN7m06Ekpmo"}},{"sys":{"type":"Link","linkType":"Entry","id":"6caWgGv16CdBLAnAELHGjH"}}],"openExternalLinksInNewTab":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4MypFsmISeX3lVf8orurw4"}},{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"QUWD2QS7RiuC12nzWW4Ai","type":"Entry","createdAt":"2022-10-07T10:12:11.131Z","updatedAt":"2022-10-07T10:12:11.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"UX Design","slug":"ux-design","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}},{"sys":{"type":"Link","linkType":"Entry","id":"6kbzSOMPOI8eWQV2cJzrHR"}}],"tags":["UX"],"creationDate":"2022-10-06","readTime":"7min","content":"UX design is an essential part of the design or redesign of any product. However, more often than not, UX design principles are confused with the design process. It should be noted that the UX design and the design process are similar but different. UX design is the standard principle for a product design, while the design process is the step-by-step guide a designer takes in designing a product. The design process typically varies based on the designer and the effect the designer is trying to create or redesign. \n\nTherefore, here we will be looking at carrying out a UX design while you design an app based on the principles learned and adequately document your design process. Note that the UX design should be based on the needs of the user and the stakeholder. Simply put, your UX design must solve the users' needs and meet business goals.\n\nAccording to the Stanford school of design the UX design comprises:\n- Product definition\n- Research\n- Analysis\n- Design\n- Validation\n\n### Product definition\nThis is the first phase in the user design process. This is where the design team understands the problem they are trying to solve and the context in which the product is being formed. This is where the \"whys” of the design are discussed. This is where the designer will collect the user needs based on business goals. Any mistakes in understanding the scope will lead to a product in the market that is not required. At this stage, the designer has stakeholder meetings in which he meets with the business manager, the product manager, and the lead developer. It is here we determine what our product is all about, who will use our product, and why they will be using our product. The entire team will have to consult with customers in their environment and analyze what they want within the framework of your operation. At this stage, critical KPIs are set, and success metrics are determined.\n\n### Research\nAfter you have adequately defined those, we move further into carrying out our research. This is very important because it helps save us time, money, and effort early in our design process. We identify pain points, needs, wants, and desires, and knowing our user's wants we can design a solution that will solve their problem. Research also involves competitive analysis where we check out what is already in mind and what we can add or remove that would give us an edge in the market. This aids us in entering the market faster.\nWe also look into the latest trends in UI design and design guidelines during the research process.\n\n### Analysis\nThis is where we combine and analyze the information gathered during research to get what we need from the data. We produce storyboards, user stories, personas, and experience maps, among other things. At this point, the designer shifts their focus from what to why a user needs or wants something. The designer has an initial guess about what the user might need, but they are not sure at this point in the user experience design process.\n\nAfter conducting enough studies and assessing the data obtained from research, we confirm our assumptions at this point.\n- __Fictional Personas:__ Developing fictional scenarios enables the designer to understand the many customers of your product better. It allows a realistic portrayal of the finished product. The design team can determine how it will seem following delivery.\n- __Experience Maps:__ These diagrams depict how users move through your finished product. This is accomplished through visual representation and suitable interactions with the customer.\n- __User story:__ A user story is a tool designers can use to better comprehend how users engage with a product or service. As a [user], I want to [objective to attain] so that [motive], which is the typical definition.\n- __Storyboarding:__ Designers can connect user personas and user stories with the storyboarding method. It's a story about a user interacting with your product, as the name suggests.\n\n### Design\nWhen product designers have a strong understanding of what customers want, need, and expect from a product, they move on to the design phase. Product teams work on various projects at this stage, from creating an Information Architecture (IA) to UI design in practice. A successful design phase is highly collaborative (every team member involved in product design must actively participate in this phase), iterative, and combined (meaning it cycles back upon itself to validate ideas).\n\nTypically, the design phase entails:\n- __Sketching:__ The quickest and most straightforward approach to visualize our ideas is through sketches. This can be accomplished by hand-drawing on paper, on a whiteboard, or with a computer tool. It may let the team see a wide range of design possibilities before determining which one to use, which makes it particularly helpful during brainstorming sessions.\n- __Wireframing:__ A wireframe is a tool designers may use to see the essential components of a future page and how they will work together. Wireframing is the product's backbone, and designers frequently utilize it as a foundation for mockups and prototypes.\n- __Prototyping:__ While wireframes are primarily concerned with structure and visual hierarchy (the look), prototypes are concerned with the actual interaction experience (the look and feel). A prototype resembles a simulation of the finished product and ranges from low-fidelity (clickable wireframes) to high-fidelity (coded prototypes) depending on the specific screens.\n- __Design specifications:__ They include user flow and task flow diagrams. It shows how the UI/UX product will generally function and its stylistic needs. It explains the procedures and visual components needed to produce fantastic user experiences.\n- __The development of design systems:__ Designers frequently construct a system of components, patterns, and styles for significant projects to enable designers and developers to stay on the same page with the design.\n\n### Validation or Testing\nTesting is the stage that establishes the final product's overall quality. When something has to be fixed, the testers make notes and submit them back to the appropriate team so they can fix the mistakes. Although some businesses conduct internal tests, doing so is not recommended because it is likely that these individuals have a basic understanding of how these apps operate and are prejudiced in favor of the product. \n\nThe validation process typically begins after the high-fidelity design is completed because testing with high-fidelity methods yields more insightful feedback from end-users. It is, however, also advisable to carry out tests also on your low-fi design; this helps in knowing that your user can carry out given actions with the barest minimum. During several user testing sessions, the team validates the product with stakeholders and end-users. \n\nThe following activities may be included in the validation phase of the UX process: \n- __Testing sessions:__ User testing sessions with participants who correspond to your target market are crucial. There are numerous forms to experiment with, such as moderated/unmoderated usability testing, focus groups, beta testing, and A/B testing.\n- __Surveys:__ Surveys are a fantastic tool for gathering quantitative and qualitative data from actual people. Open-ended questions, such as \"What portion of the product do you dislike?\" might be added by UX designers to elicit user feedback on specific features. \n- __Analytics:__ Quantitative data (clicks, navigation time, search queries, and so on) from an analytics tool can be helpful in determining how users engage with your product.\n\nThere are a few things to consider while assessing your finished project. Some are:\n- Is the system simple to use? \n- Is it adaptable and straightforward to use? \n- Does it resolve the client's problem? \n- Does it have credibility and entice customers to return when they require your service?\n\nIt should be noted that the UX design process is an iterative process where the designer performs back and forth movement based on findings from user testing sessions and meetings with stakeholders and our developers. \n\n### Conclusion\nOne must adopt a systematic approach to create excellent UX/UI interfaces. To do this, we need a UI/UX design process technique. The entire design team will participate in the process. In this increasingly competitive world, this is one of the most acceptable methods to maintain present clients and attract new ones.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"KLiU6Wijp0SYkFb5R8l8O"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}},{"sys":{"type":"Link","linkType":"Entry","id":"2uvUxTj7xgbHN7m06Ekpmo"}},{"sys":{"type":"Link","linkType":"Entry","id":"6caWgGv16CdBLAnAELHGjH"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6raiETCgPADnd17sRSKJSG","type":"Entry","createdAt":"2022-08-09T07:53:49.899Z","updatedAt":"2022-08-25T06:03:49.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","slug":"what-skills-do-you-need-to-be-a-graphic-designer-2","type":"Article","trackCategory":["Design"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5W8yVIchiseIGTWrWKXN57","type":"Entry","createdAt":"2019-09-18T07:36:54.570Z","updatedAt":"2023-09-06T19:01:10.075Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Design"}}],"tags":["Learn","Graphic Design"],"creationDate":"2022-08-08","readTime":"8min","content":"Graphic designers use visuals to communicate and make visual notions by hand or with computer tools. Through both real and virtual art forms, they can provide suggestions for inspiring, motivating, or enhancing consumers. Professionals in graphic design work on various projects, including brochures, print ads, and logos.\n\n### Evolution of Graphic Design\n\nIt isn't easy to envision life in the present era without graphic design because society encompasses so many aspects of it. Though it has been a long trip from stone tools to digital tablets, visual communication is roughly as old as our opposable thumbs, so in some respects, we never have lived without graphic design. In summary, the history of graphic design is a narrative that spans all of human history and can both inform and inspire contemporary graphic artists.\nGraphic design has evolved starting with cave paintings, then the origin of the printing press, the pre-digital era, and now the digital age. Graphic design has come a long way. As it evolves over time the skill sets are also changing.\n\n### Skill Set of Graphic Designers\n\nIn today's fast, ever-changing world, graphic designers need technical and soft skills. Your industry-specific professional knowledge and competencies are the foundation for your technical skills. Technological requirements are constantly changing; your current technical abilities might not be enough for the work you'll be requested to complete tomorrow. That's where soft skills come into play. Teamwork, effective communication, problem-solving, leadership, decisiveness, time management, and flexibility are examples of soft skills that are highly valued.\n\nLet's look more deeply into the technical and soft skills that graphic designers need in today's world.\n\n### Technical Skills\nEmployers seek out adaptable graphic designers with the necessary technical know-how to start immediately. Some of the most sought-after technical abilities for a graphic designer are the following:\n\n#### Typography skills\nThe visual representation of words and phrases is known as typography. The actual job of a graphic designer is to arrange words and letters in a visually appealing way. Typography skills work to combine the principles of visual design, font, lettering, color, and several other aspects of print writing to create banners, billboards, signs, magazine articles, website content, letters and letterheads, and many other print and writing applications\n\n#### Font selection\nThe graphic designer must be able to select the right font for each project. You must be able to choose the right font for each project, considering font style, size, and weight. All affect how your designs seem and may change how readers interpret your content.\n\n#### Design principles\nKnowing the design principles is a must-have trait for a graphic designer. Successful graphic designers understand how to balance designs using white space, color, hierarchy, and other design elements. For instance, during each project, a graphic designer must be able to select the appropriate color scheme. In contrast to RGB, which is frequently used for digital designs, CMYK is best for print projects.\n\nAlong with design principles, standards used to decide how a brand will be presented to audience members are called branding guidelines. You must be able to adhere to these rules strictly if you want to excel in the field.\n\n#### UX design\nUX design is the bridge between design and the front-end development team. The user interface, or UI, is a term that is generally understood. The screen that a person interacts with, such as while using a website or app, is most frequently the user interface. UX refers to the overall experiences a customer gets when utilizing a product or service, including UI. Graphic designers with UX experience know how to produce straightforward layouts that are practical and adhere to recognized accessibility standards.\n\n#### Digital technology (HTML, CSS, JS)\nThis skill is not required but is an optional one. Knowledge of HTML, CSS, and JavaScript is included in this. You should be familiar with well-known JavaScript libraries like React. Testing, debugging, build tools, and dependency managers may also be included.\n\nIt is significant to highlight that the position necessitates in-depth CSS knowledge. This might include using preprocessors like Sass and Less or the CSS architecture. Experience with CSS-in-JS libraries like Styled Components and Emotion is advantageous.\nThese skills will definitely help you if you plan to design websites or work as a graphic designer.\n\n#### Photography skills/photo editing\nIt's crucial to know how to edit stock pictures or take excellent photos because you might need to include photos in your graphic design work.\n\n### Soft Skills\n\nNo matter how strong your technical abilities, if you lack the soft qualities that companies value, it will be difficult for you to thrive in the design industry. Soft skills are character attributes that, as previously mentioned, can help you thrive in any industry. You can collaborate with others, communicate clearly, and establish a good rapport with clients and coworkers if you possess these qualities. The following soft skills are necessary for graphic designers.\n\n#### Collaboration skills\nWorking with people to achieve a shared objective is simple when one possesses strong collaboration abilities. A good collaborator pays attention to others, communicates well, and accepts responsibility for their errors.\n\n#### Emotional intelligence\nIndividuals with high emotional intelligence are masters at controlling their feelings, which enables them to solve problems and relieve stress from their team members.\n\n#### Communication skills\nEffective communication with coworkers, clients, and other stakeholders is essential. Graphic designers with good communication skills who can articulate their ideas concisely and consistently are always in demand by potential employers.\n\n#### Time management\nSince deadlines are a big part of graphic design, time management skills are necessary.\n\n#### Creativity \nThe potential to come up with fresh notions and apply them to problems or interpersonal communication is referred to as creativity. Successful graphic designers have a strong sense of creativity and originality.\n\n#### Storytelling\nStorytelling is a terrific approach to learn what your audience needs and how your organization may meet those needs if you're attempting to appeal to a particular demographic. The ability to tell a story is extremely useful for graphic designers tasked with creating enduring brand identities.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1i786NVOB6KrgH8WIjNA5o","type":"Asset","createdAt":"2022-08-08T17:15:51.156Z","updatedAt":"2022-08-08T17:15:51.156Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1i786NVOB6KrgH8WIjNA5o/f4c8f049da0a86b350b2d0871784b97b/What_Skills_do_you_Need_to_be_a_Graphic_Designer","details":{"size":79753,"image":{"width":640,"height":640}},"fileName":"What Skills do you Need to be a Graphic Designer?.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"12QIad2hrziFxOyUtzHw3V"}},{"sys":{"type":"Link","linkType":"Entry","id":"5QU9Tsl9cEHOJC50UvGdIl"}},{"sys":{"type":"Link","linkType":"Entry","id":"6TVx3UYkm6bWDe223mn0XP"}}],"openExternalLinksInNewTab":true}}],"openExternalLinksInNewTab":true}}],"includes":{"Entry":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"01JIR2EKpWpW9ZcokunEDM","type":"Entry","createdAt":"2021-12-15T09:29:38.217Z","updatedAt":"2022-09-10T06:09:40.018Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":60,"revision":10,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Snakes and Ladders Problem","slug":"snakes-and-ladders-problem","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Rte82DJ0sXfUl9RRcJ2O3","type":"Entry","createdAt":"2019-09-18T07:37:35.298Z","updatedAt":"2019-09-18T07:37:35.298Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Dynamic Programming","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["C++","BFS"],"creationDate":"2021-12-15","readTime":"9min","content":"### About the problem:\n\nLike a traditional snakes and ladders game, we are provided with a 10\\*10 board numbered from one to one hundred and dice with faces numbered from one to six. We start from square one, and the game is considered finished when a player reaches square one hundred. \n\nCovering two other aspects of snakes and ladders we are given two vectors of vector ladder and snake where, \n\n-   ladder\\[i\\]\\[0\\] denotes the starting square of the ith ladder and ladder\\[i\\]\\[1\\] denotes the end of the ith ladder.\n\n-   snake\\[i\\]\\[0\\] denotes the mouth of the ith snake and snake\\[i\\]\\[1\\] denotes the tail of the ith snake.\n\nNow we are required to find the minimum number of rolls to reach the hundredth square.\n\n__Example 1:__\n\nInput: ladder = \\[\\[14,28\\],\\[42,78\\],\\[55,97\\],\\[52,92\\]\\]\n\nsnake = \\[\\[99,25\\],\\[88,54\\],\\[29,10\\]\\]\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2a7jMZ4a8BCh3Qzfwog7N4/77bde54994c8c0bdd02c944e661f8697/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2a7jMZ4a8BCh3Qzfwog7N4/77bde54994c8c0bdd02c944e661f8697/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2a7jMZ4a8BCh3Qzfwog7N4/77bde54994c8c0bdd02c944e661f8697/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\nOutput: 9\n\n__Example 2:__\n\nInput: ladder = \\[\\[6,46\\],\\[19,43\\],\\[52,71\\],\\[57,98\\]\\]\n\nsnake = \\[\\[47,9\\],\\[62,40\\],\\[96,75\\]\\]\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\nOutput: 4\n\n### Approach: Breadth-First Search (BFS)\n\nFor this approach, we consider the board a graph and every square as the vertex of the graph. Here our starting vertex is one, and one hundred is the final, or destination, vertex. So, since there are six faces on a dice, we have six possible squares to move to from a particular square.\n\nIf we encounter ladder i, then it would take us from ladder\\[i\\]\\[0\\] to ladder\\[i\\]\\[1\\] in zero moves. Likewise, If we encounter a snake j, then it would take us from snakeji\\]\\[0\\] to snake\\[j\\]\\[1\\] in zero moves.\n\nTo note these details we are using an unordered map like below:\n\n```cpp\nunordered_map<int,int> m;\nfor(vector<int> &i : ladder)\n    m[i[0]] = i[1];\n\nfor(vector<int> &i : snake)\n    m[i[0]] = i[1]\n```\n\nComing to the core approach we do a level order search using BFS, where we push all possible positions in a queue, and in the next iteration loop over only the next level positions, and increment the final answer with the increasing levels in the algorithm.\n\nAlgorithm:\n\n1.  Create an explicit map and insert the ladder, snake jumping possibilities.\n\n2.  Now declare a queue and a variable level incremented with 1.\n\n3.  Now push 1 to queue and start doing a level order search.\n\n4.  Calculate the size of the queue and traverse on each possible value.\n\n1.  The new position will be x + i (1<=i<=6) if x+i is a value in map then we move to that like pos = m\\[x+i\\].\n\n2.  If the new value is 100 then we return the variable level.\n\n3.  Otherwise if the new position was not visited before then we mark it visited and push it into the queue.\n\n6.  If we are out of queue then we return -1.\n\n__Code:__\n\n```cpp\n#include<bits/stdc++.h>\nusing namespace std;\n\nint snakeLadder(vector<vector<int> > &ladder, vector<vector<int> > &snake) {\n    unordered_map<int,int> m;\n    for(vector<int> &i : ladder)\n        m[i[0]] = i[1];\n\n    for(vector<int> &i : snake)\n        m[i[0]] = i[1];\n\n    queue<int> q;\n    q.push(1);\n    int level = 1;\n    vector<bool> vis(101,0); \n    while(!q.empty())\n    {\n        int size = q.size();\n        while(size--)\n        {\n            int x = q.front();\n            q.pop();\n            for(int i=1; i<7; i++)\n            {\n                int finalpos = x+i;\n                if(m.count(x+i))\n                    finalpos = m[x+i];\n\n                if(finalpos == 100)\n                    return level;\n\n                if(!vis[finalpos])\n                {\n                    vis[finalpos] = 1;\n                    q.push(finalpos);\n                }\n\n            }\n        }\n        ++level;\n    }\n    return -1;\n}\n\nint main()\n{   \n    int s,l;\n    cin >> l;\n    vector<vector<int>> snake,ladder;\n\n    int st,en;\n    for(int i=0;i<l;i++){\n        cin >> st >> en;\n        ladder.push_back({st,en});\n    }\n\n    cin  >> s;\n    for(int i=0;i<s;i++){\n        cin >> st >> en;\n        snake.push_back({st,en});\n    }\n\n    cout << snakeLadder(snake,ladder);\n}\n```\n\n__Input:__\n4 6 46 19 43 52 71 57 98\n3 47 9 62 40 96 75\n\n__Output:__\n4","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2bAdOFpJGT2SDWvp6UeM1R","type":"Asset","createdAt":"2021-12-15T09:24:52.920Z","updatedAt":"2021-12-15T09:24:52.920Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"image","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png","details":{"size":222871,"image":{"width":861,"height":632}},"fileName":"image.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":8,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7jt5BLGIRNTxAd0kkhmd7U"}},{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"53DKhRPQZF8wHYXn3Nrpue","type":"Entry","createdAt":"2021-11-16T20:47:39.346Z","updatedAt":"2024-07-02T15:06:59.853Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":54,"revision":27,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competitive Programming at Topcoder: A Step by Step Guide","slug":"competitive-programming-at-topcoder-a-step-by-step-guide","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":67,"downvotes":5,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}}}]}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"14TE3B3pQi9gHoiwEwT1M0","type":"Entry","createdAt":"2019-09-03T05:38:25.068Z","updatedAt":"2021-02-01T15:48:12.785Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Harshit Mehta","email":"harshit@topcoder.com","tcHandle":"hmehta","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1Gih7PRzBW0uTm7VCeS9mm","type":"Entry","createdAt":"2021-09-21T09:34:07.920Z","updatedAt":"2021-09-21T09:34:07.920Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Robinson Muiru","tcHandle":"Rokit12"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1KSO9elwSjMcMAkaygGVc3","type":"Entry","createdAt":"2019-09-20T07:14:17.372Z","updatedAt":"2021-06-11T08:05:06.049Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Justin Gasper","tcHandle":"Ghostar","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1LTsf2q8kxIHBRUfKAgePp","type":"Entry","createdAt":"2020-06-26T13:51:14.042Z","updatedAt":"2021-02-16T08:16:58.019Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":141,"revision":15,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Writing a Marathon Tester","slug":"writing-a-marathon-tester","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["Marathon","Tester"],"creationDate":"2020-06-24","readTime":"15 min","content":"#### Class/method to implement\nA marathon tester with no visual representation (tester only) should extend __MarathonTester__ abstract base class, which already implements many common features.\n\nThree abstract methods must be implemented:\n\n__boolean isMaximize()__\nReturn true if the goal of this problem is to maximize the score, or false otherwise (minimize).\n\n__void generate()__\nGenerate the test case.\n\n__double run()__\nRun this test case, calling the solution (if defined) and return the calculated raw score.\n\t\t\nFor problems with a visual representation but no animation, i.e. only a single (final) state is shown, the class to be extended is __MarathonVis__ (which extends __MarathonTester__). There is a single additional method to be implemented:\n\n__void paintContent(Graphics2D g)__\nResponsible for painting the content of the visualizer. Detailed information is available in the \"__Visualization and Painting__\" section.\n\nFinally, for problems with animations, i.e. where intermediate states are displayed, the base class to be extended is MarathonAnimatedVis. It has no abstract methods. \n\n![mtester 1](//images.ctfassets.net/piwi0eufbb2g/1riYwQF1aCgvyBu6xJSLN7/807ea130fe67390811bd65730ae94237/mtester_1.png)\n\n#### Random generator\nThe random number generator is already created and initialized to use the specified seed by the base class. It is available as a class variable named rnd, to be used inside generate() method (and occasionally inside run(), in the case of interactive problems, in which the tester needs to take actions based on solution output).\n\nThere are convenience methods to get a random number (integer or double) given a range. Please use them whenever possible. \nExample: if some variable N is randomly selected between \\[10,50\\](inclusive), just use:\n\n`int N = randomInt(10, 50);`\n\n#### Command line parameters\nAll command line parameters are parsed by the __MarathonController__ class. Most of the code to handle common parameter options are also implemented by the controller or base tester classes.\n\nProblem specific parameters can be obtained from the __parameters__ class variable.\nIncluded in the problem specific parameters are main test cases random variables, that could be __overridden__ by competitors, using command line parameters, to test specific types of cases. Example: if the problem has a grid of size S, between 10 and 50 inclusive the code could be something like:\n```\nint S = randomInt(10, 50);\nif (parameters.isDefined(\"S\")) S = randomInt(parameters.getIntRange(\"S\"));\n```\n\nSo after implementing the regular code to generate, it is recommended to add this feature for the random parameters that would make sense to force a specific value or range. It should be just one extra line of code for each parameter.\nNote that even if a single value is specified by the competitor (using -S 50), __randomInt(parameters.getIntRange())__ will work as expected. So the tester code should always be implemented in the way shown in the example, which allows both ranges and single values. Similar methods are available for doubles.\n\nIt is also possible to enforce the limits, so the user specified range is trimmed to be contained in the regular range. That is important when out of range values will certainly lead to error, so they would be useless.  Same example, with range enforcement. In this case, if __-S 40,100__ is used, the range would be \\[40,50\\], i.e. the intersection between valid range (\\[10,50\\]) and user specified range (\\[40,100\\]).\n```\n   int S = randomInt(minSize, maxSize); //Using constants is better\n   if (parameters.isDefined(\"S\")) {\n       S = randomInt(parameters.getIntRange(\"S\"), minSize, maxSize);\n   }\n```\n\n#### Time Control\nTime control is mostly implemented by __MarathonTester__ base class. This includes timeout control and time measure. Concrete implementations should call __startTime()__ right before waiting for output produced by the solution. And call __stopTime()__ right after reading all solution output. \nThese functions can be called multiple times, for interactive problems. The time control will accumulate the elapsed time. It always needs to be called in pairs (start/stop), without starting again the timer before stopping it. \nIt is typically called inside the __callSolution()__ method, as in the following example:\n```\nprivate String[] callSolution() throws Exception {\n    writeLine(size);\n    writeLine(numColors);\n    flush();\n    if (!isReadActive()) return null;\n\n    startTime(); // <-- Start here\n\n    int n = readLineToInt(-1);\n    if (n < 0) {\n        setErrorMessage(\"Invalid number of moves: \" + getLastLineRead());\n        return null;\n    }\n\n    String[] ret = new String[n];\n    for (int i = 0; i < n; i++) {\n        ret[i] = readLine();\n    }\n\n    stopTime(); // <-- Stop when solution finished returning everything\n    return ret;\n }\n```\n#### Input/Output\nOutput (writing data that will be read by the solution) and input (reading solution's answer) should use methods implemented by __MarathonTester__ base class. These  functions take care of where to read from (solution or an input file) and where to write to (solution and/or an output file). \n\nAs can be seen in the example code above, to __write__:\n- __writeLine()__ writes a string or a single integer.\n- __flush()__ when writing is done.\n\nFor reading: \n- __readLine()__ reads a full line to a String\n\n- __readLineToInt()__ reads a full line and converts the content into a single integer. An exception will be thrown if it is not an integer value.\n\n- __readLineToInt(int invalid)__ same as before, but returns the specified invalid value when it is unable to parse an integer value.\n\n- __readLineToIntArr()__ a convenience method that reads a full line, with space-separated integers, and returns an integer array.\n\n- __getLastLineRead()__ can be used to get the content of the last read line, usually to create an error message.\n\n- __isReadActive()__ before starting reading (and after writing all possible input), the tester should call this function to check if there is any active read source. Otherwise it should return immediately. This will happen when the tester is called without -exec and -loadSolOutput options.\n\n#### Main Method\nThe tester should run the __main()__ method, just calling the __MarathonController__:\n```\npublic static void main(String[] args) {\n    new MarathonController().run(args);\n}\n```\n\nWhen building the tester JAR, this should be the execution entry point.\n\n#### Visualization and Painting\nThe base class __MarathonVis__ takes care of things like creating a frame, finding its correct size, and adjusting its layout. \nUsing a standard way of displaying information makes it possible that visualizers work in any screen resolution and allows smooth window content resizing, without extra effort in the contest-specific part of the code. The visualizer is divided in two parts: the __content__ panel and the __information__ panel, as shown below.\n\n![panel](//images.ctfassets.net/piwi0eufbb2g/WNdAPr45K91MheDkGrSh6/1b4e559054bc5d0b5c95764127fff273/panel.png)\n \nThe content is painted by the contest-specific tester, while the info panel is painted by the MarathonVis, using information provided by the specific tester. \n\n__Initialization__\nIn the beginning of the run() method, the tester implementation should call three methods that will provide information to MarathonVis about the desired layout:\n```\n    if (hasVis()) {\n        setInfoMaxDimension(20, 12);\n        setContentRect(0, 0, w, h);\n        setDefaultSize(30);\n    }\n```\nThe first one (__setInfoMaxDimension__) sets the number of columns and rows of text that the information panel will contain. These numbers don't need to be exact, just an approximate upper bound that will reserve enough space for the displayed information. \n\nThe second one (__setContentRect__) sets the desired logical coordinates of the content area. Later, all painting will use these coordinates, as explained below.\n\nThe last one, which is optional, will set the default size in pixels of one content unit. It is the default value equivalent to the size specified in the command line option -sz. If it is not set, it will use the standard value 0, which means fit to screen.\n\nIt is important to note that the tester can call __hasVis()__ method to check if visualization is enabled (i.e. if it wasn't disabled by the command line option -__novis__), and avoid running unnecessary parts of the code. \n\n__Information Panel__\nAs mentioned, the information panel is painted by the base class. The tester implementation should call the following functions to provide the information to be displayed:\n\n__addInfo(Object key, Object value)__ this will display \"key: value\" in the info panel. If it is called multiple times, it updates the respective value, without adding a new row of information.\n\n__addInfo(Object key)__ displays a centralized \"key\" (useful for section titles).\n\n__addInfoBreak()__ skips one line of text, to separate sections of information.\n\nIn the following example, it is possible to see the calls made to build the information panel shown:\n\n![seed](//images.ctfassets.net/piwi0eufbb2g/30eXLGYY7SxglWVIC9yZoN/36340cacbb68b1ea364593091748af21/seed.png)\n\nIn the case of an animated visualizer, after processing each step of the solution, fields like steps and score can be updated by simply calling __addInfo()__ again, with the new values, only for fields that changed. In the previous example, an update after each step would have:\n```\naddInfo(\"Steps\", currStep + \" / \" + numSteps);\naddInfo(\"Score\", getScore());\naddInfo(Color.red, 12);\naddInfo(Color.blue, 9);\naddInfo(Color.green, 11);\n```\nThese functions receive Objects as parameters. The default behavior is just to convert the content to a String, but it is possible to create different visual representations for other types of objects. Currently, there is support for objects of the Color class, which are displayed as small squares filled with the Color object value.\n\n__Content Panel__\nThe tester should implement the abstract method __paintContent()__. As the desired coordinates were already specified, inside this method there is no need to worry about borders, window dimension or the information panel. All painting should be made inside the __contentRect__ previously set.\n\nIf the problem deals with a __w__ x __h__ grid and __contentRect__ was set to (0, 0, w, h), some examples of painting:\n\nFill with blue the left half of the grid area:\n```\n    Rectangle2D rc = new Rectangle2D.Double(0, 0, w / 2, h);\n    g.setColor(Color.blue);\n    g.fill(rc);\n```\nFill with red the cell grid with coordinates x = 2, y = 3 (i.e. the third column and fourth row):\n```\n    Rectangle2D rc = new Rectangle2D.Double(2, 3, 1, 1);\n    g.setColor(Color.red);\n    g.fill(rc);\n```\nDraw a line connecting the center of grid cells (1,3) and (8,0):\n```\n    Line2D line = new Rectangle2D.Double(1.5, 3.5, 8.5, 0.5);\n    g.setStroke(new BasicStroke(0.03f, BasicStroke.CAP_ROUND,\n                BasicStroke.JOIN_ROUND));\n    g.draw(line);\n```\nNote that line thickness (stroke) also uses the current coordinate system, so it should be specified as a proportion of a grid unit (in this example, 3% of the size of a grid cell).\n\n__Update__\nAfter the initial setup and whenever the tester wants to __update__ the visualization content, it should call the update() method. This method already checks whether the visualization is enabled, so it can be called without checking __hasVis()__. \n\n__Lock__\nAs painting is asynchronous, the tester should make all updates to state class variables inside a synchronized block, on the object __updateLock__, already created for this purpose,  to avoid painting intermediate (and possibly invalid) states in the middle of a transition. \n\n__Paint Text in the Content Panel__ \\[NEW\\]\nAs explained above, a coordinate transformation is applied to the __Graphics2D__ object, making painting content easier (no need to worry about borders, offsets, size parameter, the actual window dimensions and so on). \nAlthough positioning text inside the visualizer content is simple (and follows the same idea used for any graphical component), setting the font size can be tricky. \nTwo methods were added to __MarathonVis__ class, to make this task much simpler:\n\n- __adjustFont__: receives the font that will be used, but instead of specifying its size directly, it will inform the maximum (larger) string that will be painted and a rectangle that this string should fit. For example, if number with up to 3 digits will be displayed inside each grid cell, the call should be something like:\n\n     adjustFont(g, Font.SANS_SERIF, Font.PLAIN, \n               \"000\", new Rectangle2D.Double(0, 0, 0.6, 0.6));\n\n- Note that the rectangle size used is 0.6 (instead of 1.0) to leave a margin. This method should be called inside paintContent(), only once for each group of strings that will use the same font.\n\n- __drawString__: instead of receiving x,y coordinates, it will receive a rectangle that will \"contain\" the string. The text will be drawn centralized (both horizontally and vertically) in the specified rectangle.\n\nAn example of __paintContent__ implementation, that will produce the following grid:\n\n![Screenshot 2020-06-26 16:46:53](//images.ctfassets.net/piwi0eufbb2g/cksNhdhBhrJ70Nlqnwue6/d63d6a651873d27519bf1e96611d39b0/Screenshot_2020-06-26_16_46_53.png)\n\n```\n    protected void paintContent(Graphics2D g) {\n        adjustFont(g, Font.SANS_SERIF, Font.PLAIN, \n                   \"000\", new Rectangle2D.Double(0, 0, 0.6, 0.6));\n        for (int y = 0; y < size; y++) {\n            for (int x = 0; x < size; x++) {\n                Rectangle2D rc = new Rectangle2D.Double(x, y, 1, 1);\n                g.setColor(color[y][x]);\n                g.fill(rc);\n                g.setColor(Color.black);\n                g.draw(rc);\n                drawString(g, String.valueOf(x + y * size), rc);\n            }\n        }\n        g.setStroke(new BasicStroke(0.04f, BasicStroke.CAP_ROUND,\n                    BasicStroke.JOIN_ROUND));\n        g.setColor(Color.black);\n        for (int i = 0; i <= size; i++) {\n            g.draw(new Line2D.Double(0, i, size, i));\n            g.draw(new Line2D.Double(i, 0, i, size));\n        }\n    }\n```\n#### Animated Visualizers \nFor problems with animation, in which intermediate states are displayed, the base class __MarathonAnimatedVis__ takes care of delays and pausing.\n\nAll that tester implementation needs to do is call __updateDelay()__ whenever it wants to update the visualizer. It will automatically pause or delay depending on the current state/configuration. \n\nInside the loop that processes each step of the solution, the tester should call __hasDelay()__ (usually together with __hasVis()__) to check if it is necessary to repeat calculations (like updating the current score) after each step. The __hasDelay()__ function returns __false__ if delay is zero, which means no intermediate states should be updated.\n\nIn the beginning of the __run()__ method, tester implementations can call __setDefaultDelay(int delay)__ to set the default delay between each step.\n\n__Paint Performance \\[NEW\\]__\nTo help checking if visualizer content rendering is fast enough, especially when there are many intermediate states to be drawn, it is possible to use the command line parameter __-paintInfo (or -pi)__. It will print (console standard output) how many times visualizer content was painted and the average time of each paint (in milliseconds).  \n\n#### A Complete Example\nHere is a complete (and working) example of an animated visualizer, with additional comments in important places.\n\nIt is a very simple problem called __ShortestPath__. There is a grid, and two distinct randomly chosen cells on it. The goal is to move from the start cell to the target cell. The score, which should be minimized, is the squared number of steps the solution takes to reach the target.\n\n![Screenshot 2020-06-26 16:50:54](//images.ctfassets.net/piwi0eufbb2g/cZlZCH7bXskXJB84pf841/905e319e67421e43805eafe03f3291b7/Screenshot_2020-06-26_16_50_54.png)\n\n```\nimport java.awt.*;\nimport java.awt.geom.*;\nimport com.topcoder.marathon.*;\n\npublic class ShortestPathTester extends MarathonAnimatedVis {\n    //Ranges\n    private static final int minSize = 8, maxSize = 50;\n \n    //Constraints\n    private static final int maxSteps = 10000;\n \n    //Inputs\n    private int size;\n    private int x0, y0, x1, y1; \n\n    //State control\n    private int xp, yp;\n    private int step;\n \n    //Generate the test case (override an abstract method of MarathonTester) \n    protected void generate() {\n        size = randomInt(minSize, maxSize);\n\n        //Special cases for seed 1 and 2\n        if (seed == 1) {\n            size = minSize;\n        } else if (seed == 2) {\n            size = maxSize;\n        }\n \n        //User defined parameters\n        if (parameters.isDefined(\"N\")) size = randomInt(parameters.getIntRange(\"N\"), \n                                                        minSize, maxSize);\n \n        //Generate distinct start and target positions\n        x0 = randomInt(0, size - 1);\n        y0 = randomInt(0, size - 1);\n        do {\n            x1 = randomInt(0, size - 1);\n            y1 = randomInt(0, size - 1);\n        } while (x0 == y0 && x1 == y1);\n\n        if (debug) {\n            System.out.println(\"N = \" + size);\n            System.out.println(\"start = \" + x0 + \",\" + y0);\n            System.out.println(\"target = \" + x1 + \",\" + y1);\n        }\n    }\n \n    //Return false as the goal here is to minimize the score \n    //(override an abstract method of MarathonTester) \n    protected boolean isMaximize() {\n        return false;\n    }\n \n    //Run the solution (override an abstract method of MarathonTester) \n    protected double run() throws Exception {\n        //Initialization\n        init();\n        int score = getErrorScore();\n\n        //Call the solution and check its return\n        String[] ret = callSolution();\n        if (ret == null) {\n            if (!isReadActive()) return getErrorScore();\n            return fatalError();\n        }\n        if (ret.length > maxSteps) return fatalError(\"Your solution exceed the maximum number of\"\n                                + \" steps \" + maxSteps + \" steps (returned \" + ret.length + \")\");\n \n        //Initial update\n        if (hasVis() && hasDelay()) {\n            addInfo(\"Steps\", 0 + \" / \" + ret.length);\n            updateDelay();\n        }\n\n        //Loop through all steps\n        while (step < ret.length) {\n            //Updates to state class variables should be done inside a synchronized block\n            synchronized (updateLock) {\n                String s = ret[step++];\n                if (debug) System.out.println(\"Step \" + step + \": \" + s);\n                if (s.length() != 1) return fatalError(\"Step \" + step + \" does not contain\"\n                                                       + \"exactly one character:\" + s);\n \n                //Process one step, checking invalid moves and out of bounds\n                char c = s.charAt(0);\n                int x = xp;\n                int y = yp;\n                if (c == 'U') y--;\n                else if (c == 'D') y++;\n                else if (c == 'R') x++;\n                else if (c == 'L') x--;\n                else return fatalError(\"Step \" + step + \" contains an invalid move: \" + c);\n                if (y < 0 || x < 0 || y >= size || x >= size) {\n                    return fatalError(\"Step \" + step + \" moved out of bounds.\");\n                }\n    \n                //Update current position\n                xp = x;\n                yp = y;\n            }\n\n            //Update if necessary (hasVis and (hasDelay or it is the last step))\n            if (hasVis() && (hasDelay() || step == ret.length)) {\n                score = step * step;\n                if (step == ret.length && (xp != x1 || yp != y1)) score =  getErrorScore();\n                synchronized (updateLock) {\n                    addInfo(\"Steps\", step + \" / \" + ret.length);\n                    addInfo(\"Score\", score);\n                }\n                updateDelay();\n            }\n        }\n        return score;\n    }\n \n    //Paint the content panel (override an abstract method of MarathonVis) \n    protected void paintContent(Graphics2D g) {\n        //Fill grid background\n        Rectangle2D rc = new Rectangle2D.Double(0, 0, size, size);\n        g.setColor(Color.white);\n        g.fill(rc);\n\n        //Fill start and target cells\n        rc = new Rectangle2D.Double(x0, y0, 1, 1);\n        g.setColor(Color.red);\n        g.fill(rc);\n        rc = new Rectangle2D.Double(x1, y1, 1, 1);\n        g.setColor(Color.blue);\n        g.fill(rc);\n         \n        //Draw grid\n        g.setStroke(new BasicStroke(0.04f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));\n        g.setColor(Color.black);\n        for (int i = 0; i <= size; i++) {\n            g.draw(new Line2D.Double(0, i, size, i));\n            g.draw(new Line2D.Double(i, 0, i, size));\n        }\n \n        //Current position\n        Ellipse2D e = new Ellipse2D.Double(xp + 0.1, yp + 0.1, 0.8, 0.8);\n        g.setColor(new Color(0, 0, 0));\n        g.fill(e);\n        g.setColor(new Color(255, 255, 255));\n        g.draw(e);\n    }\n \n    private void init() {\n        //Initial position\n        xp = x0;\n        yp = y0;\n\n        if (hasVis()) {\n            //Sets the maximum dimension of information panel (number of rows and columns of text)\n            setInfoMaxDimension(18, 9);\n\n            //Set desired coordinates of the content to a squared grid\n            setContentRect(0, 0, size, size);\n\n            //Default size (in pixels) of grid's cell\n            setDefaultSize(30);\n \n            //Default delay (in milliseconds) between visualizer updates\n            setDefaultDelay(100);\n \n            //Create information panel content\n            addInfo(\"Seed\", seed);\n            addInfoBreak();\n            addInfo(\"Size N\", size);\n            addInfo(\"Start\", \"(\" + x0 + \", \" + y0 + \")\");\n            addInfo(\"Target\", \"(\" + x1 + \", \" + y1 + \")\");\n            addInfoBreak();\n\n            //Steps and score will be updated later, while processing solution return\n            addInfo(\"Steps\", \"-\");\n            addInfoBreak();\n            addInfo(\"Score\", \"-\");\n\n            //Call update when done\n            update();\n       }\n    }\n \n    private String[] callSolution() throws Exception {\n        //Write input data\n        writeLine(size);\n        writeLine(x0);\n        writeLine(y0);\n        writeLine(x1);\n        writeLine(y1);\n\n        //Flush when writing is done\n        flush();\n \n        //Check is there is any active read (a running solution or a solution file), \n        //otherwise just return.\n        if (!isReadActive()) return null;\n \n        //Start to measure time spent by the solution\n        startTime();\n\n        //Read from the solution (process or a file) the number of lines\n        int n = readLineToInt(-1);\n        if (n < 0) {\n            setErrorMessage(\"Invalid number of steps: \" + getLastLineRead());\n            return null;\n        }\n\n        //Read each line\n        String[] ret = new String[n];\n        for (int i = 0; i < ret.length; i++) {\n            ret[i] = readLine();\n        }\n\n        //Stop to measure time\n        stopTime();\n\n        return ret;\n    }\n    \n    //Main method should create a MarathonController and call run passing command line arguments\n    public static void main(String[] args) {\n        new MarathonController().run(args);\n    }\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yv3fVxbcdHYRkAr0yrVnS","type":"Entry","createdAt":"2020-06-26T13:17:38.391Z","updatedAt":"2021-02-04T05:39:58.059Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Wladimir Leite","tcHandle":"wleite","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}}],"upvotes":5,"downvotes":0}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1aZUzDDhRT41AXcOHTs9yh","type":"Entry","createdAt":"2019-09-18T07:37:09.134Z","updatedAt":"2019-09-18T07:37:09.134Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Interview","trackParent":"Design"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1bK2HNQwLuojOTW8pVbUhv","type":"Entry","createdAt":"2020-06-12T18:32:11.783Z","updatedAt":"2020-06-12T18:32:11.783Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Support","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1fINVUJiGA2nwaeRASuMfq","type":"Entry","createdAt":"2021-11-05T10:44:34.241Z","updatedAt":"2023-09-06T14:46:54.663Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":46,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Merlion Library for AutoML Forecasting Using Python","slug":"merlion-library-for-automl-forecasting-using-python","type":"Article","trackCategory":["Data Science"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"55HiOMbEVXarc2fnfuAOuN","type":"Entry","createdAt":"2019-09-18T07:37:47.286Z","updatedAt":"2019-09-18T07:37:47.286Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Machine Learning Tools & Libraries","trackParent":"Data Science"}}],"tags":["Python"],"creationDate":"2021-11-05","readTime":"15min","content":"### Introduction:\n\nThere are a large number of Python AutoML libraries for fasting and simplifying machine learning tasks, such as H20, Pycaret Automl, and more. Here we are going to discuss salesforce Merlion library which has more features than some other libraries.\n\n1.  It supports univariate and multivariate time series forecasting.\n\n2.  It automatically detects outliers and anomalies.\n\n3.  It supports hyperparameter tuning.\n\n4.  It has inbuilt ensemble techniques.\n\n5.  It has an automatic visualization part.\n\nThis library’s main aim is to provide fast and accurate machine learning models for their specific time series problem.\n\nThere are several modules to boost ease-of-use, including visualization, anomaly score calibration to boost interpretability, AutoML for hyperparameter tuning and model selection, and model ensembling.\n\n![image](//images.contentful.com/piwi0eufbb2g/6A6zhuVdnEMyW16a079JK9/53a49359fd5e9ffc68238421e158fe02/image.png)\n\n### Installation:\n\nMerlion has two main sub-libraries on its ts\\_datasets for loading time series datasets and machine learning processes like data processing, data visualization, anomaly detection, hyperparameter tuning, data forecasting, etc..\n\nThis library loads data in the form of pandas.DataFrame.\n\nYou can simply install the library by calling Pypi features in your command prompt or anaconda prompt - pip install salesforce-merlion. You can also install by visiting the official Github page of salesforce-merlion at this [Link](https://github.com/salesforce/Merlion). \n\nThen move on to the next part, which is installing external dependencies of this library. You can see this simply below.\n\n![image](//images.contentful.com/piwi0eufbb2g/Nc4ElPeYZXpLiAkdHLEpm/55db43690bf2f3c5f9e863b50982390b/image.png)\n\n1.  As we are working on ensemble modeling in this library, we also need to install the lightgbm using a simple pip install lightgbm.\n\n2.  Now we are working on anomaly detection so we also need to install the Java development kit, jdk using pip install openjdk.\n\n### Getting started:\n\nHere we see some practical implementation of Merlion’s library using a time series dataset of Merlion’s inbuilt dataset importing library.\n\n#### 1. Anomaly Detection:\n\nBegin by importing Merlion’s time series data using the data loader method. Anomalies mean outliers. Outliers are those data points which do not lie properly in our data distribution.\n\n```python\nfrom merlion.utils import TimeSeries\nfrom ts_datasets.anomaly import NAB\ntime_series, metadata = NAB(subset=\"realKnownCause\")[3]\ntrain_data = TimeSeries.from_pd(time_series[metadata.trainval])\ntest_data=TimeSeries.from_pd(time_series[~metadata.trainval])\ntest_labels=TimeSeries.from_pd(metadata.anomaly[~metadata.trainval])\n```\n\nNow before doing anomaly detection, we initialize our data model parameters then insert data into it.\n\n```python\nfrom merlion.models.defaults import DefaultDetectorConfig, DefaultDetector\nmodel = DefaultDetector(DefaultDetectorConfig())\nmodel.train(train_data=train_data)\ntest_pred = model.get_anomaly_label(time_series=test_data)\n```\n\nWe call the Merlion library visualization function. Using it we can see various parameters of our data objectively like stationarity, seasonality, trends, outliers, cyclicity, etc..\n\n```python\nfrom merlion.plot import plot_anoms\nimport matplotlib.pyplot as plt\nfig, ax = model.plot_anomaly(time_series=test_data)\nplot_anoms(ax=ax, anomaly_labels=test_labels)\nplt.show()\n```\n\n![image](//images.contentful.com/piwi0eufbb2g/5cJ7Fjk3UzHzRggFr11Oqq/671fd15666e75f357514db55558baf7b/image.png)\n\n### Evaluating Model:\nMerlion also has a model evaluation function in it where we can get the accuracy score, precision and recall, and more results of our model performance.\n\n```python\nfrom merlion.evaluate.anomaly import TSADMetric\np = TSADMetric.Precision.value(ground_truth=test_labels, predict=test_pred)\nr = TSADMetric.Recall.value(ground_truth=test_labels, predict=test_pred)\nf1 = TSADMetric.F1.value(ground_truth=test_labels, predict=test_pred)\nmttd = TSADMetric.MeanTimeToDetect.value(ground_truth=test_labels, predict=test_pred)\nprint(f\"Precision: {p:.4f}, Recall: {r:.4f}, F1: {f1:.4f}\\n\"\n      f\"Mean Time To Detect: {mttd}\")\n```\n\n### Forecasting:\nThis is the final and most important function of our Merlion library. We can forecast future data values on the basis of a date index. In this model we will initialize all the parameters of our library functions. \n\n```python\nfrom merlion.utils import TimeSeries\nfrom ts_datasets.forecast import M4\n\n# Data loader returns pandas DataFrames, which we convert to Merlion TimeSeries\ntime_series, metadata = M4(subset=\"Hourly\")[0]\ntrain_data = TimeSeries.from_pd(time_series[metadata.trainval])\ntest_data = TimeSeries.from_pd(time_series[~metadata.trainval])\nfrom merlion.models.defaults import DefaultForecasterConfig, DefaultForecaster\nmodel = DefaultForecaster(DefaultForecasterConfig())\nmodel.train(train_data=train_data)\ntest_pred, test_err = model.forecast(time_stamps=test_data.time_stamps)\n```\n\nAfter building the model we will visualize our complete prediction model.\n\n```python\nimport matplotlib.pyplot as plt\nfig, ax = model.plot_forecast(time_series=test_data, plot_forecast_uncertainty=True)\nplt.show()\n```\n\n![image](//images.contentful.com/piwi0eufbb2g/1NjlrH0CJB14BQT1Kr9dUv/15cfc69749ba81ee4f55e4516b667921/image.png)\n\nBelow is a summary of the above steps that we used for model forecasting.\n\n1.  Initialize a forecasting model (including ensembles and automatic model selectors) \n\n2.  Train the model\n\n3.  Produce a forecast with the model Visualizing \n\n4.  View the model’s predictions \n\n5.  Quantitatively evaluate the model \n\n6.  Save and load a trained model \n\n7.  Simulate the live deployment of a model","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7nzds1n2pv6LnYvwPgOO5V","type":"Asset","createdAt":"2021-11-05T10:38:00.136Z","updatedAt":"2023-09-06T14:45:27.235Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Merlion","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7nzds1n2pv6LnYvwPgOO5V/b365b1e6360ba6b21ac0aefe3a76ff14/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"phRCEOBFWzgGECLgjgpy6"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3EkFoVBEiQkBrkaWBgtOgT"}},{"sys":{"type":"Link","linkType":"Entry","id":"5Hf36i5Tn2gtfg0IjPeS0W"}},{"sys":{"type":"Link","linkType":"Entry","id":"3djlLWefn7rdC6Pqjhdclx"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1gvfA0GoFuKPxGlSFhPL6P","type":"Entry","createdAt":"2020-02-28T19:56:11.253Z","updatedAt":"2021-04-28T14:04:08.574Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":15,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"kphmd","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1oYlk9lUxTwEDGuQo80etF","type":"Entry","createdAt":"2019-11-25T19:12:49.106Z","updatedAt":"2019-11-25T19:12:49.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Jaya Dhaka","tcHandle":"jaya.dhaka"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1zHxqubLKz2yYjNp00hFBu","type":"Entry","createdAt":"2019-09-18T07:37:46.512Z","updatedAt":"2019-10-15T16:13:07.041Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Lewin Gan","tcHandle":"lg5293"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"26IApFU2X6pFV4vm9UgqMO","type":"Entry","createdAt":"2019-09-18T07:37:45.247Z","updatedAt":"2019-10-15T16:12:49.080Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Bhagvan Kommadi","tcHandle":"bhagvanarch"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"26YGMSUIj6nj3lzQPhM1HM","type":"Entry","createdAt":"2019-12-17T10:05:01.265Z","updatedAt":"2019-12-17T10:05:01.265Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Ayan Sengupta","tcHandle":"ayan007"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2FyFPuf9ftL4DguU4YFcoe","type":"Entry","createdAt":"2020-02-19T12:59:58.263Z","updatedAt":"2022-07-11T04:33:32.572Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":148,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Find a Solution","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["SRM","Flood Fill","Problem","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"30 min","content":"[Discuss this article in the forums.](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505843)\n<br/>\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#straightforward\">Straight-forward problems that don’t require a special technique</a>\n<a href=\"#bfs\">Breadth First Search (BFS)</a>\n<a href=\"#floodfill\">Flood Fill</a><\n<a href=\"#bruteNback\">Brute Force and Backtracking</a>\n<a href=\"#bruteforce\">Brute Force</a>\n<a href=\"#backtracking\">Backtracking</a>\n<a href=\"#dp\">Dynamic Programming</a>\n<a href=\"#harddrills\">Hard Drills</a>\n<a href=\"#maximumflow\">Maximum Flow</a>\n<a href=\"#optimal\">Optimal Pair Matching</a>\n<a href=\"#lp\">Linear Programming (Simplex)</a>\n<a href=\"#conclusion\">Conclusion</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nWith many Topcoder problems, the solutions may be found instantly just by reading their descriptions. This is possible thanks to a collection of common traits that problems with similar solutions often have. These traits serve as excellent hints for experienced problem solvers that are able to observe them. The main focus of this article is to teach the reader to be able to observe them too.\n\\\n<a name=\"straightforward\" id=\"straightforward\"></a> __Straight-forward problems that don’t require any special technique (e.g. simulation, searching, sorting etc.)__\n\tIn most cases, these problems will ask you to perform some step by step, straight-forward tasks. Their constraints are not high, and not too low. In most cases the first problems (the easiest ones) in topcoder Single Rounds Matches are of this kind. They test mostly how fast and properly you code, and not necessarily your algorithmic skills.\n\\\nMost simple problems of this type are those that ask you just to execute all steps described in the statement.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BusinessTasks](http://community.topcoder.com/stat?c=problem_statement&pm=1585&rd=6535) – SRM 236 Div 1:__\nN tasks are written down in the form of a circular list, so the first task is adjacent to the last one. A number n is also given. Starting with the first task, move clockwise (from element 1 in the list to element 2 in the list and so on), counting from 1 to n. When your count reaches n, remove that task from the list and start counting from the next available task. Repeat this procedure until one task remains. Return it.\n</div>\n\\\nFor N&lt;=1000 this problem is just a matter of coding, no special algorithm is needed – do this operation step by step until one item is left. Usually these types of problems have a much smaller N, and so we’ll not consider cases where N is very big and for which complicated solution may be needed. Remember that in topcoder competitions even around 100 millions sets of simple operations (i.e. some multiplications, attributions or if statements) will run in allowed time.\n\\\nThis category of problems also includes those that need some simple searches.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[TallPeople](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2923&amp;rd=5854) – SRM 208 Div 1:__\nA group of people stands before you arranged in rows and columns. Looking from above, they form an R by C rectangle of people. Your job is to return 2 specific heights – the first is computed by finding the shortest person in each row, and then finding the tallest person among them (the \"tallest-of-the-shortest\"); and the second is computed by finding the tallest person in each column, and then finding the shortest person among them (the \"shortest-of-the-tallest\").\n</div>\n\\\nAs you see this is a really simple search problem. What you have to do is just to follow the steps described in the statement and find those 2 needed heights. Other TC problems may ask you to sort a collection of items by respecting certain given rules. These problems may be also included in this category, because they too are straight-forward – just sort the items respecting the rules! You can do that with a simple O(N^2) sorting algorithm, or use standard sorting algorithm that exist in your coding language. It’s just a matter of coding.\n<br/>\n__Other example(s):__\n\t__[MedalTable](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2922&amp;rd=5855) – SRM 209 Div 1__.\n<br/>\n\\\n<a name=\"bfs\" id=\"bfs\"></a> __Breadth First Search (BFS)__\n\nProblems that use BFS usually ask to find the fewest number of steps (or the shortest path) needed to reach a certain end point (state) from the starting one. Besides this, certain ways of passing from one point to another are offered, all of them having the same cost of 1 (sometimes it may be equal to another number). Often there is given a N x M table (formed of N lines and M columns) where certain cells are passable and others are impassable, and the target of the problem is to find the shortest time/path needed to reach the end point from the start one. Such tables may represent mazes, maps, cities, and other similar things. These may be considered as classical BFS problems. Because BFS complexity is in most cases linear (sometimes quadratic, or N logN), constraints of N (or M) could be high – even up to 1 million.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[SmartWordToy](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3935&amp;rd=6532) – SRM 233 Div 1:__\nA word composed of four Latin lowercase letters is given. With a single button click you can change any letter to the previous or next letter in alphabetical order (for example ‘c’ can be changed to ‘b’ or ‘d’). The alphabet is circular, thus ‘a’ can become ‘z’, and ‘z’ can become ‘a’ with one click.<br/>\nA collection of constraints is also given, each defining a set of forbidden words. A constraint is composed of 4 strings of letters. A word is forbidden if each of its characters is contained in corresponding string of a single constraint, i.e. first letter is contained in the first string, the second letter – in the second string, and so on. For example, the constraint \"lf a tc e\" defines the words \"late\", \"fate\", \"lace\" and \"face\".<br/>\nYou should find the minimum number of button presses required to reach the word finish from the word start without passing through forbidden words, or return -1 if this is not possible.\n</div>\n\\\n__Problem hints:__\n* Words can be considered as states. There are at most 26^4 different words composed of 4 letters (thus a linear complexity will run in allowed time).\n* There are some ways to pass from one state to another.\n* The cost of passing from a state to another is always 1 (i.e. a single button click).\n* You need to find the minimum number of steps required to reach the end state from start state.\n\nEverything indicates us that it’s a problem solved by the help of a BFS. Similar things can be found in any other BFS problems. Now let’s see an interesting case of BFS problems.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[CaptureThemAll](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2915&amp;rd=5853) – SRM 207 Div 2 (3rd problem):__\nHarry is playing a chess game. He has one knight, and his opponent Joe has a queen and a rook. Find the minimum number of steps that Harry’s knight has to jump so that it captures both the queen and the rook.\n</div>\n\n__Problem hints:__ At first sight this may seem like dynamic programming or backtracking. But as always, take a look into the text of the statement. After a while you should observe the following things: \n\n* A table is given.\n* The knight can jump from one cell to some of its neighbors.\n* The cost of passing from a cell to another is always 1 (just one jump).\n* You need to find the minimum number of steps (jumps).\n\nGiven this information we can see that the problem can be easily solved by the help of BFS. Don’t get confused by the fact that connected points are represented by unconnected cells. Think of cells as points in a graph, or states (whatever you want) – and in order to pass from one point to another, the knight should be able to jump from the first to the second point.\n\nNotice again that the most revealing hint about the BFS solution is the cost of 1 for any jump.\n\nTrain yourself in finding the hints of a BFS problem in following examples:\n\n__Other example(s):__\n__[RevolvingDoors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3064&amp;rd=5869) – SRM 223 Div 1__.\n__[WalkingHome](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3444&amp;rd=5868) – SRM 222 Div 1__.\n__[TurntableService](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3117&amp;rd=5865) – SRM 219 Div 1__.\n<br/>\n\\\n<a name=\"floodfill\" id=\"floodfill\"></a> __Flood Fill__\nSometimes you may encounter problems that are solved by the help of Flood Fill, a technique that uses BFS to find all reachable points. The thing that makes them different from BFS problems described above is that a minimum path/cost is not needed.\nFor example, imagine a maze where 1 represents impassable cells and 0 passable cells. You need to find all cells that are reachable from the upper-left corner. The solution is very simple – take one-by-one a visited vertex, add its unvisited neighbors to the queue of visited vertices and proceed with the next one while the queue is still populated. Note that in most cases a DFS (Depth First Search) will not work for such problems due to stack overflows. Better use a BFS. For inexperienced users it may seem harder to implement, but after a little training it becomes a \"piece of cake\". A good example of such problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[grafixMask](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2998&amp;rd=5857) – SRM 211 Div 1:__\nA 400 x 600 bitmap is given. A set of rectangles covers certain parts of this bitmap (the corners of rectangles have integer coordinates). You need to find all contiguous uncovered areas, including their sizes.\n</div>\n\n__Problem hints:__ What do we have here?\n* A map (table)\n* Certain points are impassable (those covered by given rectangles)\n* Contiguous areas need to be found\n\nIt is easy to understand that a problem with such a statement needs a Flood Fill. Usually problems using it are very easy to detect.\n\\\n<a name=\"bruteNback\" id=\"bruteNback\"></a> __Brute Force and Backtracking__\nI have placed these 2 techniques in the same category because they are very similar.  Both do the same thing – try all possible cases (situations) and choose the best one, or count only those that are needed (depending on the problem). Practically, Backtracking is just more advanced and optimized than Brute Force. It usually uses recursion and is applied to problems having low constraints (for example N&lt;=20). </p>\n\\\n<a name=\"bruteforce\" id=\"bruteforce\"></a>\n__Brute Force__\nThere are many problems that can be solved by the help of a simple brute force. Note that the limits must not be high. How does a brute force algorithm work? Actually, it tries all possible situations and selects the best one. It’s simple to construct and usually simple to implement. If there is a problem that asks to enumerate or find all possible ways (situations) of doing a certain thing, and that doesn’t have high limits – then it’s most probably a brute force problem.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[GeneralChess](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2430&amp;rd=5072) – SRM 197 Div 1:__\nYou are given some knights (at most 8), with their positions on the table (-10000&lt;=x, y&lt;=10000). You need to find all positions to place another one, so that it threatens all given pieces. \n</div>\n\n__Problem hints:__ Well, this is one of the easiest examples. So which are the hints of this statement?\n* You need to find all possible situations (positions) that satisfy a certain rule (threatens all given pieces).\n* The limits are very low – only 8 knights are at most given.\n\nIt’s a common Brute Force problem’s statement. Note that x and y limits are not relevant, because you need only try all positions that threaten one of the knights. For each of these positions see if the knight placed at that position threatens all others too.\n\nAnother interesting problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[LargestCircle](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3005&amp;rd=5858) – SRM 212 Div 2 (3rd problem):__\nGiven a regular square grid, with some number of squares marked, find the largest circle you can draw on the grid that does not pass through any of the marked squares. The circle must be centered on a grid point (the corner of a square) and the radius must be an integer. Return the radius of the circle.\n<br/> The size of the grid is at most 50.\n</div>\n\n__Problem hints:__ And again one of the most important hints is the low limit of the size of the grid – only 50. This problem is possible to be solved with the help of the Brute Force because for each cell you can try to find the circle whose center is situated in that cell and that respects the rules. Among all of these circles found, select the one that has the greatest radius.\n\nComplexity analysis: there are at most 50×50 cells, a circle’s radius is an integer and can be at most 25 units, and you need a linear time (depending on your implementation) for searching the cells situated on the border of the circle. Total complexity is low and thus you can apply a simple Brute Force here.\n\n__Other example(s):__\n__[Cafeteria](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3080&amp;rd=6518) - SRM 229 Div 1__\n__[WordFind](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3972&amp;rd=6521) - SRM 232 Div 1__\n\n<a name=\"backtracking\" id=\"backtracking\"></a> __Backtracking__\nThis technique may be used in many types of problems.  Just take a look at the limits (N, M and other main parameters). They serve as the main hint of a backtrack problem. If these are very small and you haven’t found a solution that’s easier to implement – then just don’t waste your time on searching it and implement a straight-forward backtracking solution.\n\nUsually problems of this kind ask you to find (similarly to Brute Force):\n1. Every possible configuration (subset) of items. These configurations should respect some given rules.\n2. The \"best\" configuration (subset) that respects some given rules.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BridgeCrossing](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1599&amp;rd=4535) – SRM 146 Div 2 (3rd problem):__\nA group of people is crossing an old bridge. The bridge cannot hold more than two people at once. It is dark, so they can’t walk without a flashlight, and they only have one flashlight! Furthermore, the time needed to cross the bridge varies among the people in the group. When people walk together, they always walk at the speed of the slowest person. It is impossible to toss the flashlight across the bridge, so one person always has to go back with the flashlight to the others. What is the minimum amount of time needed to get all the people across the bridge?\n<br/> There are at most 6 people.\n</div>\n\n__Problem hints:__\n* First look at the constraints – there are at most ONLY 6 people! It’s enough for generating all possible permutations, sets etc.\n* There are different possible ways to pass the people from one side to another and you need to find the best one.\n\nThis is of course a problem solved with a backtracking: at the beginning choose any 2 people to pass the bridge first, and after that at each step try to pass any of those that have been left on the start side. From all these passages select the one that needs the smallest amount of time. Note that among persons that have passed over the bridge, the one having the greatest speed should return (it’s better than returning one having a lower speed). This fact makes the code much easier to implement. After having realized these things – just code the solution. There may be others – but you will lose more time to find another than to code this one.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[MNS](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – SRM 148 Div 1:__\n9 numbers need to be arranged in a magic number square. A magic number square is a square of numbers that is arranged such that every row and column has the same sum. You are given 9 numbers that range from 0 to 9 inclusive. Return the number of distinct ways that they can be arranged in a magic number square. Two magic number squares are distinct if they differ in value at one or more positions. \n</div>\n\n__Problem hints:__ Only 9 numbers are given at most; and every distinct way (configuration) to arrange the numbers so that they form a magic number square should be found.\n\nThese are the main properties of a Backtracking problem. If you have observed them – think about the code. You can generate all permutations of numbers and for each of them check if it forms a magic square. If so – add it to the answer. Note that it must be unique. A possible way to do that – is to have a list of earlier found configurations, thus for each new magic square check if it exists in that list and if it doesn’t – add it to the answer. There will not be many distinct magic squares, thus no additional problems will appear when applying this method.\n\n__Other example(s):__\n\n__[WeirdRooks](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3998&amp;rd=6533) - SRM 234 Div 1__\n\\\n<a name=\"dp\" id=\"dp\"></a> __Dynamic Programming__\nQuite a few problems are solved with the help of this technique. Knowing how to detect this type of problem can be very valuable.  However in order to do so, one has to have some experience in dynamic programming. Usually a DP problem has some main integer variables (e.g. N) which are neither too small, nor too big – so that a usual DP complexity of N^2, N^3 etc. fits in time. Note that in the event that N is very small (for TC problems usually less than 30) – then it is likely the problem is not a DP one. Besides that there should exist states and one or more ways (rules) to reach one greater state from another lower one.  In addition, greater states should depend only upon lower states. What is a so-called state? It’s just a certain configuration or situation. To better understand dynamic programming, you may want to read [this article](http://community.topcoder.com/tc?module=Static&amp;d1=tutorials&amp;d2=dynProg).\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nLet’s analyze a simple classic DP problem:<br/>\nGiven a list of N coins with their values (V1, V2, … ,VN), and the total sum S. Find the minimum number of coins the sum of which is S (you can use as many coins of one type as you want), or report that it’s not possible to select coins in such a way that they sum up to S.<br/>\nLet N &lt;= 1,000 and S &lt;= 1,000.\n</div>\n\n__Problem hints:__\n* Two main integer variables are given (N and S). These are neither too small, nor are they too big (i.e. a complexity of N*S fits in time).\n* A state can be defined as the minimum number of coins needed to reach a certain sum.\n* A sum (state) i depends only on lower sums (states) j (j&lt;i).\n* By adding a coin to a certain sum – another greater sum is reached. This is the way to pass from one state to another.\n\nThus all properties of a DP problem are uncovered in this statement. Let’s see another (slightly harder) DP problem:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[ZigZag](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – 2003 TCCC Semifinals 3:__\nA sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a zig-zag sequence. Given a sequence of integers, return the length of the longest subsequence that is a zig-zag sequence. A subsequence is obtained by deleting some number of elements (possibly zero) from the original sequence, leaving the remaining elements in their original order. Assume the sequence contains between 1 and 50 elements, inclusive. \n</div>\n\n__Problem hints:__\n* There are N numbers given (1&lt;=N&lt;=50), thus N isn’t too small, nor too big.\n* A state (i,d) can be defined as the length of the longest zig-zag subsequence ending with the i-th number, for which the number before the last one is smaller than it for d=0, and bigger for d=1.\n* A state i (i.e. a subsequence ending with the i-th number) depends only on lower states j (j&lt;i).\n* By adding a number to the end of a subsequence – another bigger (greater) subsequence is created. This is the way to pass from one state to another.\n\nAs you can see – this statement has almost the same traits (pattern) as in the previous problem. The most difficult part in identifying a DP problem statement is observing/seeing the states with the properties described above. Once you can do that, the next step is to construct the algorithm, which is out of the scope of this article.\n\n__Other example(s):__\n__[ChessMetric](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1592&amp;rd=4482) - 2003 TCCC Round 4__\n__[AvoidRoads](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1889&amp;rd=4709) - 2003 TCO Semifinals 4__\n__[FlowerGarden](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1918&amp;rd=5006) - 2004 TCCC Round 1__\n__[BadNeighbors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2402&amp;rd=5009) - 2004 TCCC Round 4__\n\\\n<a name=\"harddrills\" id=\"harddrills\"></a> __Hard Drills:__\n<a name=\"maximumflow\" id=\"maximumflow\"></a> __Maximum Flow__\n\nIn many cases it’s hard to detect a problem whose solution uses maximum flow.  Often you have to create/define graphs with capacities based on the problem statement.\n\nHere are some signs of a Maximum Flow problem:\n* Take a look at the constraints, they have to be appropriate for a O(N^3) or O(N^4) solution, i.e. N shouldn’t be greater than 500 in extreme cases (usually it’s less than 100).\n* There should be a graph with edges having capacities given, or you should be able to define/create it from data given in the statement.\n* You should be finding a maximum value of something.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nSample problem:<br/>\nYou are given a list of water pipes, each having a certain maximum water flow capacity. There are water pipes connected together at their extremities. <br/>\nYou have to find the maximum amount of water that can flow from start junction to end junction in a unit of time. <br/>\nLet N&lt;=100. <br/>\n</div>\n\nAs you can see – it’s a straight-forward maximum flow problem: water pipes represent edges of the graph, their junctions – vertices; and you have to find the maximum value of amount of water that can flow from start to end vertex in a unit of time.\n\\\n<a name=\"optimal\" id=\"optimal\"></a> __Optimal Pair Matching:__\nThese problems usually have a list of items (from a set A) for which other items (from a set B) should be assigned under some rules, so that all (or a maximum possible number of) items from set A have to each be assigned to a certain item from set B.\n\n__Mixed:__\nSome problems need other techniques in addition to network flows.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Parking](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3530&amp;rd=6535) - SRM 236 Div 1:__\nN cars and M parking lots are given. They are situated on a rectangular surface (represented by a table), where certain cells are impassable. You should find a way to assign each car to a parking lot, so that the greatest of the shortest distances from each car to its assigned parking lot is as small as possible. Each parking lot can have at most one car assigned to it. \n</div>\n__Problem hints:__ By reading this problem one can simply understand the main idea of the solution – it should be something similar to optimal pair matching, because each car (point from a set A) should be assigned to a parking lot (point from a set B) so that all are assigned and that there is at most one car assigned to a parking lot. Additionally, there can be cars that can’t reach certain parking lots, thus some pairs of points (one point from A and the other from B) are not connected. However a graph should be created for optimal pair matching. The way to make it is clear – an edge exists between a car and a parking lot if only there is a path between them, and its cost is equal to the shortest distance needed for the car to reach the parking lot. The next step of the solution is a binary search on the longest edge. Although it may be out of the scope of this article, I will provide a short explanation: At each step delete those edges of the initial graph that have costs greater than a certain value C (Note that you’ll have to save the initial graph’s state in order to repeat this step again for other C values). If it’s possible in this case to assign all the cars to parking lots – then take a smaller C, and repeat the same operation. If not – take a greater C. After a complete binary search, the smallest C for which a complete assignment is possible will be found. This will be the answer.\n\\\n<a name=\"lp\" id=\"lp\"></a> __Linear Programming (Simplex)__\nMost of the common traits of problems solved with the help of the linear programming technique are:\n* You are given collection of items having different costs/weights. There is a certain quantity of each item that must be achieved.\n* A list of sets is given. These sets are composed of some of the available items, having certain quantities of each of them. Each set has a certain cost. \n* The goal of the problem is to find an optimal combination (the cheapest one) of these sets so that the sum of quantities of each of the items they have is exactly the one needed to achieve.\n\nAt first it may seem confusing, but let’s see an example:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Mixture](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3942&amp;rd=6520) - SRM 231 Div 1:__\nA precise mixture of a number of different chemicals, each having a certain amount, is needed. Some mixtures of chemicals may be purchased at a certain price (the chemical components for the mixture might not be available in pure form). Each of them contains certain amounts of some of the chemicals. You need not purchase the available mixtures in integral amounts. Hence if you purchase a 1.5 of a mixture having a price of 3 and amounts of \"2 0 1\", you’ll pay 4.5 and get \"3 0 1.5\" amounts of chemicals. Your task is to determine the lowest price that the desired mixture can be achieved. \n</div>\n__Problem hints:__\n* A collection of items (chemicals).\n* A list of sets (available mixtures), each containing certain amounts of each of the items, and having a certain cost.\n* You need to find the lowest price of the desired collection of items achieved by the combination of the available sets. More than that – you can take also non-integral amounts of mixtures.\n\nThese are exactly the traits described above.\n\\\n<a name=\"conclusion\" id=\"conclusion\"></a>\n__Conclusion__\nIf you have found this article interesting and you have learned new things from it – train yourself on any of the problems in the topcoder Algorithm Arena. Try hard to see the hints and determine the type of the solution by carefully reading through the problem statement. Remember, there are still many problems that may not be included properly in any of the categories described above and may need a different approach.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":27,"downvotes":1}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2MZf5yPIlVLprsO8F9FNEo","type":"Entry","createdAt":"2019-12-13T16:59:16.647Z","updatedAt":"2019-12-13T16:59:16.647Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Marathon Match","trackParent":"Data Science"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2Sp9m6GVboExtjXPfmLLPL","type":"Entry","createdAt":"2022-06-14T17:47:28.502Z","updatedAt":"2022-06-14T17:47:28.502Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Joseph Chege","tcHandle":"kimkimani"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2TKYKf2Q8PtfYpLSU6RsKB","type":"Entry","createdAt":"2022-07-15T15:52:22.395Z","updatedAt":"2022-07-18T03:50:20.674Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":89,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Python Data Structures - List and Tuples","slug":"python-data-structures-list-and-tuples","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Python","Data Structures"],"creationDate":"2022-07-07","readTime":"10min","content":"Data structures are used for storing and organizing data efficiently. They allow you to quickly access and manipulate the data. Python includes many built-in data structures that enable easy data management. In this article, we will learn about two of Python's most important data structures, lists & tuples.\n\n### Data Structure #1: Lists in Python\n\nThe most flexible data structure in Python is a list. They are used to store a variety of data items, ranging from integers to strings and even another list! They are mutable, meaning their elements can be changed even after the list has been created.\n\n#### Creating Lists\nLists are formed by enclosing elements within [square] brackets and separating each item with a comma.\n\n```python\n#creating a list \ntest_list = ['Engineer', 'Doctor', 'Architect']\nprint (type(test_list))\nprint (test_list)\n```\n\n__output:__\n```python\n<class 'list'>\n['Engineer', 'Doctor', 'Architect']\n```\n\n#### Accessing List Elements\nIndexing is used to access list elements. Each list element has an index corresponding to its position in the list. The first item on the list has an index of 0, the second has an index of 1, and so on. The list's final element has an index that is one less than the list's length.\n\n```python\n#creating a list \ntest_list = ['Engineer', 'Doctor', 'Architect']\nprint (test_list[0])\nprint (test_list[1])\nprint (test_list[2])\n```\n\n__output:__\n```python\nEngineer\nDoctor\nArchitect\n```\n\nThere are a few unique features in the list data structure. \nWe can have duplicate values in the list since each element has its position, and using that, we can access the element.\n\n```python\n#creating a list with duplicate values\ntest_list = ['Engineer', 'Doctor', 'Architect', 'Doctor']\nprint (test_list[1])\nprint (test_list[3])\n```\n\n__output:__\n```python\nDoctor\nDoctor\n```\n\nWe can have different types of values in the same list.\n```python\n#creating a list with different types of values\ntest_list = ['Engineer', 10, 10.5, 'Doctor', -1]\nprint (test_list[1])\nprint (test_list[2])\nprint (test_list[4])\n```\n\n__output:__\n```python\n10\n10.5\n-1\n```\nIn the list, we can access the elements using negative indexes.\n```python\n#accessing the list with negative indexes\ntest_list = ['Engineer', 'lawyer', 'Architect', 'Doctor',' Accountant']\nprint (test_list[-1]) # it will print last element in the list\nprint (test_list[-2])\t # it will print second last element in the list\nprint (test_list[-3]) # it will print third last element in the list\nprint (test_list[-4]) # it will print fourth last element in the list\nprint (test_list[-5]) # it will print fifth last element in the list\n```\n\n__output:__\n```python\nAccountant\nDoctor\nArchitect\nlawyer\nEngineer\n```\n\nWe can return the range of elements between two positions in the list. This concept is called slicing. To return the elements in the range, we need to supply the start and end indexes like this List_name[start : end]. This will print the elements between including the start index and excluding the end index.\n```python\n#accessing the list to return the range of elements\ntest_list = ['Engineer', 'lawyer', 'Architect', 'Doctor',' Accountant']\nprint (test_list[1:3])\nprint (test_list[2:4])\n```\n\n__output:__\n```python\n['lawyer', 'Architect']\n['Architect', 'Doctor',' Accountant']\n```\n#### Appending Values in Lists\nWe can add new members to an existing list using the `append()` or `insert()` methods.\n\n##### `append()`\n\nThis operation will add the particular element to the last position. \n```python\n#appending the elements to the list\ntest_list = ['Engineer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.append('Designer')\nprint (test_list)\n```\n\n__output:__\n```python\n['Engineer', 'lawyer', 'Architect', 'Doctor', 'Accountant', 'Designer']\n```\n\n##### `insert()`\nThis operation will insert the particular element to the specified position.\n```python\n#inserting the elements to the list\ntest_list = ['Engineer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.insert(1, 'Designer')\nprint (test_list)\n```\n\n__output:__\n```python\n['Engineer', 'Designer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\n```\n\n#### Removing Elements From Lists\nUsing the `remove()` or `pop()` methods, we can remove elements from a list just like adding them using `append()` or `insert()`.\n##### `remove()`\nThis operation will remove the first occurrence from the list that matches a specified value.\n```python\n#removing the elements from the list\ntest_list = ['Engineer', 'Designer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.remove('Designer')\nprint (test_list)\n```\n\n__output:__\n```python\n['Engineer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\n```\n\n##### `pop()`\nThis operation will remove an element at a specified index from the list. If no index is specified, then the last element will be removed.\n```python\n#removing the element at the particular index from the list\ntest_list = ['Engineer', 'Designer', 'lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.pop(3)\nprint (test_list)\n```\n__output:__\n```python\n['Engineer', 'Designer', 'lawyer', 'Doctor', 'Accountant']\n```\n\n#### Sorting Lists\nSorting is an important operation in data structures, and we will be using this operation most of the time. In Python, we can use the sort() function and it will allow you to reorder your list either in ascending or descending order.\n\n```python\n#sorting ascending & descending\nprime_numbers = [5,7,2,13,11,3,17]\nprime_numbers.sort()\nprint(prime_numbers)\nprime_numbers.sort(reverse=True)\nprint(prime_numbers)\n```\n\n__output:__\n```python\n[2, 3, 5, 7, 11, 13, 17]\n[17, 13, 11, 7, 5, 3, 2]\n```\n\nBut this is not a straightforward thing when it comes to sorting the list which has string values. These string elements are stored as ASCII values. Each character in the string has an integer value associated with it and with that we use these values to sort the strings.\n```python\ntest_list = ['Engineer','Designer', 'Lawyer', 'Architect', 'Doctor', 'Accountant']\ntest_list.sort()\nprint(test_list)\ntest_list.sort(reverse=True)\nprint(test_list)\n```\n\n__output:__\n```python\n['Accountant', 'Architect', 'Designer', 'Doctor', 'Engineer', 'Lawyer']\n['Lawyer', 'Engineer', 'Doctor', 'Designer', 'Architect', 'Accountant']\n```\n\n#### Concatenating Lists\nTwo or more lists can be concatenated using the '+' symbol. This will return a single list with two or more lists combined.\n\n```python\n#concatenating two lists\ntest_list1 = ['Engineer', 'Designer', 'Lawyer']\ntest_list2 = ['Architect', 'Doctor', 'Accountant']\ntest_list = test_list1 + test_list2\nprint(test_list)\n```\n\n__output:__\n```python\n['Engineer', 'Designer', 'Lawyer', 'Architect', 'Doctor', 'Accountant']\n```\n\n##### List Comprehensions\nList comprehension offers a convenient method of producing new lists. By performing an operation on each element of an existing list, these new lists are generated.\n\n```python\nnum = [1,2,3,4]\ncube = []\nfor x in num:\n\tcube.append(x**3)\nprint(cube)\n```\n\n__output:__\n```python\n[1, 8, 27, 64]\n```\n\nThe above traditional for-loop can be concisely written into a single line of code using list comprehensions.\n\n```python\nnum = [1,2,3,4]\ncube = [x**3 for x in num]\nprint(cube)\n```\n\n__output:__\n```python\n[1, 8, 27, 64]\n```\n\n#### Stacks & Queues Using Lists\nPython comes with a built-in data structure called a list. However, we can employ it to produce custom data structures. Stacks and queues are two extremely well-liked user-defined data structures created using lists.\n\n##### Stacks\nStacks are lists of elements where new elements are added at the start of the list or removed at the end of the list. Imagine it as a pile of books. You always work your way up the stack whenever you need to add or remove a book. It employs the straightforward Last-In-First-Out principle.\n\n```python\nstack = [1,2,3,4]\nstack.append(5)\nprint(stack)\nstack.pop()\nprint(stack)\n```\n\n__output:__\n```python\n[1, 2, 3, 4, 5]\n[1, 2, 3, 4]\n```\n\n##### Queue\nOn the other hand, a queue is a list of elements in which new elements are added to the end of the list and old elements are removed from the front of the list. It is comparable to standing in a line in the real world. The line gets shorter as those at the front of the line leave. It gets longer when a new person joins the queue from the back. It takes advantage of the First-In-First-Out principle.\n\n```python\nqueue = [1,2,3,4]\nqueue.append(5)\nprint(queue)\nqueue.pop(0)\nprint(queue)\n```\n\n__output:__\n```python\n[1, 2, 3, 4, 5]\n[2, 3, 4, 5]\n```\n\n### Data Structure #2: Tuples in Python\nAnother well-liked built-in data structure in Python is the tuple. These are quite similar to lists with one exception - their immutability. \nThis implies that a tuple cannot be modified or added to after it has been formed. Let's see how to create a tuple in Python and how to play with it below.\n\n#### Creating Tuples in Python\nYou can create tuples by enclosing data in parenthesis and separating each piece with a comma. You can create a tuple even if you write a number of items in a row without any parenthesis and assign them to a variable.\n\n```python\ncountry = ('india','canada','u.s.a')\nprint(type(country))\nprint(country)\ncurrency = (85, 'inr', 'usd', 'cad')\nprint(type(currency))\nprint(currency)\n\n<class 'tuple'>\n('india', 'canada', 'u.s.a')\n<class 'tuple'>\n(85, 'inr', 'usd', 'cad')\n```\n\nNow that we have created tuples let's see about their immutable nature.\n\n#### Immutability of Tuples\nImmutable in Python refers to something that cannot be changed after creation. The two types of objects in the Python programming language are mutable and immutable.\nLists, dictionaries, and sets are examples of mutable objects which can be altered after creation. We shall explore these in the following sections. In contrast, immutable objects include integers, floating-point numbers, boolean values, strings, and tuples. What, then, makes them unchangeable?\nEverything in Python is an object. As a result, we may check an object's memory address using the built-in id() method. This is known as the identity of the object. Let's make a list then locate the list and all of its components.\n\n```python\nthislist = [\"apple\", \"banana\", \"cherry\"]\nprint(id(thislist))\nprint(id(thislist[0]))\n```\n\n__output:__\n```python\n47251449707712\n47251450601840\n```\nYou can see that the list and its elements are stored in different parts of memory. We can change the value of a list's elements since we know that lists are mutable. Let's try that and watch how the location values change.\n\n```python\nthislist[0] = \"grape\"\nprint(id(this list))\nprint(id(thislist[0]))\n```\n\n__output:__\n```python\n47251449707712\n47251450602288\n```\n\nThe element's location changed, but the list's placement remained the same. It denotes the creation of a new object for the element and its saving in the list. The term \"mutable\" refers to this. An immutable object cannot change its state or contents after being created, although a mutable object may.\n\nTuples are called pseudo-immutable; though they are immutable they can contain mutable objects whose values can be modified.\n\n```python\nmytuple = (1,2,3,[4,5,6])\nprint(id(mytuple))\nprint(id(mytuple[-1]))\n```\n\n__output:__\n```python\n22916022675872\n22916023512128\n```\n\n```python\nmytuple[-1].append(7)\nprint(id(mytuple))\nprint(id(mytuple[-1]))\nprint(mytuple)\n```\n\n__output:__\n```python\n22916022675872\n22916023512128\n(1, 2, 3, [4, 5, 6, 7])\n```\n\nAs the above code exhibits, we can alter the values of immutable objects, i.e., the list contained within the tuple.\n\n#### Tuple Assignment and Changing Tuples Values\nWith tuple packing and unpacking, we can assign values to a tuple of elements from another tuple in a single line.\n\n```python\nmytuple = (\"apple\", \"banana\", \"cherry\")\na,b,c = mytuple\nprint(a)\nprint(b)\nprint(c)\n```\n\n__output:__\n```python\napple\nbanana\ncherry\n```\n\nAlthough tuple values cannot be modified, you can alter them by turning them into a list with list(). When you are finished with your data processing, you can use the tuple function to convert it back to a tuple().\n\n```python\nmytuple = (\"apple\", \"banana\", \"cherry\")\nconv_list = list(mytuple)\nprint(type(conv_list))\nconv_list.append(\"grape\")\nprint(conv_list)\ntuple_fruits = tuple(conv_list)\nprint(type(tuple_fruits))\nprint(tuple_fruits)\n```\n\n__output:__\n```\n<class 'list'>\n['apple', 'banana', 'cherry', 'grape']\n<class 'tuple'>\n('apple', 'banana', 'cherry', 'grape’)\n```\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3NYB2aT7Gq3kJRqScz4IPw","type":"Asset","createdAt":"2022-07-08T03:28:13.117Z","updatedAt":"2023-09-14T11:30:09.820Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3NYB2aT7Gq3kJRqScz4IPw/7478abbc77e49c6af713855f234d3e34/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"34zIQNVTXVHI5WguauMsWx","type":"Entry","createdAt":"2020-12-18T08:52:04.288Z","updatedAt":"2024-07-15T11:27:39.055Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":26,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Getting Started with Python","slug":"getting-started-with-python","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"sys":{"type":"Link","linkType":"Entry","id":"Caw9t2fdYN3diW6ITAg20"}}],"tags":["Python"],"creationDate":"2020-12-18","readTime":"15min","content":"This article will cover almost everything you need to get started with Python. Python has become one of the most popular programming languages and is used every day by programmers to do cool things like automate, build applications and websites like Instagram, and it is used in Artificial Intelligence (AI). \nNo one is too old or too young to learn Python. Python is very easy to learn.\n\n### Installing Python:\n1. Download Python from this link -> https://www.python.org/downloads/.\n2. Install after downloading the latest Python from the above link.\n3. Don't forget to click on check Add Python 3.x to PATH.\n\n### About IDEs:\n\nIDE stands for Integrated Development Environment. It enables programmers to combine different aspects of writing code. IDEs increase programmer’s productivity by simplifying common activities in a single application like editing source code, debugging and building executables. There are different IDEs available like PyCharm, VS Code, Sublime text, and IDLE (default).\n\n#### Why PyCharm and why it is better than other IDEs?\n\n1. The intelligent code editor provided by PyCharm enables programmers to write a high quality Python code.\n2. The editor enables programmers to read code easily through color schemes, and auto indents on new lines automatically.\n3.The smart code navigation option provided by PyCharm helps programmers to edit and improve the code quality without putting in extra time. It makes both local and global changes very quickly and efficiently.\n4. PyCharm comes with a local terminal which enables the programmers to continue coding and testing without leaving the IDE.\n\n### Setting up IDE for Python:\n1. Download [PyCharm from this link](https://www.jetbrains.com/pycharm/download/#section=windows).\n2. Install Pycharm.\n3. Click on the new Project.\n4. Make sure in Project Interpreter, the base interpreter is set to your installed python version.\n\n![Screenshot 2020-12-18 10:34:50](//images.ctfassets.net/piwi0eufbb2g/1wV1DfEV8hT5wDDyZj2DTV/4da57cec5900cac1f30d4f2151ea9378/Screenshot_2020-12-18_10_34_50.png)\n\nWriting First Python Program\n\n1. Right-click on the new project created.\n2. New -> Python File\n3. Give `<Filename>.py`\n4. Type print(‘This is my first python program’)\n5. Click on run\n\n![Screenshot 2020-12-18 10:35:51](//images.ctfassets.net/piwi0eufbb2g/1Dyo4GsyUZhRip5edJY73y/23cfe00eaccf612469264ab2904ab6f2/Screenshot_2020-12-18_10_35_51.png)\n\nPython executes the program line by line.\n\nFor reference,users can read documentation at: [Read Docs](https://docs.python.org/release/3.7.9/tutorial/index.html) and can also read sample codes here: [Samples](https://www.programiz.com/python-programming/examples)\n\n### Python Variables:\n\nVariables are used in programming languages to temporarily store data in a computer's memory.\nFor example:\n\n![Screenshot 2020-12-18 10:37:01](//images.ctfassets.net/piwi0eufbb2g/353KBMKnGCzDjuktxdkmx3/454676aeddbc4853c1583473aa3de5f2/Screenshot_2020-12-18_10_37_01.png)\n\nWhen Python interpreter executes this code, it will allocate some memory and thenstore the number 29 in the memory and attach 29 to the label age. \n\nInteger, float, string, and Boolean are the data types in Python.\n\n![Screenshot 2020-12-18 10:37:48](//images.ctfassets.net/piwi0eufbb2g/nFeimIQyg8S3JJYPhgVEJ/ef1843ecbc96877d6add45be82d67c10/Screenshot_2020-12-18_10_37_48.png)\n\n### PYTHON STRINGS:\nA string is a sequence of characters. To make a string, we may enclose a sequence of characters between single, double, or triple quotes. \nThus, 'Hello world', ' \"Hello \" ', \"what's \", '''today's \"action\" plan?''' are the examples of strings.\n\n```\nprint('Hello world')\nprint(\"What’s \")\nprint('''today's plan?''' )\n```\n\n![Screenshot 2020-12-18 10:38:40](//images.ctfassets.net/piwi0eufbb2g/7d4mD9wE1aKcFpbBtCUATb/e61ddd9a765d34a00eb9c149c71ed5b0/Screenshot_2020-12-18_10_38_40.png)\n\n### OPERATORS IN PYTHON\n#### RELATION OPERATORS\nThese operators are used to compare two expressions and returns either true or false. These are greater than (>), less than (<), equals to (==), greater than equal to (>=), less than equal to (<=), not equal to (! =), they can be used for any data types.\n\n![Screenshot 2020-12-18 10:39:32](//images.ctfassets.net/piwi0eufbb2g/407HxnRem5pjDqpWAZFlln/27be9c3a569080cfa0a6e4c83f86f0d1/Screenshot_2020-12-18_10_39_32.png)\n\n#### LOGICAL OPERATORS:\n\nThe logical operators not, and, and or are applied to logical operands true and false, also called Boolean values, and yield either true or false. Not is an unary operator it requires only one operand.\n\n*and operator – It returns true only when both the expressions are true else false.\n* or operator – It returns true if any one of the expressions is true else false.\n* not operator – It returns the opposite of the expression.\n\n![Screenshot 2020-12-18 10:40:22](//images.ctfassets.net/piwi0eufbb2g/6d5P3wcGfvG6bL2Quq3Svn/8dae71553bf9f529112a74f43e53dd67/Screenshot_2020-12-18_10_40_22.png)\n\n#### BITWISE OPERATORS\n\nBitwise operators are the operators that operate on integers interpreted as strings of binary digits 0 and 1, also called bits. \n\n- Bitwise and (&)\n- Bitwise or (|)\n- Bitwise complement (~)\n- Bitwise Exclusive to (^)\n- Left Shift (<<)\n- Right Shift (>>)\n\n### BUILT-IN FUNCTIONS\nBuilt-in functions are the predefined functions that are already available in Python.\n#### input() function:\n\nThe function input enables us to accept an input string from the user without evaluating its value. The function input continues to read input text from the user until it encounters a new line, for example:\n\n![Screenshot 2020-12-18 10:41:45](//images.ctfassets.net/piwi0eufbb2g/1PW2GbdDTIrH8AfZvB0jPz/561a646839d771020b204a4268d79d60/Screenshot_2020-12-18_10_41_45.png)\n\n#### eval() function:\nThis function is used to evaluate the value of the string.\n\n![Screenshot 2020-12-18 10:42:24](//images.ctfassets.net/piwi0eufbb2g/1nFikLmcT7D536zYKGlMJQ/2d0bdbe70974f0c2e87ca9d3d91ca744/Screenshot_2020-12-18_10_42_24.png)\n\n#### print() Function:\n\nprint() function enables us to produce output in Python. Print function can also have an escape sequence which can print different types of data at a time separating the values with a comma.\n\n![Screenshot 2020-12-18 10:42:59](//images.ctfassets.net/piwi0eufbb2g/2Hr4yvbGcRptANb9Bg0pq9/39db8912b78a16c7edfe309a976fc3b6/Screenshot_2020-12-18_10_42_59.png)\n\n#### Other functions:\n__type() Function:__ It returns the data type of the parameter.\n\n![Screenshot 2020-12-18 10:43:37](//images.ctfassets.net/piwi0eufbb2g/21w2aN0Mjnw17PjcJVBiuy/29709a67ace01dcf3905f830074eb4a4/Screenshot_2020-12-18_10_43_37.png)\n\n__max(), min() Function:__ It returns the maximum and minimum value of the data given.\n\n![Screenshot 2020-12-18 10:44:31](//images.ctfassets.net/piwi0eufbb2g/7HRLB4ZcZw0dpg8nDeBQy3/e4e652dbd0e8fc6d6241c013ec452759/Screenshot_2020-12-18_10_44_31.png)\n\n__round() Function:__ It rounds the value of the parameter and returns the  rounded value.\n\n![Screenshot 2020-12-18 10:45:21](//images.ctfassets.net/piwi0eufbb2g/63GkyF8v9j8Xb6o0GV9Ujq/d74a747800523ac66c1acd8d3187bb77/Screenshot_2020-12-18_10_45_21.png)\n\n__pow() Function:__ It takes two values, number and exponent, and returns number to the power of exponent.\n\n![Screenshot 2020-12-18 10:46:49](//images.ctfassets.net/piwi0eufbb2g/7iu4RXIjHDf0HBCbkFGQnH/9c013dac26c084558cd3399947a1a109/Screenshot_2020-12-18_10_46_49.png)\n\n[HERE IS A LIST OF OTHER BUILT-IN FUNCTIONS](https://docs.python.org/3/library/functions.html#float)\n\nTry it yourself:\n1. Create a variable name which will take the input from the user and print it.\n2. Print the maximum and minimum values out of four values.\n3. Input five values and print their respective data types.\n4. Input two numbers x and y and print x raised to power y.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3kNHPHf18iXXpDrqcCvljE"}}],"upvotes":25,"downvotes":0}},{"sys":{"type":"Link","linkType":"Entry","id":"6GBXhy7l8ghq5l4eIZSLDp"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7jXzj0Re46Izgnuy04I5X8","type":"Entry","createdAt":"2022-07-15T15:51:22.672Z","updatedAt":"2022-07-25T02:36:55.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":122,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","slug":"python-data-structures-strings","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"1XKgff9ovQ0Qb7cPbG37Un"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Python","Data Structures"],"creationDate":"2022-07-07","readTime":"10min","content":"Data structures are used to store and organize data efficiently. They allow you to quickly access and manipulate the data. Python includes many built-in data structures for easy data management.\nIn this article we will learn about one of Python's most important data structures: Strings. \n\nWorking on real-world projects will make you realize how significant strings are as a data type in Python. Since working with strings seems simple but solving problems is complex, the majority of problem statements in interviews and written examinations are based on string manipulation.\nIn this article we cover everything about strings.\n\n### Brief Overview of Python String Data Type\n\nStrings are a collection of Unicode characters that are used specifically in Python. A string is the language or text we use to communicate. However, machines can only read binary, they cannot comprehend text. As a result, ASCII numbers are initially generated from characters before being transformed to binary representation. However, ASCII is exclusively used for the English language, and when programming languages are used in other nations, they are translated to 16-bit characters known as Unicode.\n\n##### Creating Strings\n\nPython offers several methods for creating strings, including single, double, and triple quotes. When constructing a string, if the string contains any kind of quote, you should use a separate kind of quote in the declaration to prevent an error. Try the example below in any Python IDE or code editor for a better understanding.\n\n```python\ns = 'Good Morning' #single quotes\ns = 'It's been a great day' #syntax error (It confuses where string starts and ends)\ns = \"It's been a great day\" #correct way\ns = '''Good Morning''' #multi-line strings\n```\n\nWhen declaring or referencing a lengthy paragraph use triple quotes. Any other data type can be declared as a string or converted using an internal function.\n\n```python\na = 99 #int\nprint(str(a)) #int to str\n```\n\n##### Accessing Substring from String\n\nTo address a specific use case, it may occasionally be essential to access portions of a string. We shall discuss indexing and slicing, which enable us to extract a specific section of the text as output.\n\n#### Indexing\n\nIndexing a string with zeros is the same as indexing an array. Simply put, the zero indexes in a string represent the first character, and as the index rises, the string advances. Positive and negative indexing are the two categories of indexing in Python.\n\n##### Positive Indexing\n\nPositive indexing is moving from zero to the end length of a string. It is also known as zero-based indexing.\n\n```python\ns = 'GoodMorning' \nprint(s[0])  \nprint(s[2])  \nprint(s[4])  \nprint(s[len(s)-1]) \nprint(len(s))\n```\n\n__output:__\n```python\nG\no\nM\ng\n11\n```\n\n__Note__: If access s(11), program returns a Index error\n\n##### Negative Indexing\n\nAccessing string elements using a negative index means going backward in time. It usually  takes a long time to access the last character in a string if we use positive indexing since we have to calculate the length of the string and then take one off of it. In this situation, we can just use the negative indexing.\n\n```python\ns = 'GoodMorning' \nprint(s[-1])  \nprint(s[-2])\n```\n__output:__\n```python\ng\nn\n```\n\n##### Slicing\nThe concept of slicing, which is accomplished using the colon operator, comes into play when we have long strings, such as sentences or paragraphs, and we want to access specific pieces, like whole words, but we cannot do so merely using indexing. To ensure that the output is a portion of the string from a start index to an end index less one, we must specify the starting index and end index in square brackets that are separated by colons.\n\n```python\ns = 'Good Morning' \nprint(s[1:4])\n```\n\n__output:__\n```python\nood\n```\n\nStart with the first index in the example above and retrieve the character all the way to the third index. Now that there are various slicing variations, let's examine them practically using the code sample below.\n\n```python\ns = 'GoodMorning' \nprint(s[1:])  \nprint(s[:4])\nprint(s[:])\nprint(s[0:8:3])\nprint(s[::-1])\n```\n\n__output:__\n```python\noodMorning\t\t#It will print the entire string starting from index 1\nGood\t\t\t#It will print the entire string starting from index 0 to 3\nGoodMorning\t\t#It will print the entire string \nGdr\t\t\t\t#It will print zero index and skip two index and take third index till eighth index\ngninroMdooG #It will print the string in reverse order\n```\n\n### Editing and Deleting Python Strings\n\nSince strings in Python are immutable data types, attempting to change one will result in a type error. The existing string cannot be changed or added to, but it can be assigned to a separate variable to produce a new string. Let's examine the practical effects of deleting and altering strings to see whether we experience any errors.\n\nSince strings are immutable, we cannot directly reassign the value of the particular string in the below snippet.\n\n```python\ns = 'GoodMorning' \ns[0] = \"M\" \t\t #This operation is not allowed and it will return not support Item assignment error\n\n```\n\nInstead, the below combination will work\n\n```python\ns = 'GoodMorning' \na = \"M\" + s[1:]\t \nprint(a) \n```\n\n__output:__\n```python\nMoodMorning\n```\n\nDeleting the strings won't work well and the below statements will generate errors saying we can't delete the string.\n\n```python\ndel s[0]    \ndel s[:3:2] \n```\n\nIt is crucial to comprehend that strings cannot be changed; nothing can be added or removed from an existing string.\n\n### Operations on Python String\n\n#### Arithmetic Operations\n\n##### Addition(+)\n\nConcatenation, as it is also known, allows us to link any amount of strings by using the addition operator.\n\n```python\ns = \"Good\" + \"-\" + \"Morning\"\nprint(s) \n```\n__output:__\n```python\nGood-Morning\n```\n\n##### Multiplication(*)\n\nTo repeat a certain string before the multiplication operator any number of times is known as string repetition. When we want a pattern, we use it.\n\n```python\ns = \"Good\" \nprint(s*3) \n```\n__output:__\n```python\nGoodGoodGood\n```\n\n#### Relational Operations \n\nRelational operators display the relationship between two terms and determine whether a particular condition is true or false, producing a boolean result.\n```python\nprint(\"Hello\" == \"World\")  \nprint(\"Hello\" != \"World\")  \n```\n__output:__\n```python\nFalse\nTrue\n```\n\nWhen we apply the larger than and less than operators the situation becomes more intriguing.\n```python\nprint(\"Mumbai\" > \"Pune\")  \nprint(\"Goa\" < \"Indore\") \n```\n\n__output:__\n```python\nFalse\nTrue\n````\n\nYou might be wondering how it compares two strings. As a result, it lexicographically compares a string. As P follows M in the alphabetical order in the first case, the statement is false. Lowercase characters are placed after uppercase because occasionally people mistake the two case types.\n\n#### Logical Operations\nWhen you use the AND, OR, and NOT logical operators on strings, Python returns false for empty strings and true for non-empty strings.\n\n```python\nprint(\"Hello\" and \"World\") #True and True -> True (O/P -> World)\nprint(\"\" and \"World\") #False and True -> False (O/P -> \"\")\nprint(\"\" or \"World\") #False OR True -> True (O/P -> \"World\")\nprint(not \"Hello\") #opposite of True -> False\nprint(not \"\") #True\n```\n\n##### Loops\nSlicing allows us to loop over strings starting at any index. To access distinct characters or create a pattern in a string, we can use both a where and a for loop.\n\n```python\ns = 'GoodMorning' \nfor i in s:\n\tprint(i)\n```\n\n__output:__\n```python\nG\no\no\nd\nM\no\nr\nn\ni\nn\ng\n```\n\n#### Membership Operators\nPython's in and NOT in membership operators are used to determine whether any element is present in any sequence data structure.\n\n```python\ns = 'GoodMorning' \nif 'M' in s:\n\tprint('true')\n```\n__output:__\n```python\ntrue\n```\n\n### Python String Functions\nThe most important parts of a string are string functions which you use everywhere whenever you build any project. Now we will study all-important string functions which are frequently used.\nCommon Functions:\n\nThese are the same functions that are available for all other iterator data types, including list, tuple, set, and string.\n\n1. length - It provides the string's length.\n2. minimum - This function returns the smallest character in a string, as determined by ASCII.\n3. maximum - The largest character found in the string, as determined by ASCII, is provided by the third option, maximum.\n4. sorted - The string is sorted in either ascending or descending order using the ASCII character sequence. This function always returns a list of characters as its result.\n\n```python\ns = 'GoodMorning' \nprint(len(s))\nprint(min(s))\nprint(max(s))\nprint(sorted(s))\nprint(sorted(s,reverse=True))\n```\n\n__output:__\n```python\n11\nG\nr\n['G', 'M', 'd', 'g', 'i', 'n', 'n', 'o', 'o', 'o', 'r']\n['r', 'o', 'o', 'o', 'n', 'n', 'i', 'g', 'd', 'M', 'G']\n```\n\n#### Some Specific Purpose Functions in Strings\nThe functions we'll look at here only work with strings.\n\n##### Title or capitalize\nThe title function capitalizes the first letter of each word, whereas the capitalize function capitalizes the first letter of a string.\n```python\ns = \"its raining outside\"\nprint(s.capitalize()) #O/P -> Its raining outside\nprint(s.title()) \t #O/P -> Its Raining Outside\n```\n\n##### Upper / lower / swap case\nIn string each character is converted in the upper function to lowercase characters. Swap case changes an upper to a lower case character, and vice versa.\n```python\ns = \"Its Raining Outside\"\nprint(s.upper()) #O/P -> ITS RAINING OUTSIDE\nprint(s.lower()) #O/P -> its raining outside\nprint(s.swapcase()) #O/P -> iTS rAINING oUTSIDE\n```\n\n##### Count\nIt provides the number of any substrings that are present in a string. It outputs 0 if the substring is missing from the string. It is used to determine how often a given substring occurs in a string.\n```python\ns = \"Its Raining Outside\"\nprint(s.count(\"i\")) #3\nprint(s.count(\"ing\")) #1\n```\n\n###### Find / Index\nBoth functions operate in exactly the same manner. Both locate the position of a substring within a string. The sole distinction between the two functions is that while index gives an error when the substring is absent, string find produces a negative value when this occurs.\n```python\ns = \"Its Raining Outside\"\nprint(s.find(\"ing\")) #8\nprint(s.index(\"ing\")) #8\nprint(s.find(\"down\")) #-1\nprint(s.index(\"down\")) #error\n```\n\n### Conclusion\nIn this article we have learned about string literals in Python. We have started by getting ideas about string and covered how to use, create, and play with string and string functions. Hope you enjoyed it. \n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3NYB2aT7Gq3kJRqScz4IPw","type":"Asset","createdAt":"2022-07-08T03:28:13.117Z","updatedAt":"2023-09-14T11:30:09.820Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3NYB2aT7Gq3kJRqScz4IPw/7478abbc77e49c6af713855f234d3e34/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"34zIQNVTXVHI5WguauMsWx","type":"Entry","createdAt":"2020-12-18T08:52:04.288Z","updatedAt":"2024-07-15T11:27:39.055Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":26,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Getting Started with Python","slug":"getting-started-with-python","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"sys":{"type":"Link","linkType":"Entry","id":"Caw9t2fdYN3diW6ITAg20"}}],"tags":["Python"],"creationDate":"2020-12-18","readTime":"15min","content":"This article will cover almost everything you need to get started with Python. Python has become one of the most popular programming languages and is used every day by programmers to do cool things like automate, build applications and websites like Instagram, and it is used in Artificial Intelligence (AI). \nNo one is too old or too young to learn Python. Python is very easy to learn.\n\n### Installing Python:\n1. Download Python from this link -> https://www.python.org/downloads/.\n2. Install after downloading the latest Python from the above link.\n3. Don't forget to click on check Add Python 3.x to PATH.\n\n### About IDEs:\n\nIDE stands for Integrated Development Environment. It enables programmers to combine different aspects of writing code. IDEs increase programmer’s productivity by simplifying common activities in a single application like editing source code, debugging and building executables. There are different IDEs available like PyCharm, VS Code, Sublime text, and IDLE (default).\n\n#### Why PyCharm and why it is better than other IDEs?\n\n1. The intelligent code editor provided by PyCharm enables programmers to write a high quality Python code.\n2. The editor enables programmers to read code easily through color schemes, and auto indents on new lines automatically.\n3.The smart code navigation option provided by PyCharm helps programmers to edit and improve the code quality without putting in extra time. It makes both local and global changes very quickly and efficiently.\n4. PyCharm comes with a local terminal which enables the programmers to continue coding and testing without leaving the IDE.\n\n### Setting up IDE for Python:\n1. Download [PyCharm from this link](https://www.jetbrains.com/pycharm/download/#section=windows).\n2. Install Pycharm.\n3. Click on the new Project.\n4. Make sure in Project Interpreter, the base interpreter is set to your installed python version.\n\n![Screenshot 2020-12-18 10:34:50](//images.ctfassets.net/piwi0eufbb2g/1wV1DfEV8hT5wDDyZj2DTV/4da57cec5900cac1f30d4f2151ea9378/Screenshot_2020-12-18_10_34_50.png)\n\nWriting First Python Program\n\n1. Right-click on the new project created.\n2. New -> Python File\n3. Give `<Filename>.py`\n4. Type print(‘This is my first python program’)\n5. Click on run\n\n![Screenshot 2020-12-18 10:35:51](//images.ctfassets.net/piwi0eufbb2g/1Dyo4GsyUZhRip5edJY73y/23cfe00eaccf612469264ab2904ab6f2/Screenshot_2020-12-18_10_35_51.png)\n\nPython executes the program line by line.\n\nFor reference,users can read documentation at: [Read Docs](https://docs.python.org/release/3.7.9/tutorial/index.html) and can also read sample codes here: [Samples](https://www.programiz.com/python-programming/examples)\n\n### Python Variables:\n\nVariables are used in programming languages to temporarily store data in a computer's memory.\nFor example:\n\n![Screenshot 2020-12-18 10:37:01](//images.ctfassets.net/piwi0eufbb2g/353KBMKnGCzDjuktxdkmx3/454676aeddbc4853c1583473aa3de5f2/Screenshot_2020-12-18_10_37_01.png)\n\nWhen Python interpreter executes this code, it will allocate some memory and thenstore the number 29 in the memory and attach 29 to the label age. \n\nInteger, float, string, and Boolean are the data types in Python.\n\n![Screenshot 2020-12-18 10:37:48](//images.ctfassets.net/piwi0eufbb2g/nFeimIQyg8S3JJYPhgVEJ/ef1843ecbc96877d6add45be82d67c10/Screenshot_2020-12-18_10_37_48.png)\n\n### PYTHON STRINGS:\nA string is a sequence of characters. To make a string, we may enclose a sequence of characters between single, double, or triple quotes. \nThus, 'Hello world', ' \"Hello \" ', \"what's \", '''today's \"action\" plan?''' are the examples of strings.\n\n```\nprint('Hello world')\nprint(\"What’s \")\nprint('''today's plan?''' )\n```\n\n![Screenshot 2020-12-18 10:38:40](//images.ctfassets.net/piwi0eufbb2g/7d4mD9wE1aKcFpbBtCUATb/e61ddd9a765d34a00eb9c149c71ed5b0/Screenshot_2020-12-18_10_38_40.png)\n\n### OPERATORS IN PYTHON\n#### RELATION OPERATORS\nThese operators are used to compare two expressions and returns either true or false. These are greater than (>), less than (<), equals to (==), greater than equal to (>=), less than equal to (<=), not equal to (! =), they can be used for any data types.\n\n![Screenshot 2020-12-18 10:39:32](//images.ctfassets.net/piwi0eufbb2g/407HxnRem5pjDqpWAZFlln/27be9c3a569080cfa0a6e4c83f86f0d1/Screenshot_2020-12-18_10_39_32.png)\n\n#### LOGICAL OPERATORS:\n\nThe logical operators not, and, and or are applied to logical operands true and false, also called Boolean values, and yield either true or false. Not is an unary operator it requires only one operand.\n\n*and operator – It returns true only when both the expressions are true else false.\n* or operator – It returns true if any one of the expressions is true else false.\n* not operator – It returns the opposite of the expression.\n\n![Screenshot 2020-12-18 10:40:22](//images.ctfassets.net/piwi0eufbb2g/6d5P3wcGfvG6bL2Quq3Svn/8dae71553bf9f529112a74f43e53dd67/Screenshot_2020-12-18_10_40_22.png)\n\n#### BITWISE OPERATORS\n\nBitwise operators are the operators that operate on integers interpreted as strings of binary digits 0 and 1, also called bits. \n\n- Bitwise and (&)\n- Bitwise or (|)\n- Bitwise complement (~)\n- Bitwise Exclusive to (^)\n- Left Shift (<<)\n- Right Shift (>>)\n\n### BUILT-IN FUNCTIONS\nBuilt-in functions are the predefined functions that are already available in Python.\n#### input() function:\n\nThe function input enables us to accept an input string from the user without evaluating its value. The function input continues to read input text from the user until it encounters a new line, for example:\n\n![Screenshot 2020-12-18 10:41:45](//images.ctfassets.net/piwi0eufbb2g/1PW2GbdDTIrH8AfZvB0jPz/561a646839d771020b204a4268d79d60/Screenshot_2020-12-18_10_41_45.png)\n\n#### eval() function:\nThis function is used to evaluate the value of the string.\n\n![Screenshot 2020-12-18 10:42:24](//images.ctfassets.net/piwi0eufbb2g/1nFikLmcT7D536zYKGlMJQ/2d0bdbe70974f0c2e87ca9d3d91ca744/Screenshot_2020-12-18_10_42_24.png)\n\n#### print() Function:\n\nprint() function enables us to produce output in Python. Print function can also have an escape sequence which can print different types of data at a time separating the values with a comma.\n\n![Screenshot 2020-12-18 10:42:59](//images.ctfassets.net/piwi0eufbb2g/2Hr4yvbGcRptANb9Bg0pq9/39db8912b78a16c7edfe309a976fc3b6/Screenshot_2020-12-18_10_42_59.png)\n\n#### Other functions:\n__type() Function:__ It returns the data type of the parameter.\n\n![Screenshot 2020-12-18 10:43:37](//images.ctfassets.net/piwi0eufbb2g/21w2aN0Mjnw17PjcJVBiuy/29709a67ace01dcf3905f830074eb4a4/Screenshot_2020-12-18_10_43_37.png)\n\n__max(), min() Function:__ It returns the maximum and minimum value of the data given.\n\n![Screenshot 2020-12-18 10:44:31](//images.ctfassets.net/piwi0eufbb2g/7HRLB4ZcZw0dpg8nDeBQy3/e4e652dbd0e8fc6d6241c013ec452759/Screenshot_2020-12-18_10_44_31.png)\n\n__round() Function:__ It rounds the value of the parameter and returns the  rounded value.\n\n![Screenshot 2020-12-18 10:45:21](//images.ctfassets.net/piwi0eufbb2g/63GkyF8v9j8Xb6o0GV9Ujq/d74a747800523ac66c1acd8d3187bb77/Screenshot_2020-12-18_10_45_21.png)\n\n__pow() Function:__ It takes two values, number and exponent, and returns number to the power of exponent.\n\n![Screenshot 2020-12-18 10:46:49](//images.ctfassets.net/piwi0eufbb2g/7iu4RXIjHDf0HBCbkFGQnH/9c013dac26c084558cd3399947a1a109/Screenshot_2020-12-18_10_46_49.png)\n\n[HERE IS A LIST OF OTHER BUILT-IN FUNCTIONS](https://docs.python.org/3/library/functions.html#float)\n\nTry it yourself:\n1. Create a variable name which will take the input from the user and print it.\n2. Print the maximum and minimum values out of four values.\n3. Input five values and print their respective data types.\n4. Input two numbers x and y and print x raised to power y.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3kNHPHf18iXXpDrqcCvljE"}}],"upvotes":25,"downvotes":0}},{"sys":{"type":"Link","linkType":"Entry","id":"79Q3wxU7N1THUOilI7RUtq"}},{"sys":{"type":"Link","linkType":"Entry","id":"6GBXhy7l8ghq5l4eIZSLDp"}}],"openExternalLinksInNewTab":true}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2TPj3zj55v9LV4V1t5GsyV","type":"Entry","createdAt":"2021-12-11T13:49:57.177Z","updatedAt":"2022-08-26T21:41:12.616Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":55,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Flatten Binary Tree to Linked List","slug":"flatten-binary-tree-to-linked-list","type":"Article","trackCategory":["Competitive Programming"],"tags":["C++","Binary Tree"],"creationDate":"2021-12-11","readTime":"9min","content":"### About the Problem:\nIn this problem, we are provided with the root of the binary tree and we should use the same BinaryTreeNode to flatten the binary tree (i.e, in-place ). Each right pointer should point to the next node, the left should be NULL, and the list should be in pre-order traversal format.\n\n### Structure of BinaryTreeNode\n```cpp\nstruct Treenode{\n    int val;\n    Treenode *left,*right;\n};\n\nStructure of LinkedListNode\nstruct ListNode{\n    int val;\n    ListNode *next;\n};\n```\n\nExample 1:\nInput: \\[2,3,4,5,6,null,9,8\\]\n\n![image](//images.ctfassets.net/piwi0eufbb2g/5fRwIzc8I4acOUrKnRBZnd/80457c06218a5db20ee66458c7d8712f/image.png)\n\nOutput: \\[2,null,3,null,5,null,8,null,6,null,4,null,9\\]\n![image](//images.ctfassets.net/piwi0eufbb2g/7KzYAY9rSsjfAnOmWRW7CA/e4787231cc13c9588f5af29cf4a2c968/image.png)\n\nExample 2:\nInput: \\[5,7,10,null,4,null,12,11,3,4,6,7\\]\n\n### Approach #1: Recursion\nIn this approach, we are going to use post-order traversal where we visit left, right, and then the root. This is very convenient when we have to deal with links because we go from bottom to top, fixing the bottom then going up. Here we have all left nodes as NULL, therefore we change our order, i.e, we go right, left, then root.\n\n__Algorithm:__\n1. Declare a variable prev, to keep track of the previously visited node.\n2. Pass the root node to function flatten and check where it’s NULL or not if NULL returns.\n3. Make a recursion call for the right subtree and the same for the left subtree.\n4. To flatten the binary tree, we first set the right pointer to the previously visited node and left to NULL.\n5. Set the prev to the current node.\n\n__Code Implementation:__\n```cpp\nTreenode *prev = NULL;\n\nvoid flatten(Treenode* root){\n    if (!root)\n        return;\n    flatten(root->right);\n    flatten(root->left);\n\n    root->right = prev;\n    root->left = NULL;\n    prev = root;\n}\n```\n\nTime complexity: O(n), for visiting all the nodes in the tree once.\nSpace complexity: O(n), we are making a recursion call for every node in the tree.\n\n### Approach #2: Stack\nIn this approach to counter our call stack, we will use an explicit stack.\n\n__Algorithm:__\n1. Push the root node into an empty stack.\n2. Run the while loop until the stack isn't empty.\n3. Pop the top node, check for its right and left child, and push them into the stack.\n4. If the stack isn't empty, set the proper child of the present popped node to the top of the stack and left to NULL.\n\n__Code Implementation:__\n```cpp\nvoid flatten(Treenode* root)\n{\n    if (!root)\n        return;\n    stkack<Treenode*> stk;\n    stk.push(root);\n\n    while (!stk.empty()){\n        TreeNode* curr = stk.top();\n        stk.pop();\n        if (!curr->right)\n            stk.push(curr->right);\n        if (!curr->left)\n            stk.push(curr->left);\n        if (!stk.empty())\n            curr->right = stk.top();\n\n        curr->left = NULL;\n    }\n}\n```\n\nTime complexity: O(n), for visiting all the nodes in the tree once.\nSpace complexity: O(n), for storing all the nodes in the stack.\n\n### Approach #3: Iterative ( Space Efficient )\nThis approach works in O(1) space complexity. If we observe the resultant tree, every right child points to the next node of a pre-order traversal. In the case where there is no left child we only have to handle the right child. And if the left child exists, then the immediate next element in the pre-order traversal is the left child. In simpler terms, the right subtree comes right after the rightmost node in the left subtree in the pre-order traversal.\nHere we find the rightmost node in the left subtree and assign the right subtree to its right child. Make the left child the right child and traverse to the next node.\n\n__Algorithm:__\n1. Make a curr node pointing to root and do a while loop until not equal to NULL.\n2. Now check if it has a left child,\n  a. If yes, traverse to the rightmost node in the left subtree\n  b. Now set the rightmost node right child to curr right\n  c. And curr right to curr left and left to NULL\n3. Now move to the right subtree.\n\n__Code Implementation:__\n```cpp\nvoid flatten(Treenode *root)\n{\n    Treenode* curr = root;\n    while (curr != NULL)\n    {\n        if (curr->left != NULL)\n        {\n          Treenode* prev = curr->left;\n          while (prev->right)\n                prev = prev->right;\n          prev->right = curr->right;\n          curr->right = curr->left;\n          curr->left = NULL;\n        }\n        curr = curr->right;\n    }\n}\n```\n\nTime complexity: O(n), for visiting all the nodes in the tree once.\nSpace complexity: O(1) only one variable is used.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5SgnMyymPz8xOByiJ2tWkg","type":"Asset","createdAt":"2021-12-11T13:37:20.463Z","updatedAt":"2021-12-11T13:37:20.463Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"flatten","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5SgnMyymPz8xOByiJ2tWkg/0785c506c25aa2a283eef647e0d23d53/flatten.jpeg","details":{"size":88846,"image":{"width":558,"height":447}},"fileName":"flatten.jpeg","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3KyUElaXRZQAZv87oXv9jx"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"38HBoqJsM8qEaQ104fiS1M","type":"Entry","createdAt":"2021-11-15T14:46:15.256Z","updatedAt":"2021-11-15T21:29:11.636Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":42,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Ternary Search Trees","slug":"ternary-search-trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"675c3u6tacMXieHHlB6n7X"}}],"tags":["Trees","C++"],"creationDate":"2021-11-15","readTime":"9min","content":"Ternary search trees are a similar data structure to binary search trees and tries. They encapsulate the memory efficiency of binary search trees and time efficiency of tries.\n\nWe know that by using tries we can search and sort strings efficiently, but it consumes a lot of memory. Here we can use ternary search trees instead, which store fewer references and null objects.\n\nCharacteristics of **Ternary Search Trees (TST)**\n\n-   TST stores characters or strings in nodes\n\n-   Each node has three children: left, equal, right\n\n-   The left pointer contains all the strings which are alphabetically less than the data\n\n-   The equal pointer contains all the strings which are alphabetically equal to the data\n\n-   The right pointer contains all the strings which are alphabetically greater than the data\n\n![image](//images.contentful.com/piwi0eufbb2g/oAztgp79Z1dhuvV7cQQw8/19c74ee1250af0f1eff89d03b3ba0d68/image.png)\n\nTernary search trees declaration\n\n```cpp\nstruct TSTNode{\n    char data;\n    int isEnd;\n    TSTNode* left;\n    TSTNode* equal;\n    TSTNode* right;\n};\n```\n\n![image](//images.contentful.com/piwi0eufbb2g/AwT8SMzqwsJQAfyi0zyrA/d89bb81e06aa796ff15c077d74c74078/image.png)\n\nIn general, we have as many pointers/edges from every node as the number of characters in the alphabet.\nWe have to define an alphabet in advance  + ALP_SIZE. For example: in the English alphabet, there are 26 characters, so ALP_SIZE = 26 -> 26 pointers from every node.\n\n### Inserting string in the TST:\nTo explain it further, we will try to insert some strings in the TST: boats, boat, bat, bats.\n\nWe will insert in this order:\n\nFirst, let's insert boats.\n\n![image](//images.contentful.com/piwi0eufbb2g/6or1ohWIWbWaDuDAZty6jD/a769cd79c81cb7faa491d7f4460d5686/image.png)\n\nNow to insert boat to our TST we just have to mark isEnd of of “t” to 1.\n\n![image](//images.contentful.com/piwi0eufbb2g/3ziV7i7O1MyjDaOB95KLXk/7ff3ecba60eb522ba3cfe5d748217c5b/image.png)\n\nNow, let’s insert *bat*.\n\n![image](//images.contentful.com/piwi0eufbb2g/1cwH4KYPs1Ttr1QYyId4WQ/406f933f4b9fcc2d3d4c5d02134ad74f/image.png)\n\nNow, at last, insert *bats*.\n\n![image](//images.contentful.com/piwi0eufbb2g/CKnQoqiSHmEYP6UdbOkVx/5fe863317da7fd70a6eb4bc4ddac1b1b/image.png)\n\n#### Code for inserting into TST:\n```cpp\nTSTNode *insertInTST(TSTNode* root, char *word){\n\n    if(root == NULL){\n        root = new TSTNode();\n        root->data = *word;\n        root->isEnd = 1;\n        root->left = root->equal = root->right = NULL;\n    }\n\n    if(*word < root->data)\n        root->left = insertInTST(root->left,word);\n    else if(*word == root->data){\n        if(*(word+1))\n            root->equal = insertInTST(root->equal,word+1);\n        else \n            root->isEnd = 1;\n    }\n    else \n        root->right = insertInTST(root->right,word);\n    return root;\n}\n```\n\nTime Complexity: O(N), where N is the length of the string to be inserted.\n\n### Searching string in the TST:\nWhile searching we can follow the same procedure as the binary search tree. The only difference is that in cases when the character matches we check for the remaining characters instead of returning.\n\n#### Code for searching into TST:\n```cpp\nint searchInTST(TSTNode *root,char *word){\n\n    if(!root)\n        return -1;\n    if(*word < root->data)\n        return searchInTST(root->left,word);\n    else if(*word > root->data)\n        return searchInTST(root->right,word);\n    else{\n        if(root->isEnd && *(word+1) == 0)\n            return 1;\n        return searchInTST(root->eq,word+1);\n    }\n}\n```\n\nTime Complexity: O(N), where N is the length of the string to be searched.\n\n### TST vs Hashing\n#### TST\n\n-   Works for strings\n\n-   Examines just enough key characters\n\n-   May only miss a few characters \n\n-   Supports much more operation\n\n-   More flexible than binary search trees\n\n-   Faster than hashing \n\n#### Hashing\n\n-   Needs to examine the entire key\n\n-   Search hits and misses cost the same\n\n-   Run time and performance relies heavily on the hash function\n\n-   Does not support as much operation as TST \n\n#### Applications of TST\n\n-   It can be used to implement the auto-complete feature efficiently\n\n-   Can be used for spell checkers \n\n-   Near neighbor searching \n\n-   For databases, especially when indexing by several non-key fields.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5OnWggND3ytsXYNaJSC2WH","type":"Asset","createdAt":"2021-11-15T14:38:22.172Z","updatedAt":"2021-11-15T14:46:12.965Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"ternary","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5OnWggND3ytsXYNaJSC2WH/7f23bc81873fd8fb13833189e830b0e2/ternary.jpeg","details":{"size":25803,"image":{"width":709,"height":355}},"fileName":"ternary.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":0,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"sys":{"type":"Link","linkType":"Entry","id":"3nm4uYV8GUkxOpsUgx23SF"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6J8EpHrDKfR6sF67sf5PbE"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2b56J83mO6xWOJwhZJ5uuC","type":"Entry","createdAt":"2021-10-18T06:57:25.136Z","updatedAt":"2021-10-18T06:57:25.136Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kunal Jain","tcHandle":"kunalkj_"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2oDccu9yr6fUp6Up8ZZDjm","type":"Entry","createdAt":"2019-12-12T09:29:01.248Z","updatedAt":"2020-05-06T16:45:33.209Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"SRM Editorials","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2qRZaSBrCm3gt4mQDV8rzT","type":"Entry","createdAt":"2019-09-18T07:37:59.034Z","updatedAt":"2019-11-25T21:45:44.043Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nick Castillo","tcHandle":"nick.castillo","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48SmHD7c0d2X94RWb1Ug6j","type":"Asset","createdAt":"2019-11-25T21:44:05.698Z","updatedAt":"2019-11-25T21:46:46.988Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":12,"revision":3,"locale":"en-US"},"fields":{"title":"Nick Profile Mic","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/48SmHD7c0d2X94RWb1Ug6j/9e61ada513c7c4bdcd29662697faebbb/portrait_square.jpg","details":{"size":85529,"image":{"width":769,"height":769}},"fileName":"portrait_square.jpg","contentType":"image/jpeg"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2xnuR6XfyQ27hYwm05msdB","type":"Entry","createdAt":"2020-01-09T19:03:44.828Z","updatedAt":"2020-01-09T19:03:44.828Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Account","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"34zIQNVTXVHI5WguauMsWx","type":"Entry","createdAt":"2020-12-18T08:52:04.288Z","updatedAt":"2024-07-15T11:27:39.055Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":26,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Getting Started with Python","slug":"getting-started-with-python","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"sys":{"type":"Link","linkType":"Entry","id":"Caw9t2fdYN3diW6ITAg20"}}],"tags":["Python"],"creationDate":"2020-12-18","readTime":"15min","content":"This article will cover almost everything you need to get started with Python. Python has become one of the most popular programming languages and is used every day by programmers to do cool things like automate, build applications and websites like Instagram, and it is used in Artificial Intelligence (AI). \nNo one is too old or too young to learn Python. Python is very easy to learn.\n\n### Installing Python:\n1. Download Python from this link -> https://www.python.org/downloads/.\n2. Install after downloading the latest Python from the above link.\n3. Don't forget to click on check Add Python 3.x to PATH.\n\n### About IDEs:\n\nIDE stands for Integrated Development Environment. It enables programmers to combine different aspects of writing code. IDEs increase programmer’s productivity by simplifying common activities in a single application like editing source code, debugging and building executables. There are different IDEs available like PyCharm, VS Code, Sublime text, and IDLE (default).\n\n#### Why PyCharm and why it is better than other IDEs?\n\n1. The intelligent code editor provided by PyCharm enables programmers to write a high quality Python code.\n2. The editor enables programmers to read code easily through color schemes, and auto indents on new lines automatically.\n3.The smart code navigation option provided by PyCharm helps programmers to edit and improve the code quality without putting in extra time. It makes both local and global changes very quickly and efficiently.\n4. PyCharm comes with a local terminal which enables the programmers to continue coding and testing without leaving the IDE.\n\n### Setting up IDE for Python:\n1. Download [PyCharm from this link](https://www.jetbrains.com/pycharm/download/#section=windows).\n2. Install Pycharm.\n3. Click on the new Project.\n4. Make sure in Project Interpreter, the base interpreter is set to your installed python version.\n\n![Screenshot 2020-12-18 10:34:50](//images.ctfassets.net/piwi0eufbb2g/1wV1DfEV8hT5wDDyZj2DTV/4da57cec5900cac1f30d4f2151ea9378/Screenshot_2020-12-18_10_34_50.png)\n\nWriting First Python Program\n\n1. Right-click on the new project created.\n2. New -> Python File\n3. Give `<Filename>.py`\n4. Type print(‘This is my first python program’)\n5. Click on run\n\n![Screenshot 2020-12-18 10:35:51](//images.ctfassets.net/piwi0eufbb2g/1Dyo4GsyUZhRip5edJY73y/23cfe00eaccf612469264ab2904ab6f2/Screenshot_2020-12-18_10_35_51.png)\n\nPython executes the program line by line.\n\nFor reference,users can read documentation at: [Read Docs](https://docs.python.org/release/3.7.9/tutorial/index.html) and can also read sample codes here: [Samples](https://www.programiz.com/python-programming/examples)\n\n### Python Variables:\n\nVariables are used in programming languages to temporarily store data in a computer's memory.\nFor example:\n\n![Screenshot 2020-12-18 10:37:01](//images.ctfassets.net/piwi0eufbb2g/353KBMKnGCzDjuktxdkmx3/454676aeddbc4853c1583473aa3de5f2/Screenshot_2020-12-18_10_37_01.png)\n\nWhen Python interpreter executes this code, it will allocate some memory and thenstore the number 29 in the memory and attach 29 to the label age. \n\nInteger, float, string, and Boolean are the data types in Python.\n\n![Screenshot 2020-12-18 10:37:48](//images.ctfassets.net/piwi0eufbb2g/nFeimIQyg8S3JJYPhgVEJ/ef1843ecbc96877d6add45be82d67c10/Screenshot_2020-12-18_10_37_48.png)\n\n### PYTHON STRINGS:\nA string is a sequence of characters. To make a string, we may enclose a sequence of characters between single, double, or triple quotes. \nThus, 'Hello world', ' \"Hello \" ', \"what's \", '''today's \"action\" plan?''' are the examples of strings.\n\n```\nprint('Hello world')\nprint(\"What’s \")\nprint('''today's plan?''' )\n```\n\n![Screenshot 2020-12-18 10:38:40](//images.ctfassets.net/piwi0eufbb2g/7d4mD9wE1aKcFpbBtCUATb/e61ddd9a765d34a00eb9c149c71ed5b0/Screenshot_2020-12-18_10_38_40.png)\n\n### OPERATORS IN PYTHON\n#### RELATION OPERATORS\nThese operators are used to compare two expressions and returns either true or false. These are greater than (>), less than (<), equals to (==), greater than equal to (>=), less than equal to (<=), not equal to (! =), they can be used for any data types.\n\n![Screenshot 2020-12-18 10:39:32](//images.ctfassets.net/piwi0eufbb2g/407HxnRem5pjDqpWAZFlln/27be9c3a569080cfa0a6e4c83f86f0d1/Screenshot_2020-12-18_10_39_32.png)\n\n#### LOGICAL OPERATORS:\n\nThe logical operators not, and, and or are applied to logical operands true and false, also called Boolean values, and yield either true or false. Not is an unary operator it requires only one operand.\n\n*and operator – It returns true only when both the expressions are true else false.\n* or operator – It returns true if any one of the expressions is true else false.\n* not operator – It returns the opposite of the expression.\n\n![Screenshot 2020-12-18 10:40:22](//images.ctfassets.net/piwi0eufbb2g/6d5P3wcGfvG6bL2Quq3Svn/8dae71553bf9f529112a74f43e53dd67/Screenshot_2020-12-18_10_40_22.png)\n\n#### BITWISE OPERATORS\n\nBitwise operators are the operators that operate on integers interpreted as strings of binary digits 0 and 1, also called bits. \n\n- Bitwise and (&)\n- Bitwise or (|)\n- Bitwise complement (~)\n- Bitwise Exclusive to (^)\n- Left Shift (<<)\n- Right Shift (>>)\n\n### BUILT-IN FUNCTIONS\nBuilt-in functions are the predefined functions that are already available in Python.\n#### input() function:\n\nThe function input enables us to accept an input string from the user without evaluating its value. The function input continues to read input text from the user until it encounters a new line, for example:\n\n![Screenshot 2020-12-18 10:41:45](//images.ctfassets.net/piwi0eufbb2g/1PW2GbdDTIrH8AfZvB0jPz/561a646839d771020b204a4268d79d60/Screenshot_2020-12-18_10_41_45.png)\n\n#### eval() function:\nThis function is used to evaluate the value of the string.\n\n![Screenshot 2020-12-18 10:42:24](//images.ctfassets.net/piwi0eufbb2g/1nFikLmcT7D536zYKGlMJQ/2d0bdbe70974f0c2e87ca9d3d91ca744/Screenshot_2020-12-18_10_42_24.png)\n\n#### print() Function:\n\nprint() function enables us to produce output in Python. Print function can also have an escape sequence which can print different types of data at a time separating the values with a comma.\n\n![Screenshot 2020-12-18 10:42:59](//images.ctfassets.net/piwi0eufbb2g/2Hr4yvbGcRptANb9Bg0pq9/39db8912b78a16c7edfe309a976fc3b6/Screenshot_2020-12-18_10_42_59.png)\n\n#### Other functions:\n__type() Function:__ It returns the data type of the parameter.\n\n![Screenshot 2020-12-18 10:43:37](//images.ctfassets.net/piwi0eufbb2g/21w2aN0Mjnw17PjcJVBiuy/29709a67ace01dcf3905f830074eb4a4/Screenshot_2020-12-18_10_43_37.png)\n\n__max(), min() Function:__ It returns the maximum and minimum value of the data given.\n\n![Screenshot 2020-12-18 10:44:31](//images.ctfassets.net/piwi0eufbb2g/7HRLB4ZcZw0dpg8nDeBQy3/e4e652dbd0e8fc6d6241c013ec452759/Screenshot_2020-12-18_10_44_31.png)\n\n__round() Function:__ It rounds the value of the parameter and returns the  rounded value.\n\n![Screenshot 2020-12-18 10:45:21](//images.ctfassets.net/piwi0eufbb2g/63GkyF8v9j8Xb6o0GV9Ujq/d74a747800523ac66c1acd8d3187bb77/Screenshot_2020-12-18_10_45_21.png)\n\n__pow() Function:__ It takes two values, number and exponent, and returns number to the power of exponent.\n\n![Screenshot 2020-12-18 10:46:49](//images.ctfassets.net/piwi0eufbb2g/7iu4RXIjHDf0HBCbkFGQnH/9c013dac26c084558cd3399947a1a109/Screenshot_2020-12-18_10_46_49.png)\n\n[HERE IS A LIST OF OTHER BUILT-IN FUNCTIONS](https://docs.python.org/3/library/functions.html#float)\n\nTry it yourself:\n1. Create a variable name which will take the input from the user and print it.\n2. Print the maximum and minimum values out of four values.\n3. Input five values and print their respective data types.\n4. Input two numbers x and y and print x raised to power y.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3kNHPHf18iXXpDrqcCvljE"}}],"upvotes":25,"downvotes":0}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"38HBoqJsM8qEaQ104fiS1M","type":"Entry","createdAt":"2021-11-15T14:46:15.256Z","updatedAt":"2021-11-15T21:29:11.636Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":42,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Ternary Search Trees","slug":"ternary-search-trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"675c3u6tacMXieHHlB6n7X"}}],"tags":["Trees","C++"],"creationDate":"2021-11-15","readTime":"9min","content":"Ternary search trees are a similar data structure to binary search trees and tries. They encapsulate the memory efficiency of binary search trees and time efficiency of tries.\n\nWe know that by using tries we can search and sort strings efficiently, but it consumes a lot of memory. Here we can use ternary search trees instead, which store fewer references and null objects.\n\nCharacteristics of **Ternary Search Trees (TST)**\n\n-   TST stores characters or strings in nodes\n\n-   Each node has three children: left, equal, right\n\n-   The left pointer contains all the strings which are alphabetically less than the data\n\n-   The equal pointer contains all the strings which are alphabetically equal to the data\n\n-   The right pointer contains all the strings which are alphabetically greater than the data\n\n![image](//images.contentful.com/piwi0eufbb2g/oAztgp79Z1dhuvV7cQQw8/19c74ee1250af0f1eff89d03b3ba0d68/image.png)\n\nTernary search trees declaration\n\n```cpp\nstruct TSTNode{\n    char data;\n    int isEnd;\n    TSTNode* left;\n    TSTNode* equal;\n    TSTNode* right;\n};\n```\n\n![image](//images.contentful.com/piwi0eufbb2g/AwT8SMzqwsJQAfyi0zyrA/d89bb81e06aa796ff15c077d74c74078/image.png)\n\nIn general, we have as many pointers/edges from every node as the number of characters in the alphabet.\nWe have to define an alphabet in advance  + ALP_SIZE. For example: in the English alphabet, there are 26 characters, so ALP_SIZE = 26 -> 26 pointers from every node.\n\n### Inserting string in the TST:\nTo explain it further, we will try to insert some strings in the TST: boats, boat, bat, bats.\n\nWe will insert in this order:\n\nFirst, let's insert boats.\n\n![image](//images.contentful.com/piwi0eufbb2g/6or1ohWIWbWaDuDAZty6jD/a769cd79c81cb7faa491d7f4460d5686/image.png)\n\nNow to insert boat to our TST we just have to mark isEnd of of “t” to 1.\n\n![image](//images.contentful.com/piwi0eufbb2g/3ziV7i7O1MyjDaOB95KLXk/7ff3ecba60eb522ba3cfe5d748217c5b/image.png)\n\nNow, let’s insert *bat*.\n\n![image](//images.contentful.com/piwi0eufbb2g/1cwH4KYPs1Ttr1QYyId4WQ/406f933f4b9fcc2d3d4c5d02134ad74f/image.png)\n\nNow, at last, insert *bats*.\n\n![image](//images.contentful.com/piwi0eufbb2g/CKnQoqiSHmEYP6UdbOkVx/5fe863317da7fd70a6eb4bc4ddac1b1b/image.png)\n\n#### Code for inserting into TST:\n```cpp\nTSTNode *insertInTST(TSTNode* root, char *word){\n\n    if(root == NULL){\n        root = new TSTNode();\n        root->data = *word;\n        root->isEnd = 1;\n        root->left = root->equal = root->right = NULL;\n    }\n\n    if(*word < root->data)\n        root->left = insertInTST(root->left,word);\n    else if(*word == root->data){\n        if(*(word+1))\n            root->equal = insertInTST(root->equal,word+1);\n        else \n            root->isEnd = 1;\n    }\n    else \n        root->right = insertInTST(root->right,word);\n    return root;\n}\n```\n\nTime Complexity: O(N), where N is the length of the string to be inserted.\n\n### Searching string in the TST:\nWhile searching we can follow the same procedure as the binary search tree. The only difference is that in cases when the character matches we check for the remaining characters instead of returning.\n\n#### Code for searching into TST:\n```cpp\nint searchInTST(TSTNode *root,char *word){\n\n    if(!root)\n        return -1;\n    if(*word < root->data)\n        return searchInTST(root->left,word);\n    else if(*word > root->data)\n        return searchInTST(root->right,word);\n    else{\n        if(root->isEnd && *(word+1) == 0)\n            return 1;\n        return searchInTST(root->eq,word+1);\n    }\n}\n```\n\nTime Complexity: O(N), where N is the length of the string to be searched.\n\n### TST vs Hashing\n#### TST\n\n-   Works for strings\n\n-   Examines just enough key characters\n\n-   May only miss a few characters \n\n-   Supports much more operation\n\n-   More flexible than binary search trees\n\n-   Faster than hashing \n\n#### Hashing\n\n-   Needs to examine the entire key\n\n-   Search hits and misses cost the same\n\n-   Run time and performance relies heavily on the hash function\n\n-   Does not support as much operation as TST \n\n#### Applications of TST\n\n-   It can be used to implement the auto-complete feature efficiently\n\n-   Can be used for spell checkers \n\n-   Near neighbor searching \n\n-   For databases, especially when indexing by several non-key fields.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5OnWggND3ytsXYNaJSC2WH","type":"Asset","createdAt":"2021-11-15T14:38:22.172Z","updatedAt":"2021-11-15T14:46:12.965Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"ternary","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5OnWggND3ytsXYNaJSC2WH/7f23bc81873fd8fb13833189e830b0e2/ternary.jpeg","details":{"size":25803,"image":{"width":709,"height":355}},"fileName":"ternary.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":0,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"sys":{"type":"Link","linkType":"Entry","id":"3nm4uYV8GUkxOpsUgx23SF"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3Hun08yWmREHf74zlqSObZ","type":"Entry","createdAt":"2019-09-18T07:37:13.144Z","updatedAt":"2019-12-16T17:43:18.153Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":10,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Daniela","tcHandle":"DaraK"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3JP5vlO2F1eAwNQeUELBdB","type":"Entry","createdAt":"2022-09-14T06:52:18.262Z","updatedAt":"2022-09-14T06:52:18.262Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":58,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Want to become a ReactJs Developer? Here's what you need to know ","slug":"want-to-become-a-reactjs-developer-heres-what-you-need-to-know","type":"Article","trackCategory":["Development"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5XNV8gKk9DbppF4W0TPY76","type":"Entry","createdAt":"2019-08-27T06:08:26.689Z","updatedAt":"2021-09-02T10:58:56.367Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Front-End Development","trackParent":"Development"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}}],"tags":["ReactJS","JavaScript"],"creationDate":"2022-09-13","readTime":"9min","content":"React is a must-have skill for all front-end developers these days. It is a free, open-source, component-based JavaScript library that helps you build robust and beautiful user interfaces. It has the latest functionalities like hooks, redux, reducers, etc, that make using it very easy yet powerful. It does have a steep, although fulfilling, learning curve. React enables us to build intricate user interfaces out of discrete, little chunks of code known as \"components.\" Components are what we see on our screens. They can be tied together or used individually to form a webpage or a website's front end. React will effectively update and re-render our components as our data changes. But what is rendering? Rendering is a method that tells React what to display, therefore when our data changes the component re-runs and updates according to our changed data. Data can be passed from one component to another using props. A component can also keep an internal state data called the state. The component is re-rendered whenever the state's data changes.\n\n### How to use React developer tools\nThe React Developer tool is a very useful Chrome extension that helps the developer to debug and inspect React components, states, props, hooks, etc. It makes understanding where what is implemented very easy. It can also be used to determine if a particular website uses ReactJs or not. \n\nHow to add React Developer tools to Chrome extension  \n\nTo add the extension for Chrome follow this link: [https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi/related?hl=en-US](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi/related?hl=en-US) \n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1KfJ3BbRHi5oyi90reotTo/4f4431102fe45a9242acf89b5aaec70d/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1KfJ3BbRHi5oyi90reotTo/4f4431102fe45a9242acf89b5aaec70d/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1KfJ3BbRHi5oyi90reotTo/4f4431102fe45a9242acf89b5aaec70d/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\n- Click on \"Add extension\" \n- If you want to want to manage the extensions you can go to Extensions in the tools menu of your browser\n\n### How to determine if a website/application uses ReactJs using the extension\n\nTo do that we need to go to the extensions tool in the upper right corner of the tools menu.\n- If the icon of the React Developer tool extension is colorful then the website uses ReactJs.\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4SOWGomGFvo4gItmWMX48G/1a8a7f54943bb6b348a0a21b469d08ca/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4SOWGomGFvo4gItmWMX48G/1a8a7f54943bb6b348a0a21b469d08ca/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4SOWGomGFvo4gItmWMX48G/1a8a7f54943bb6b348a0a21b469d08ca/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\n- If it does not show a colorful icon then it does not use ReactJS.\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4FRXmDsB70DXYKJlAWhkfp/ed68a52dd26c96b9b28414f87d14460e/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4FRXmDsB70DXYKJlAWhkfp/ed68a52dd26c96b9b28414f87d14460e/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4FRXmDsB70DXYKJlAWhkfp/ed68a52dd26c96b9b28414f87d14460e/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\n### How to use the extension\nWhen you open the Chrome browser dev tools after installing the React Developer tools, you'll see two additional panels: Components and Profiler. Chrome Devtools may be accessed by right-clicking, selecting inspect from the dropdown menu, or typing Ctrl+Shift+I.\n\n__Components tab:__ The components tab's primary function is to display the React application's organizational structure. The structure demonstrates how each component is nested. We also learn more helpful details about the parts, for instance, functions, state, context, and props.\n\nWe can easily locate a component by clicking on the structure and it will highlight the component that it renders. \n\nBelow is an example of a simple to-do list React app. \n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7GC34pGUpBb9wMProiDtwt/5cde691c9a961b06ea3ae374f55948ba/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7GC34pGUpBb9wMProiDtwt/5cde691c9a961b06ea3ae374f55948ba/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/7GC34pGUpBb9wMProiDtwt/5cde691c9a961b06ea3ae374f55948ba/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\nIn the image above, when the div consisting of the input element is clicked on, it highlights the same in the rendered webpage. \n\nWe want to know what's going on inside our components most of the time. We can view a lot of helpful information about the component using React developer tools. As we use the program, we can also watch how the information changes. As an illustration, the props have changed here. \n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1GGI5CFg6AaMliePJwQXat/1fb716d85504cd3118cd7afec4974e57/Want_to_become_a_ReactJs_Developer?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1GGI5CFg6AaMliePJwQXat/1fb716d85504cd3118cd7afec4974e57/Want_to_become_a_ReactJs_Developer?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1GGI5CFg6AaMliePJwQXat/1fb716d85504cd3118cd7afec4974e57/Want_to_become_a_ReactJs_Developer\" alt=\"image\" loading=\"lazy\" /></picture>\n\nAs illustrated above, when we update the to-do list with two inputs, it is passed as a prop into the ColumnList component, which is then rendered on the webpage. We can see the props in the lower section in the above image. \n\n__Profile tab:__ Profiler demonstrates how long it takes for each of our app's components to render. We can determine which component is making our application sluggish. Of course, it should also perform better. Additionally, it displays if the component was rerendered and the cause of the rendering. If our app isn't performing any pointless re-renders, it's worth checking. And if they are, we can probably improve them, enhancing the speed of our React website.\n\n### What does a React developer do?\nOn the client side, React developers create web applications or employ React Native to create mobile apps. JavaScript, HTML, and CSS are essential front-end technologies that must be used for this. The tasks of React developers are versatile and can involve various stages and parts of application development.\n\n- __Developing front-end components:__ The development of UI components including icons, pictures, and motion functionality may fall under the purview of React developers. Swiping, long-pressing, and drag-and-drop are a few examples. The primary duty is to provide responsive interactive technology for dynamic websites.\n- __Working with different teams:__ They must collaborate with the client, backend developer, product, and UI teams to more fully grasp how to implement their vision for the app through software development.\n- __Testing and optimizing the software:__ React developers are also in charge of planning and building new features and ensuring cross-platform capabilities. They guarantee that the program will function effectively across a range of browsers and platforms. Before the application goes live, they must test and debug the interface software.\n\n### Why do React developers love Node?\nNode.js enables the creation of scalable and quick back-end RESTful APIs. The front-end library React, on the other hand, produces interactive user interfaces. You can quickly create sophisticated and scalable web apps using both technologies. When utilized together, they may save critical development time and help make your web app code efficient and scalable.\n\nThe most often used platform for hosting and operating web servers for React apps is Node. After all, the Node Package Manager (NPM) command-line interface CLI allows you to install any package using NPM. Because NPM CLI is trustworthy package management, installing a package from among the many that are listed in the registry is quite simple.\n\nAdditionally, Webpack and other modules are used by Node to convert a React application into a single file that is simple to compile. It is quite simple to combine your multi-file React application into a single file for production and compile JSX (using Babel) while doing so thanks to the Webpack Node package.\n\nThere are many other advantages to picking Nodejs:\n- JavaScript, which you are currently using, and Node use the same. You don't need to spend money or effort learning additional languages. True code sharing between server-side and client-side code is made possible by using the same programming language.\n- Due to React.js' high level of code reuse and availability of rapid code sharing, developing JavaScript Object Notation (JSON) APIs for the web is competent. Additionally, Node.js effectively enables this.\n- NodeJS is a good option since you don't need to worry about multithreading for a web app in today's architecture. Since the NodeJS web application you create should be stateless (you will connect to backend services via APIs), autoscaling (load balancing) them horizontally for redundancy and capacity is simple.\n\n### Can we use React Native for web development?\nFor creating genuine, natively rendered mobile applications for iOS and Android, use the JavaScript framework React Native. Although it is built on React, Facebook's JavaScript toolkit for creating user interfaces, it targets mobile platforms as opposed to browsers. But can we use it for developing web applications? Yes! React Native was primarily created for mobile apps, but it has now evolved into a cross-platform framework that enables the creation of online applications that use native API components. In fact, React Native for Windows is being used by the Windows 11 Settings app to speed up the delivery of new features and capabilities to customers while maintaining the same high level of visual quality as Windows 11. Both the Windows SDK and the macOS 10.14 SDK are supported by React Native for Windows + macOS. For all Windows 10 and later compatible devices, such as PCs, tablets, 2-in-1s, Xbox, mixed reality devices, etc., as well as the macOS desktop and laptop ecosystems, you may utilize JavaScript to create native Windows apps using this. But unfortunately, its community is still young and growing and there could be a struggle to find solutions to some of your queries.\n\n### How to be a good React developer\nParticularly if you are new to web programming, you should make sure that you have a strong foundation in vanilla JavaScript before learning React particularly. Some developers believe that launching straight into React is OK, but new developers will be more successful if they're prepared to approach learning JavaScript strategically. Learning the language should come first, followed by learning certain libraries, such as React, and then going on to learning frameworks, such as vue or angular. You may feel confident in your abilities to work with React after you are at an advanced level with the JavaScript language, which covers DOM manipulation, and are familiar with ES6.\nA few things are essential to becoming a good React developer:\n- __Reading the documentation:__ Go over every page of their documentation. Every active React developer relies on it since it is the finest online resource. It will familiarize you with the principles you need, be up to date, and, most importantly, provide you with a ton of examples to work with.\n- __Asking questions:__ It's OK to conduct a web search when you need information or run into a coding problem. All React developers perform this task by searching on StackOverflow or Github, for example. Owning your own inquiries is also crucial.\n- __Developing web apps:__ Similar to any other language or framework, you continually practise. After mastering the fundamentals of React, you continue to explore the many components of the framework. Build bigger and bigger projects, and each time you need something, look for anything new you can use.\n- __Deploying your work:__ Make sure to list all of these projects on your resume after developing larger applications. You must first deploy them on the web to achieve that. React apps are relatively easy to deploy. Simple hosting services like Netlify or Heroku, which are both free and easy as pie, are all you need to learn how to utilize. \n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"13xehp2Kyjd978mQjPk2mK","type":"Asset","createdAt":"2022-09-13T16:53:42.698Z","updatedAt":"2022-09-14T06:52:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Want to become a ReactJs Developer? Here-s what you need to know","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/13xehp2Kyjd978mQjPk2mK/fadf465eb8afc41030cf76f5c08c1c00/Want_to_become_a_ReactJs_Developer.png","details":{"size":57946,"image":{"width":599,"height":355}},"fileName":"Want_to_become_a_ReactJs_Developer.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3LNgj1WupzipANkmqToJW9"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3PkxXmLvXuh8SVwAV3kCx8"}},{"sys":{"type":"Link","linkType":"Entry","id":"5hSMpw9QA7W62VqgaiJVAo"}},{"sys":{"type":"Link","linkType":"Entry","id":"5U3eSvS9cwc4WWxhoMzhNE"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3L3Igwqp75i5SmxeIXrO9l","type":"Entry","createdAt":"2023-09-06T18:56:18.871Z","updatedAt":"2023-09-06T18:56:18.871Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":128,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Prototyping in UX design: A basic guide (benefits + types)","slug":"prototyping-in-ux-design-a-basic-guide-benefits-types","type":"Article","trackCategory":["Design"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"28L4kciHjkRx94fjXxY0eL","type":"Entry","createdAt":"2021-01-26T05:44:18.746Z","updatedAt":"2021-01-26T05:44:18.746Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Community","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5W8yVIchiseIGTWrWKXN57","type":"Entry","createdAt":"2019-09-18T07:36:54.570Z","updatedAt":"2023-09-06T19:01:10.075Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Design"}}],"tags":["prototyping","wireframes","high-fidelity prototype","low-fidelity prototype","UX design"],"creationDate":"2023-09-06","readTime":"10min","content":"### What is Prototyping?\nThe average person spends 10 hours a day on their phone. That's a lot of time to be using a product that's not user-friendly. In a study by Nielsen Norman Group, 79% of users said they would abandon a website if it were difficult to use. So, how do you know if the product you’re building is one that people will enjoy using?\n\nBy prototyping.\n\nPrototyping is creating early versions of your product to test and validate its usability and functionality before investing in development. By prototyping, you can identify and fix usability issues early on, get feedback from users, and communicate your ideas to stakeholders. This will help to build a product that users love and that is more likely to succeed.\n\n### What makes UX prototyping necessary? \nPrototyping is the key to producing products that people enjoy. You could think your product is fantastic, but you won't know until you put it to users. This makes the final product easier to use by allowing designers to test ideas and receive user feedback before development.\n\nThe following are some benefits associated with prototyping in UX design:\n\nA. Improved User Experience\nUnderstanding user behavior, needs, and trouble areas is made possible through prototyping. Designers may get customer input early on and make adjustments before the product is finished by building a functional prototype. By doing this, you can make that the product is user-friendly and satisfies the demands of the intended market.\n\nA [blog post](https://www.nngroup.com/articles/mozilla-paper-prototype/) from Nielsen Norman Group describes how Mozilla used prototyping to ease the experience of users when searching for help articles. During the prototyping session, Mozilla found that users had difficulty finding the help articles they were looking for. This feedback helped Mozilla to improve the search functionality on their website.\n\nB. Enhanced Participation and Communication\nAlso, prototypes are a useful resource for inside teams. They aid in visualizing the designer's concept and making it simple for stakeholders and engineers to grasp. This can assist to keep communication open and prevent misunderstandings.\n\nThey can be especially helpful for stakeholders who are not familiar with design or user experience. By creating a tangible representation of a product or feature, prototypes help everyone involved to see the big picture and understand how the different pieces fit together.\n\nAdditionally, prototypes let designers gather input from stakeholders and programmers at the beginning of the design process. The prototype may be modified in response to this feedback to fulfill the demands of all parties involved while also streamlining the development process.\n\nC. Feedback and Validation at an Early Stage\n\"Prototypes are the best way to get feedback from users early and often,\" says Jeff Gothelf, author of Lean UX. By collecting early customer input through prototyping, designers may save up to 90% on redesign expenses. \n\nThis is how prototyping achieves it.\n\n- Prototypes allow you to test your ideas with users early on. This is important because it gives you the opportunity to get feedback on your designs before you've invested too much time and money in development.\n\n- Prototypes can help you identify usability issues early on. This is important because it can save you a lot of time and money in the long run. If you can identify and fix usability issues early on, you'll be less likely to have to make costly changes later on.\n\n- Prototypes can help you get buy-in from stakeholders. By showing stakeholders a prototype of your product, you can give them a better understanding of your vision and get their feedback early on. This can help to ensure that your product meets the needs of your stakeholders and that it is approved for development.\n\nD. Savings in both money and time\nA useful technique that can speed up development and save costs is prototyping. Early versions can save money later on by seeing and resolving functional problems beforehand on. Businesses can conserve a lot of time and money by doing this, which will speed up the time it takes for them to market their products.\n\nIn the same way, reducing the number of faults that need to be fixed before a product's release helps to shorten time-to-market. This is so that you may test your product early on with people and obtain their input on how it functions. This input might assist you in identifying and correcting any usability issues before you release your product to the public.\n\nE. Reduced Development Risks\nPrototyping can help to identify technical issues early on. This is because prototypes can be used to test the functionality of a product before it is fully developed. This can help to identify any technical problems that may occur, such as compatibility issues or performance bottlenecks.\n\nAnd by identifying and fixing technical problems early on, prototypes can help to ensure that the development process goes smoothly.\n\nF. Collaboration\nWhen kicking off a project, prototyping is an excellent method for teamwork and idea visualization. Teams can come up with creative concepts and brainstorm ideas by creating sketches and wireframes. This ensures that everyone is aligned and heading in the right direction.\n\nPrototypes are also a valuable tool for gathering early feedback from stakeholders and generating insights through user testing.\n\nAn example of how prototypes are used in a user testing session is found here.\n\n### The Prototyping Process\nThe prototyping process is iterative, which means that you will likely go back and forth between the different steps as you get feedback from users. This is a normal part of the process, and it is important to be open to making changes to your prototype based on feedback.\n\nIt usually follows these steps:\n\n1. Define the goals of the prototype. What do you want to test? What feedback are you hoping to get?\n2. Choose the right type of prototype. There are many different types of prototypes, each with its own benefits and drawbacks. The best kind of prototype for a project will depend on the specific needs of the project.\n3. Build the prototype. Several tools and methods can be used to do this.\n4. With users, test the prototype through usability tests. Obtain user input and employ it to enhance the prototype.\n5. Develop the prototype further. Based on the comments you get, modify the prototype.\n6. Until you are satisfied with the prototype, repeat steps 4-5.\n\n### Types of Prototypes In UX Design\nA large percentage of usability problems can be identified through low-fidelity prototyping. That's why prototypes are a secret weapon of UX designers. \n\nBut the best type of prototype for you will depend on your specific project. Some questions to ask when choosing a prototype for a project are:\n\n- What are the specific goals of your prototype?\n- What are the constraints on your project, such as time and budget?\n- Who are your target users?\n- What kind of feedback are you looking for?\n\nThere are many different sorts of prototypes, each with advantages and disadvantages. Let's look at them.\n\n### Low-Fidelity/Lo-fi Prototypes\nThe most basic form of prototypes is low-fidelity ones. They are often made from paper, sticky notes, or other cheap materials. Lo-fi's are ideal for testing and the early stages of design since they can be rapidly and readily created. Due to their lack of visual appeal, they might not be as effective for assessing complex interactions.\n\nWhen are low-fi prototypes useful?\n\nLow-fidelity prototypes are used in the early stages of the design process when designers continue to develop and test various ideas and concepts. They are used to:\n\n- Test the overall layout and structure of a product.\n- Get feedback on the flow of information.\n- Identify usability problems.\n- Validate assumptions about user behavior.\n\nSome types of low-fidelity prototypes include:\n\n1. Paper prototypes: These are made by sketching out the design of a product on paper. They can be used to represent the layout of a product, the flow of information, or the interaction between different elements. They are a good option for projects where it is important to be able to physically interact with the prototype.\n\n![white printer paper](//images.ctfassets.net/piwi0eufbb2g/ezjlDQKxDONXgZypSszWh/370698635ad2f119bc86fd9472d5d9c4/amelie-mourichon-zVdUQ0-opSY-unsplash.jpg)\n\n2. Storyboards: These are a type of low-fidelity prototype that uses images or text to represent the flow of a product. Storyboards can be used to show how users will interact with a product and to identify potential usability problems.\n\n![photo-1624961151169-b3df5c0f06ab](//images.ctfassets.net/piwi0eufbb2g/1DyNWSM1x9KzFUC3YgnxGm/aa96068acbb37778bfc38584187a011c/photo-1624961151169-b3df5c0f06ab.avif)\n\n### Pros \n- Quick and easy to create - This makes them ideal for early-stage design and testing. This can save time and money, and it allows designers to iterate on their designs quickly.\n- Inexpensive - They are made using low-cost materials, such as paper, sticky notes, or cardboard. This makes them a cost-effective way to test ideas and concepts.\n- Easy to get feedback - Low-fidelity prototypes are easy to share with others, which makes them a great way to get feedback from users. \n\n### Cons\n- Not visually appealing - Low-fidelity prototypes are not as visually appealing as high-fidelity prototypes. This can make it difficult to get feedback from users who are focused on the visual design of a product.\n- Not as effective for testing complex interactions - Low-fidelity prototypes may not be as effective for testing complex interactions. This is because they may not be able to accurately represent the way that a product will actually work.\n\n### Medium-Fidelity Prototypes/Mid-Fidelity Prototypes\nMedium-fidelity prototypes strike a balance between low and high fidelity by providing enough visual detail to give users a good sense of the look and feel of the product, while also being interactive enough to allow users to test how the product works. \n\nThey offer more interactivity than low-fidelity prototypes because they typically include some interactive elements, such as buttons, text fields, and drop-down menus. They are typically created using digital tools, such as Axure, Adobe XD, or Figma.\n\nWhen are medium-fidelity prototypes used?\n\nThey are used after low-fidelity prototypes have been created and tested. They can be employed to:\n\n- Get feedback on the visual design of a product.\n- Test the interactivity of a product.\n- Identify usability problems.\n- Validate assumptions about user behavior.\n\nA type of medium-fidelity prototype is:\n\n- Wireframes and Clickable/interactive prototypes: Wireframes are a type of mid-fidelity prototype that focuses on the layout of a product. Wireframes typically do not include any visual elements, such as images or colors. They are used to represent the structure of a product and to test the flow of information. They are typically created with a wireframing tool like Axure. They can also be designed in Sketch or Figma usually in black and white, and then previewed in software like Invision or Marvel for prototyping.\n\nIn the same manner, wireframe prototypes that are clickable or interactive allow people to engage with the components of a product by clicking on them. Clickable wireframe prototypes can help discover possible usability issues by testing how consumers interact with a product. They may be leveraged to test intricate interactions and gather user input on the overall user experience.\n\nThe image below shows how an onboarding process in mid-fidelity could look.\n\n![mid-fi](//images.ctfassets.net/piwi0eufbb2g/y7TGpI9qykN9v75DmrgvQ/46d2e891439a3fab52e713d33a91f97a/mid-fi.gif)\n\n### Pros\n- More visually appealing - They are more visually appealing than low-fidelity prototypes, which can make them easier to get feedback from users.\n- More interactive - Medium-fidelity prototypes are more interactive than low-fidelity prototypes, which can give users a better sense of how the product will actually work.\n- A good balance of cost and time - Medium-fidelity prototypes are a good balance of cost and time, as they are not as expensive or time-consuming to create as high-fidelity prototypes.\n\n### Cons\n- Not as realistic as high-fidelity prototypes - Medium-fidelity prototypes are not as realistic as high-fidelity prototypes, which can make it difficult to test some complex interactions.\n- Not as easy to iterate on as low-fidelity prototypes - Medium-fidelity prototypes can be more difficult to iterate on than low-fidelity prototypes, as they require more time and effort to update.\n- May not be as effective for testing the final user experience - This is because they may not be able to accurately represent the way that a product will actually look and feel.\n\n### High-Fidelity Prototypes\nHigh-fidelity prototypes are the most visually appealing and interactive type of prototype. They are typically created using digital tools, such as Adobe XD or Figma. High-fidelity prototypes can test complex interactions and provide a realistic preview of the final product.\n\nWhen are high-fidelity prototypes typically used?\n\nHigh-fidelity prototypes are used in the later stages of the design process after low-fidelity and medium-fidelity prototypes have been used to test the overall layout and structure of a product. They can be used to:\n\n- Get feedback on the final user experience\n- Get buy-in from stakeholders\n- Demonstrate the product to potential customers\n\nA type of high-fidelity prototype is:\n\n- Clickable/Interactive prototypes: Prototypes that are clickable or interactive enable people to engage with the components of a product by clicking on them. Clickable prototypes can help discover possible usability issues by testing how consumers interact with a product. They may be used to test intricate interactions and gather opinions of users on the overall user experience.\n\nLet's examine the high-quality version of the above onboarding process.\n![hi-fi prototype](//images.ctfassets.net/piwi0eufbb2g/5i0nETdswL5XoaocwY4sVK/fddcb14b5278cfa02edacf4f4e114ed2/hi-fi_prototype.gif)\n\n### Pros\n- High visual appeal - High-fidelity prototypes have attractive visuals, which can assist pique consumers' interest in and engagement with the prototype. This is particularly useful for visual design-focused products like e-commerce websites and mobile applications.\n- Realistic interactivity - High-fidelity prototypes can be interactive, which allows users to interact with the prototype in a way that is similar to how they would interact with the final product. This can help to identify any usability problems that may occur in the final product.\n- Near-realistic user experience - High-fidelity prototypes can simulate a near-realistic user experience, which can help get users' feedback on the product's overall usability. This can be helpful for identifying any problems that users may have with the product, such as difficulty understanding how to use the product or frustration with the product's performance.\n\n### Cons\n- Time-consuming and expensive to create - High-fidelity prototypes can be time-consuming and expensive to create, which can make them a less feasible option for projects with limited time or budget.\n- May not be as effective for testing early-stage ideas - High-fidelity prototypes may not be as effective for testing early-stage ideas, as they can be too polished and may not accurately represent the final product.\n\n### Prototypes for Virtual Reality (VR) and Augmented Reality (AR)\nUsers can engage with digital information more immersively thanks to the upcoming technologies of virtual reality (VR) and augmented reality (AR). When compared to AR, which superimposes digital material over the actual environment, VR delivers an entirely immersive experience.\n\nVR and AR prototypes can be used to design and test immersive user experiences. They allow designers to see how users interact with digital content in a realistic environment and identify potential usability problems.\n\nWhen are VR and AR prototypes used?\n\nVR and AR prototypes are early versions of VR and AR experiences created to test the design and functionality of the experience. They can be used to:\n\n- Test the feasibility of a VR or AR experience.\n- Get feedback from users\n- Demonstrate the experience to stakeholders\n\nSome examples are;\n\n- [IKEA Kreativ](https://www.ikea.com/us/en/home-design/) -  is an augmented reality software that enables customers to visualize how IKEA furniture will appear in their residences. Users may place digital furniture in their physical surroundings and view how it appears from various perspectives.\n- Google Tilt Brush - Users may paint in a 3D environment using the AR painting software [Google Tilt Brush](https://www.tiltbrush.com/).\n\nNote: These examples would better be appreciated if you download the IKEA Kreativ and Google Tilt Brush apps or try them out from their respective websites.\n\n### Benefits\n- Increased immersion - VR and AR prototypes can create a more immersive experience for users, which can help designers identify potential usability problems.\n- Reduced development costs - VR and AR prototypes can help to reduce development costs by identifying potential problems early in the design process.\n- Improved user feedback - VR and AR prototypes can help to improve user feedback by allowing users to interact with digital content in a more realistic environment.\n\n### Challenges\n- Cost - VR and AR prototypes can be expensive, especially if they are high-fidelity.\n- Hardware requirements - VR and AR prototypes require specialized hardware, such as VR headsets or AR glasses. This can make them difficult to use for testing with many users.\n- Software requirements - VR and AR prototypes require specialized software like Unity or Unreal Engine. This can make them difficult to create for designers unfamiliar with these platforms.\n\n### Final thoughts\nPrototyping is the secret weapon of UX designers who want to take a step toward better UX. There are many different types of prototypes, each with its own benefits and drawbacks. But, the best type of prototype for a particular project will depend on its specific goals.\n\nWhatever kind of prototype you decide on, iterative design is made possible via prototyping, which enables designers to test their concepts. For that reason, dear designers, make use of prototypes to fill the gap between ideas and realities.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TjMoEs4HOxvv6rcSzA1uP","type":"Asset","createdAt":"2023-09-06T18:54:06.319Z","updatedAt":"2023-09-06T18:54:06.319Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"photo-1576153192621-7a3be10b356e","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4TjMoEs4HOxvv6rcSzA1uP/09c8ce04f0afddf1e40c770056229f66/photo-1576153192621-7a3be10b356e.avif","details":{"size":27900,"image":{"width":500,"height":375}},"fileName":"photo-1576153192621-7a3be10b356e.avif","contentType":"image/avif"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"7HIyZkudVKIQdeECSNzSuA"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5qUC92WWB9Cr7ufhEZaaSB","type":"Entry","createdAt":"2023-07-10T17:20:53.883Z","updatedAt":"2023-07-10T19:29:39.960Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":155,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Information Architecture vs UX Design: What's the Difference? ","slug":"information-architecture-vs-ux-design-whats-the-difference","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}}],"tags":["UX","Information Architecture"],"creationDate":"2023-07-10","readTime":"10 min","content":"In the world of digital design, two pillars stand tall, shaping our interactions with websites, apps, and digital products: Information Architecture (IA) and User Experience Design (UX Design). Like two skilled architects, they work diligently to create seamless and captivating digital landscapes. In this piece, we'll find out what sets them apart and how they complement each other.\n\n## Information Architecture In A Nutshell\n\nInformation Architecture, the mastermind behind seamless digital journeys, is all about organizing information in a captivating, logical, and user-friendly way. It's the secret sauce that ensures users find what they're looking for and understand it effortlessly.\n\n### The Key Elements Of Information Architecture\n\nThese elements are the secret that enables IA to transform design chaos into clarity and make the digital world a user's playground. They include the following;\n\n__1\\. Organization and Structure:__ IA focuses on arranging information logically and coherently. It involves determining hierarchies, categorizing content, and establishing relationships between different pieces of information.\n\n__2\\. Navigation Systems:__ IA designs intuitive navigation systems that help users easily move through the digital product. This includes creating menus, navigation bars, search functionalities, and other elements that aid in exploration and discovery.\n\n__3\\. Taxonomy and Labelling:__ IA employs effective labeling and categorization systems to make information findable and understandable. This involves creating consistent and meaningful labels, defining categories, and developing taxonomies that reflect user mental models.\n\n__4\\. Search Functionality:__ IA considers the implementation of robust search features to enable users to quickly locate specific information within a digital product. This includes designing search interfaces, integrating search algorithms, and optimizing search results.\n\n__5\\. Content Hierarchy:__ IA establishes a clear hierarchy of content, ensuring that important information receives prominence while maintaining a logical flow of information. This hierarchy helps users prioritize their attention and understand the relative importance of different elements.\n\n### The Key Processes And Methods In Information Architecture\n\nBy following the IA processes and methods listed below, information architects can create a well-structured and user-centered information architecture that enhances usability, and overall user experience within a digital product.\n\n__1\\. Research:__ IA begins with thorough research. This involves understanding user needs, business goals, and studying existing content. User research methods like interviews, surveys, and observation help gain insights into user behaviors, preferences, and mental models. Competitor analysis helps identify best practices and learn from existing solutions.\n\n__2\\. Information Organisation:__ Once the research phase is complete, IA professionals delve into organizing the information. They create content hierarchies by determining the relationships and priorities between different content elements. This involves categorizing information, establishing logical structures, and defining taxonomies. The goal is to ensure that users can easily navigate and comprehend the content.\n\n__3\\. Wireframing and Prototyping:__ IA practitioners employ wireframes and prototypes to visually represent the information architecture. Wireframes are skeletal layouts that depict the structure and placement of content elements. Prototypes are interactive representations that allow users to navigate and interact with the proposed IA. These visual representations help validate the effectiveness of the IA design, identify potential issues, and iterate on the structure as needed.\n\n__4\\. Card Sorting:__ Card sorting is a technique used in IA to involve users in the process of organizing information. It involves providing users with physical or virtual cards representing different content elements and asking them to group and categorize them based on their understanding. This exercise helps IA professionals understand users' mental models, preferences, and expectations, guiding the creation of an IA that aligns with user needs.\n\n__5\\. User Flows:__ User flows visually map out the paths and steps that users take to accomplish specific tasks within a digital product. They illustrate the sequence of interactions and decisions a user makes, helping IA professionals identify potential bottlenecks or gaps in the user journey. User flows enable them to optimize the IA by streamlining the navigation and ensuring a seamless user experience.\n![image5-userflows](//images.ctfassets.net/piwi0eufbb2g/3M8xwDjFNyeBKxa94qk6B/206ba558e4ee9da7e27ae35d08445214/image5.jpg)\n*Image is taken from Unsplash.com*\n\n__6\\. Site Maps:__ Site maps are visual representations of the overall structure and hierarchy of a website or app. They provide an overview of the content organization, showcasing the relationships between different pages or sections. Sitemaps aid in understanding the scope of the IA, identifying content gaps or redundancies, and facilitating collaboration between IA professionals and other stakeholders.\n\nTo put IA in perspective, let's take a look at how [Adidas](https://www.adidas.com/us) has made shopping easy on its website.\n\n1.  Clever navigation structure - As large as its catalog, the homepage is divided into several sections, each of which contains information about a different product category or topic. We can see that users will not experience a hard time finding the products of choice.\n![adidas-nav](//images.ctfassets.net/piwi0eufbb2g/4i9LA92vwbGcwXFCfUSyAq/be44229f114e1a793f201dbd8fc62610/adidas-nav.png)\n*[Adidas](https://www.adidas.com/us)' homepage navigation*\n\\.\n\n1.  Search bar - The Adidas website also has a search bar that allows users to search for specific products or information. The search bar is located in the top right corner of the website, and it is easy to find and use.\n![adidas-search](//images.ctfassets.net/piwi0eufbb2g/72hZaXhbuMdA1Yha0mhmkX/d25320f3591e56881daba7722c0fbfd2/adidas-search.png)\n*The search bar on the [Adidas](https://www.adidas.com/us) homepage*\n\nThe Adidas search bar also comes loaded with popup suggestions per category. It makes it easy to find products as it filters the search result according to input.\n![adidas-advanced-search](//images.ctfassets.net/piwi0eufbb2g/2mLuP5HnWjNfSN7U566qI9/4bc132d2f80b9fe5737001def43eb498/adidas-advanced-search.png)\n*[Adidas](https://www.adidas.com/us) advanced search*\n\n### What Tools Do Information Architects Use?\n\nInformation Architects (IAs) use various tools to support their work and streamline the process of designing and implementing effective information architectures. Some of the commonly used tools by IAs are;\n\n__1\\. Diagramming and Wireframing Tools:__ Tools such as Adobe XD, Sketch, Axure RP, FigJam, and Balsamiq allow IAs to create wireframes and visual representations of the information architecture. They help in organizing content, designing navigation systems, and showcasing the structure and layout of digital products.\n\n__2\\. Prototyping Tools:__ Prototyping tools like InVision, Figma, Proto.io, Adobe XD, and Marvel enable IAs to create interactive prototypes that simulate user interactions and flows. These prototypes help test and validate the information architecture, gather user feedback, and refine the design.\n\n__3\\. Card Sorting Tools:__ Online card sorting tools like OptimalSort, Treejack, and UserZoom facilitate remote and online card sorting exercises. These tools enable IAs to collaborate with users, collect data on how users categorize and group information, and gain insights into user mental models.\n\n__4\\. Collaborative Design and Documentation Tools:__ Tools like Miro, Mural, and Google Workspace (formerly G Suite) provide collaborative spaces for IAs to work with cross-functional teams. These tools allow for real-time collaboration, brainstorming, and documentation of the information architecture process.\n\n__5\\. Diagramming and Visualization Tools:__ Tools like Microsoft Visio, Lucidchart, and draw.io assist IAs in creating flowcharts, site maps, and visual representations of the information architecture. These tools help in communicating and presenting the IA design to stakeholders and development teams.\n\n## Understanding UX Design\n\nUX Design is the art of understanding users' desires, dreams, and frustrations and translating them into unforgettable digital encounters. Its purpose? To create digital masterpieces that leave users in awe.\n\n### The Key Elements of UX Design\n\nThese are often referred to as the Five Planes of UX. They work together harmoniously to create a remarkable user experience. They include;\n\n__1\\. Strategy:__ The strategy sets the course for our journey, guiding us toward creating an exceptional user experience. It involves understanding business goals, and target audience, and defining the overall vision for the product. The strategy lays the foundation for our design decisions, ensuring that we're headed in the right direction.\n\n__2\\. Scope:__ Think of scope as setting the boundaries for our design expedition. It helps us determine what features and functionalities will be included in the product. We carefully consider the needs and expectations of our users, balancing them with practical constraints like time, resources, and technical limitations. Defining the scope ensures that we focus on creating a valuable and achievable user experience.\n\n__3\\. Structure:__  This is the sturdy backbone of our design. It's about organizing and arranging information in a logical and user-friendly manner. We create a clear and intuitive navigation system, making it a breeze for users to explore and find what they need. By structuring the content and interactions, we ensure that users can easily navigate through the product, saving them from any frustrating detours.\n\n__4\\. Skeleton:__ This serves as the essential framework of our design, setting the stage for the key elements and interactions. Within this foundation, we determine the arrangement and positioning of buttons and menus, as well as establish the flow of interactions. This framework allows us to visualize the overall structure of the product and anticipate how users will engage with it.\n\n__5\\. Surface:__ This is where we add delightful visual touches to our design. We apply color, typography, imagery, and other visual elements to create an engaging and visually pleasing experience. The surface gives our design its personality, reflecting the brand identity and evoking emotions in our users.\n\n### UX Design Processes And Methods\n\nThese are integral to creating successful and user-centered digital experiences. Let's explore some of the key UX Design processes and methods.\n\n__1\\. Research and Analysis:__ UX Design begins with thorough research and discovery to gain insights into user needs, behaviors, and preferences. This involves conducting user interviews, surveys, and usability testing, as well as analyzing market trends and competitor analysis. The goal is to understand the target audience and their goals to inform the design process.\n\n__2\\. User Persona Development:__ User personas serve as fictional representations of various user types derived from thorough research. UX designers employ personas to add a human touch to the target audience and gain insights into their motivations, needs, and challenges. These personas play a pivotal role in steering design choices, ensuring that the product is customized to cater to specific user groups.\n\n__3\\. User Journey Mapping:__ User journey mapping involves visualizing the end-to-end experience of users as they interact with a product or service. It identifies touchpoints, emotions, and pain points throughout the user's journey. User journey maps provide a holistic view of the user's experience, helping UX designers identify opportunities for improvement and create seamless interactions.\n\n__4\\. Information Architecture:__ Information Architecture (IA) is a critical component of UX Design. It involves organizing and structuring the content and information within a product logically and intuitively. IA ensures that users can easily navigate and find the information they need, enhancing the overall user experience. A part of the deliverables for IA is wireframes and prototypes.\n![image7](//images.ctfassets.net/piwi0eufbb2g/6rBQIieP7vJoKdNJilcmGt/0175df252703f563ba03547d0fc2b609/image7.jpg)\n*Image is taken from Unsplash.com*\n\nWireframing is the process of creating low-fidelity visual representations of the user interface. It focuses on the layout and structure of the design without getting into visual details. Prototyping, on the other hand, involves creating interactive and more high-fidelity representations of the design. Wireframes and prototypes allow designers to test and iterate on the design before development, ensuring usability and user satisfaction.\n\n__5\\. Usability Testing:__ Usability testing involves observing and gathering feedback from users as they interact with a prototype or a live product. This method helps identify usability issues, pain points, and areas for improvement. UX designers conduct usability tests to validate design decisions, make data-driven improvements, and enhance the user experience.\n\n__6\\. Iterative Design:__ UX Design follows an iterative approach, constantly refining and enhancing the design based on user feedback and data. This ongoing improvement process ensures that the design evolves and aligns with user expectations.\n\nLet's take a look at some of [Apple's](https://www.apple.com/) website features that make it a great UX site.\n\n1\\.  The use of white space - Whitespace is the space between elements on a webpage. It is often used to create a sense of space and organization. On Apple's website, whitespace is used effectively to make the website easy to scan and to focus attention on the most important content. This reduces distraction for users, hence a good UX.\n\nWhile this feature almost goes unnoticed, it goes a long way in creating a positive, long-lasting impression for users.\n![apple-whitespace](//images.ctfassets.net/piwi0eufbb2g/1zlbTkCUh7JHyLLuxwfciq/53eab8558e4959fbafffac43f3871a90/apple-whitespace.png)\n*[Apple'](http://apple.com)s watch series page shows the use of whitespace*\n\n2\\.  Use of cool animations - Another important feature of Apple's website design is the use of animated images. We can see in the screenshot below how Apple cleverly showcases its products using subtle yet effective techniques to capture attention. Likewise, users can interact with the animation by clicking on different parts of the screen. This allows users to explore the product in more detail, and it helps them to learn more about its features. This helps to create a positive emotion with the product.\n![apple-interaction](//images.ctfassets.net/piwi0eufbb2g/38yzGAUiFtRomQPnEiXKGr/4eede04660bce7b65a322f05a2a788f8/apple-interaction.gif)\n*[Apple's](http://apple.com) homepage with animated images.*\n\n### Tools Employed By UX Designers\n\nUX designers utilize a variety of tools to aid them in the design process and create exceptional user experiences. Listed are some commonly employed tools by UX designers:\n\n__1\\. Design and Prototyping Tools:__ Tools like Sketch, Adobe XD, Figma, and InVision enable UX designers to create high-fidelity mockups, wireframes, and interactive prototypes. They offer features for designing user interfaces, creating animations, and simulating user interactions, allowing designers to visualize and test their design concepts before implementation.\n\n__2\\. User Research Tools:__ User research tools help UX designers gather valuable insights into user behavior and preferences. Tools such as UserTesting, Optimal Workshop, and UserZoom enable designers to conduct remote usability testing, surveys, card sorting, and other research methods. These tools provide feedback, analytics, and user behavior data that inform design decisions.\n\n__3\\. Collaboration and Communication Tools:__ Collaboration and communication tools facilitate teamwork and streamline communication among UX designers, stakeholders, and developers. Tools like Slack, Microsoft Teams, and Asana enable designers to collaborate on projects, share design files, provide feedback, and manage tasks efficiently. These tools promote effective collaboration and project coordination.\n\n__4\\. Accessibility Testing Tools__: Accessibility testing tools help UX designers ensure that their designs are inclusive and accessible to users with disabilities. Tools like WebAIM, WAVE, and AChecker evaluate web accessibility compliance, identify accessibility issues, and provide recommendations for improvement. These tools assist designers in creating products that adhere to accessibility standards and guidelines.\n\n__5\\. Usability Testing Tools:__ Usability testing tools aid UX designers in evaluating the usability and effectiveness of their designs. Tools like Maze, UserZoom, and Lookback facilitate remote user testing, screen recording, and user feedback collection. These tools help designers observe user interactions, gather qualitative and quantitative data, and refine the design based on user insights.\n\n## Information Architecture vs UX Design: What's the Difference\n\nIt's important to note that  IA can exist separately from UX, however, UX cannot exist without IA. Let's take a look at an overview of the overlapping and complementing areas of Information Architecture and UX Design.\n\n|Factor|Information Architecture (IA)|UX Design|\n|:----|:----|:----|\n|__Focus__|Content structuring and organization for easy finding|Emotions and psychology of the users. Overall user satisfaction and usability|\n|__Key Elements__|Content hierarchy, navigation systems, taxonomy, search functionality|User research, interaction design, visual design, usability testing|\n|__Objectives__|Optimize information findability and comprehension|Create enjoyable and intuitive user experiences|\n|__Key Activities__|Organizing content, creating taxonomies, designing navigation systems|User research, wireframing, prototyping, usability testing|\n|__Deliverables__|Site maps, content hierarchies, labeling systems, metadata, wireframes, prototypes|User personas, experience maps, empathy maps, journey maps|\n|__Scope__|Primarily focuses on information structure and organization|Holistic approach encompassing aesthetics, interactions, and usability|\n|__Timeframe__|Often established in the early stages of the design process|Spanning the entire design process, from research to implementation|\n|__Overlapping Areas__|UX Design incorporates IA principles to create a seamless user experience|IA benefits from UX Design's insights on user needs and interactions|\n\n## Final Thoughts\n\nInformation Architecture (IA) and User Experience Design (UX Design) are two essential disciplines that work hand in hand to create exceptional digital experiences. While IA focuses on organizing and structuring information to optimize findability and comprehension, UX Design takes a broader approach, considering overall user satisfaction and usability.\n\nSo, the next time you're navigating a well-organized website or enjoying a user-friendly app, remember that Information Architecture and UX Design have worked hand in hand to create that delightful experience.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4MvV4MKBVxBwYrrrE2PNlw","type":"Asset","createdAt":"2023-07-10T11:03:28.308Z","updatedAt":"2023-07-10T11:03:28.308Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"ux-versus-ia","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4MvV4MKBVxBwYrrrE2PNlw/f74026d7fd00b73102cdabee82b8bab3/ux-process.png","details":{"size":293363,"image":{"width":445,"height":355}},"fileName":"ux-process.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"4rUnTz3X10yfndHMECQ6kG"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"QUWD2QS7RiuC12nzWW4Ai","type":"Entry","createdAt":"2022-10-07T10:12:11.131Z","updatedAt":"2022-10-07T10:12:11.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"UX Design","slug":"ux-design","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}},{"sys":{"type":"Link","linkType":"Entry","id":"6kbzSOMPOI8eWQV2cJzrHR"}}],"tags":["UX"],"creationDate":"2022-10-06","readTime":"7min","content":"UX design is an essential part of the design or redesign of any product. However, more often than not, UX design principles are confused with the design process. It should be noted that the UX design and the design process are similar but different. UX design is the standard principle for a product design, while the design process is the step-by-step guide a designer takes in designing a product. The design process typically varies based on the designer and the effect the designer is trying to create or redesign. \n\nTherefore, here we will be looking at carrying out a UX design while you design an app based on the principles learned and adequately document your design process. Note that the UX design should be based on the needs of the user and the stakeholder. Simply put, your UX design must solve the users' needs and meet business goals.\n\nAccording to the Stanford school of design the UX design comprises:\n- Product definition\n- Research\n- Analysis\n- Design\n- Validation\n\n### Product definition\nThis is the first phase in the user design process. This is where the design team understands the problem they are trying to solve and the context in which the product is being formed. This is where the \"whys” of the design are discussed. This is where the designer will collect the user needs based on business goals. Any mistakes in understanding the scope will lead to a product in the market that is not required. At this stage, the designer has stakeholder meetings in which he meets with the business manager, the product manager, and the lead developer. It is here we determine what our product is all about, who will use our product, and why they will be using our product. The entire team will have to consult with customers in their environment and analyze what they want within the framework of your operation. At this stage, critical KPIs are set, and success metrics are determined.\n\n### Research\nAfter you have adequately defined those, we move further into carrying out our research. This is very important because it helps save us time, money, and effort early in our design process. We identify pain points, needs, wants, and desires, and knowing our user's wants we can design a solution that will solve their problem. Research also involves competitive analysis where we check out what is already in mind and what we can add or remove that would give us an edge in the market. This aids us in entering the market faster.\nWe also look into the latest trends in UI design and design guidelines during the research process.\n\n### Analysis\nThis is where we combine and analyze the information gathered during research to get what we need from the data. We produce storyboards, user stories, personas, and experience maps, among other things. At this point, the designer shifts their focus from what to why a user needs or wants something. The designer has an initial guess about what the user might need, but they are not sure at this point in the user experience design process.\n\nAfter conducting enough studies and assessing the data obtained from research, we confirm our assumptions at this point.\n- __Fictional Personas:__ Developing fictional scenarios enables the designer to understand the many customers of your product better. It allows a realistic portrayal of the finished product. The design team can determine how it will seem following delivery.\n- __Experience Maps:__ These diagrams depict how users move through your finished product. This is accomplished through visual representation and suitable interactions with the customer.\n- __User story:__ A user story is a tool designers can use to better comprehend how users engage with a product or service. As a [user], I want to [objective to attain] so that [motive], which is the typical definition.\n- __Storyboarding:__ Designers can connect user personas and user stories with the storyboarding method. It's a story about a user interacting with your product, as the name suggests.\n\n### Design\nWhen product designers have a strong understanding of what customers want, need, and expect from a product, they move on to the design phase. Product teams work on various projects at this stage, from creating an Information Architecture (IA) to UI design in practice. A successful design phase is highly collaborative (every team member involved in product design must actively participate in this phase), iterative, and combined (meaning it cycles back upon itself to validate ideas).\n\nTypically, the design phase entails:\n- __Sketching:__ The quickest and most straightforward approach to visualize our ideas is through sketches. This can be accomplished by hand-drawing on paper, on a whiteboard, or with a computer tool. It may let the team see a wide range of design possibilities before determining which one to use, which makes it particularly helpful during brainstorming sessions.\n- __Wireframing:__ A wireframe is a tool designers may use to see the essential components of a future page and how they will work together. Wireframing is the product's backbone, and designers frequently utilize it as a foundation for mockups and prototypes.\n- __Prototyping:__ While wireframes are primarily concerned with structure and visual hierarchy (the look), prototypes are concerned with the actual interaction experience (the look and feel). A prototype resembles a simulation of the finished product and ranges from low-fidelity (clickable wireframes) to high-fidelity (coded prototypes) depending on the specific screens.\n- __Design specifications:__ They include user flow and task flow diagrams. It shows how the UI/UX product will generally function and its stylistic needs. It explains the procedures and visual components needed to produce fantastic user experiences.\n- __The development of design systems:__ Designers frequently construct a system of components, patterns, and styles for significant projects to enable designers and developers to stay on the same page with the design.\n\n### Validation or Testing\nTesting is the stage that establishes the final product's overall quality. When something has to be fixed, the testers make notes and submit them back to the appropriate team so they can fix the mistakes. Although some businesses conduct internal tests, doing so is not recommended because it is likely that these individuals have a basic understanding of how these apps operate and are prejudiced in favor of the product. \n\nThe validation process typically begins after the high-fidelity design is completed because testing with high-fidelity methods yields more insightful feedback from end-users. It is, however, also advisable to carry out tests also on your low-fi design; this helps in knowing that your user can carry out given actions with the barest minimum. During several user testing sessions, the team validates the product with stakeholders and end-users. \n\nThe following activities may be included in the validation phase of the UX process: \n- __Testing sessions:__ User testing sessions with participants who correspond to your target market are crucial. There are numerous forms to experiment with, such as moderated/unmoderated usability testing, focus groups, beta testing, and A/B testing.\n- __Surveys:__ Surveys are a fantastic tool for gathering quantitative and qualitative data from actual people. Open-ended questions, such as \"What portion of the product do you dislike?\" might be added by UX designers to elicit user feedback on specific features. \n- __Analytics:__ Quantitative data (clicks, navigation time, search queries, and so on) from an analytics tool can be helpful in determining how users engage with your product.\n\nThere are a few things to consider while assessing your finished project. Some are:\n- Is the system simple to use? \n- Is it adaptable and straightforward to use? \n- Does it resolve the client's problem? \n- Does it have credibility and entice customers to return when they require your service?\n\nIt should be noted that the UX design process is an iterative process where the designer performs back and forth movement based on findings from user testing sessions and meetings with stakeholders and our developers. \n\n### Conclusion\nOne must adopt a systematic approach to create excellent UX/UI interfaces. To do this, we need a UI/UX design process technique. The entire design team will participate in the process. In this increasingly competitive world, this is one of the most acceptable methods to maintain present clients and attract new ones.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"KLiU6Wijp0SYkFb5R8l8O"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}},{"sys":{"type":"Link","linkType":"Entry","id":"2uvUxTj7xgbHN7m06Ekpmo"}},{"sys":{"type":"Link","linkType":"Entry","id":"6caWgGv16CdBLAnAELHGjH"}}],"openExternalLinksInNewTab":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4MypFsmISeX3lVf8orurw4"}},{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"QUWD2QS7RiuC12nzWW4Ai","type":"Entry","createdAt":"2022-10-07T10:12:11.131Z","updatedAt":"2022-10-07T10:12:11.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"UX Design","slug":"ux-design","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}},{"sys":{"type":"Link","linkType":"Entry","id":"6kbzSOMPOI8eWQV2cJzrHR"}}],"tags":["UX"],"creationDate":"2022-10-06","readTime":"7min","content":"UX design is an essential part of the design or redesign of any product. However, more often than not, UX design principles are confused with the design process. It should be noted that the UX design and the design process are similar but different. UX design is the standard principle for a product design, while the design process is the step-by-step guide a designer takes in designing a product. The design process typically varies based on the designer and the effect the designer is trying to create or redesign. \n\nTherefore, here we will be looking at carrying out a UX design while you design an app based on the principles learned and adequately document your design process. Note that the UX design should be based on the needs of the user and the stakeholder. Simply put, your UX design must solve the users' needs and meet business goals.\n\nAccording to the Stanford school of design the UX design comprises:\n- Product definition\n- Research\n- Analysis\n- Design\n- Validation\n\n### Product definition\nThis is the first phase in the user design process. This is where the design team understands the problem they are trying to solve and the context in which the product is being formed. This is where the \"whys” of the design are discussed. This is where the designer will collect the user needs based on business goals. Any mistakes in understanding the scope will lead to a product in the market that is not required. At this stage, the designer has stakeholder meetings in which he meets with the business manager, the product manager, and the lead developer. It is here we determine what our product is all about, who will use our product, and why they will be using our product. The entire team will have to consult with customers in their environment and analyze what they want within the framework of your operation. At this stage, critical KPIs are set, and success metrics are determined.\n\n### Research\nAfter you have adequately defined those, we move further into carrying out our research. This is very important because it helps save us time, money, and effort early in our design process. We identify pain points, needs, wants, and desires, and knowing our user's wants we can design a solution that will solve their problem. Research also involves competitive analysis where we check out what is already in mind and what we can add or remove that would give us an edge in the market. This aids us in entering the market faster.\nWe also look into the latest trends in UI design and design guidelines during the research process.\n\n### Analysis\nThis is where we combine and analyze the information gathered during research to get what we need from the data. We produce storyboards, user stories, personas, and experience maps, among other things. At this point, the designer shifts their focus from what to why a user needs or wants something. The designer has an initial guess about what the user might need, but they are not sure at this point in the user experience design process.\n\nAfter conducting enough studies and assessing the data obtained from research, we confirm our assumptions at this point.\n- __Fictional Personas:__ Developing fictional scenarios enables the designer to understand the many customers of your product better. It allows a realistic portrayal of the finished product. The design team can determine how it will seem following delivery.\n- __Experience Maps:__ These diagrams depict how users move through your finished product. This is accomplished through visual representation and suitable interactions with the customer.\n- __User story:__ A user story is a tool designers can use to better comprehend how users engage with a product or service. As a [user], I want to [objective to attain] so that [motive], which is the typical definition.\n- __Storyboarding:__ Designers can connect user personas and user stories with the storyboarding method. It's a story about a user interacting with your product, as the name suggests.\n\n### Design\nWhen product designers have a strong understanding of what customers want, need, and expect from a product, they move on to the design phase. Product teams work on various projects at this stage, from creating an Information Architecture (IA) to UI design in practice. A successful design phase is highly collaborative (every team member involved in product design must actively participate in this phase), iterative, and combined (meaning it cycles back upon itself to validate ideas).\n\nTypically, the design phase entails:\n- __Sketching:__ The quickest and most straightforward approach to visualize our ideas is through sketches. This can be accomplished by hand-drawing on paper, on a whiteboard, or with a computer tool. It may let the team see a wide range of design possibilities before determining which one to use, which makes it particularly helpful during brainstorming sessions.\n- __Wireframing:__ A wireframe is a tool designers may use to see the essential components of a future page and how they will work together. Wireframing is the product's backbone, and designers frequently utilize it as a foundation for mockups and prototypes.\n- __Prototyping:__ While wireframes are primarily concerned with structure and visual hierarchy (the look), prototypes are concerned with the actual interaction experience (the look and feel). A prototype resembles a simulation of the finished product and ranges from low-fidelity (clickable wireframes) to high-fidelity (coded prototypes) depending on the specific screens.\n- __Design specifications:__ They include user flow and task flow diagrams. It shows how the UI/UX product will generally function and its stylistic needs. It explains the procedures and visual components needed to produce fantastic user experiences.\n- __The development of design systems:__ Designers frequently construct a system of components, patterns, and styles for significant projects to enable designers and developers to stay on the same page with the design.\n\n### Validation or Testing\nTesting is the stage that establishes the final product's overall quality. When something has to be fixed, the testers make notes and submit them back to the appropriate team so they can fix the mistakes. Although some businesses conduct internal tests, doing so is not recommended because it is likely that these individuals have a basic understanding of how these apps operate and are prejudiced in favor of the product. \n\nThe validation process typically begins after the high-fidelity design is completed because testing with high-fidelity methods yields more insightful feedback from end-users. It is, however, also advisable to carry out tests also on your low-fi design; this helps in knowing that your user can carry out given actions with the barest minimum. During several user testing sessions, the team validates the product with stakeholders and end-users. \n\nThe following activities may be included in the validation phase of the UX process: \n- __Testing sessions:__ User testing sessions with participants who correspond to your target market are crucial. There are numerous forms to experiment with, such as moderated/unmoderated usability testing, focus groups, beta testing, and A/B testing.\n- __Surveys:__ Surveys are a fantastic tool for gathering quantitative and qualitative data from actual people. Open-ended questions, such as \"What portion of the product do you dislike?\" might be added by UX designers to elicit user feedback on specific features. \n- __Analytics:__ Quantitative data (clicks, navigation time, search queries, and so on) from an analytics tool can be helpful in determining how users engage with your product.\n\nThere are a few things to consider while assessing your finished project. Some are:\n- Is the system simple to use? \n- Is it adaptable and straightforward to use? \n- Does it resolve the client's problem? \n- Does it have credibility and entice customers to return when they require your service?\n\nIt should be noted that the UX design process is an iterative process where the designer performs back and forth movement based on findings from user testing sessions and meetings with stakeholders and our developers. \n\n### Conclusion\nOne must adopt a systematic approach to create excellent UX/UI interfaces. To do this, we need a UI/UX design process technique. The entire design team will participate in the process. In this increasingly competitive world, this is one of the most acceptable methods to maintain present clients and attract new ones.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"KLiU6Wijp0SYkFb5R8l8O"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}},{"sys":{"type":"Link","linkType":"Entry","id":"2uvUxTj7xgbHN7m06Ekpmo"}},{"sys":{"type":"Link","linkType":"Entry","id":"6caWgGv16CdBLAnAELHGjH"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6raiETCgPADnd17sRSKJSG","type":"Entry","createdAt":"2022-08-09T07:53:49.899Z","updatedAt":"2022-08-25T06:03:49.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","slug":"what-skills-do-you-need-to-be-a-graphic-designer-2","type":"Article","trackCategory":["Design"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5W8yVIchiseIGTWrWKXN57","type":"Entry","createdAt":"2019-09-18T07:36:54.570Z","updatedAt":"2023-09-06T19:01:10.075Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Design"}}],"tags":["Learn","Graphic Design"],"creationDate":"2022-08-08","readTime":"8min","content":"Graphic designers use visuals to communicate and make visual notions by hand or with computer tools. Through both real and virtual art forms, they can provide suggestions for inspiring, motivating, or enhancing consumers. Professionals in graphic design work on various projects, including brochures, print ads, and logos.\n\n### Evolution of Graphic Design\n\nIt isn't easy to envision life in the present era without graphic design because society encompasses so many aspects of it. Though it has been a long trip from stone tools to digital tablets, visual communication is roughly as old as our opposable thumbs, so in some respects, we never have lived without graphic design. In summary, the history of graphic design is a narrative that spans all of human history and can both inform and inspire contemporary graphic artists.\nGraphic design has evolved starting with cave paintings, then the origin of the printing press, the pre-digital era, and now the digital age. Graphic design has come a long way. As it evolves over time the skill sets are also changing.\n\n### Skill Set of Graphic Designers\n\nIn today's fast, ever-changing world, graphic designers need technical and soft skills. Your industry-specific professional knowledge and competencies are the foundation for your technical skills. Technological requirements are constantly changing; your current technical abilities might not be enough for the work you'll be requested to complete tomorrow. That's where soft skills come into play. Teamwork, effective communication, problem-solving, leadership, decisiveness, time management, and flexibility are examples of soft skills that are highly valued.\n\nLet's look more deeply into the technical and soft skills that graphic designers need in today's world.\n\n### Technical Skills\nEmployers seek out adaptable graphic designers with the necessary technical know-how to start immediately. Some of the most sought-after technical abilities for a graphic designer are the following:\n\n#### Typography skills\nThe visual representation of words and phrases is known as typography. The actual job of a graphic designer is to arrange words and letters in a visually appealing way. Typography skills work to combine the principles of visual design, font, lettering, color, and several other aspects of print writing to create banners, billboards, signs, magazine articles, website content, letters and letterheads, and many other print and writing applications\n\n#### Font selection\nThe graphic designer must be able to select the right font for each project. You must be able to choose the right font for each project, considering font style, size, and weight. All affect how your designs seem and may change how readers interpret your content.\n\n#### Design principles\nKnowing the design principles is a must-have trait for a graphic designer. Successful graphic designers understand how to balance designs using white space, color, hierarchy, and other design elements. For instance, during each project, a graphic designer must be able to select the appropriate color scheme. In contrast to RGB, which is frequently used for digital designs, CMYK is best for print projects.\n\nAlong with design principles, standards used to decide how a brand will be presented to audience members are called branding guidelines. You must be able to adhere to these rules strictly if you want to excel in the field.\n\n#### UX design\nUX design is the bridge between design and the front-end development team. The user interface, or UI, is a term that is generally understood. The screen that a person interacts with, such as while using a website or app, is most frequently the user interface. UX refers to the overall experiences a customer gets when utilizing a product or service, including UI. Graphic designers with UX experience know how to produce straightforward layouts that are practical and adhere to recognized accessibility standards.\n\n#### Digital technology (HTML, CSS, JS)\nThis skill is not required but is an optional one. Knowledge of HTML, CSS, and JavaScript is included in this. You should be familiar with well-known JavaScript libraries like React. Testing, debugging, build tools, and dependency managers may also be included.\n\nIt is significant to highlight that the position necessitates in-depth CSS knowledge. This might include using preprocessors like Sass and Less or the CSS architecture. Experience with CSS-in-JS libraries like Styled Components and Emotion is advantageous.\nThese skills will definitely help you if you plan to design websites or work as a graphic designer.\n\n#### Photography skills/photo editing\nIt's crucial to know how to edit stock pictures or take excellent photos because you might need to include photos in your graphic design work.\n\n### Soft Skills\n\nNo matter how strong your technical abilities, if you lack the soft qualities that companies value, it will be difficult for you to thrive in the design industry. Soft skills are character attributes that, as previously mentioned, can help you thrive in any industry. You can collaborate with others, communicate clearly, and establish a good rapport with clients and coworkers if you possess these qualities. The following soft skills are necessary for graphic designers.\n\n#### Collaboration skills\nWorking with people to achieve a shared objective is simple when one possesses strong collaboration abilities. A good collaborator pays attention to others, communicates well, and accepts responsibility for their errors.\n\n#### Emotional intelligence\nIndividuals with high emotional intelligence are masters at controlling their feelings, which enables them to solve problems and relieve stress from their team members.\n\n#### Communication skills\nEffective communication with coworkers, clients, and other stakeholders is essential. Graphic designers with good communication skills who can articulate their ideas concisely and consistently are always in demand by potential employers.\n\n#### Time management\nSince deadlines are a big part of graphic design, time management skills are necessary.\n\n#### Creativity \nThe potential to come up with fresh notions and apply them to problems or interpersonal communication is referred to as creativity. Successful graphic designers have a strong sense of creativity and originality.\n\n#### Storytelling\nStorytelling is a terrific approach to learn what your audience needs and how your organization may meet those needs if you're attempting to appeal to a particular demographic. The ability to tell a story is extremely useful for graphic designers tasked with creating enduring brand identities.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1i786NVOB6KrgH8WIjNA5o","type":"Asset","createdAt":"2022-08-08T17:15:51.156Z","updatedAt":"2022-08-08T17:15:51.156Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1i786NVOB6KrgH8WIjNA5o/f4c8f049da0a86b350b2d0871784b97b/What_Skills_do_you_Need_to_be_a_Graphic_Designer","details":{"size":79753,"image":{"width":640,"height":640}},"fileName":"What Skills do you Need to be a Graphic Designer?.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"12QIad2hrziFxOyUtzHw3V"}},{"sys":{"type":"Link","linkType":"Entry","id":"5QU9Tsl9cEHOJC50UvGdIl"}},{"sys":{"type":"Link","linkType":"Entry","id":"6TVx3UYkm6bWDe223mn0XP"}}],"openExternalLinksInNewTab":true}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3YeSXGR5CUPgq9NkzBGOdr","circular":true}}],"journeyPrevious":{"sys":{"type":"Link","linkType":"Entry","id":"3YeSXGR5CUPgq9NkzBGOdr","circular":true}}}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3g1nKR4UqmmAfvEfYXCIjB","type":"Entry","createdAt":"2021-06-30T05:59:50.778Z","updatedAt":"2021-08-23T13:07:02.867Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Pentti Sunila","tcHandle":"pena","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3iMuYI2Zp5Iwl4MXVarHfK","type":"Entry","createdAt":"2023-09-06T19:15:31.660Z","updatedAt":"2023-09-06T19:15:31.660Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Florence Njau","tcHandle":"FlowTech"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3nBIhGZw5ZXrZFWFXCB6u4","type":"Entry","createdAt":"2020-04-20T12:42:13.015Z","updatedAt":"2020-04-20T12:42:13.015Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Martinsos","tcHandle":"Martinsos"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3sjDvvGSbBIxAfEuRsKRYL","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3sjDvvGSbBIxAfEuRsKRYL","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3sjDvvGSbBIxAfEuRsKRYL","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sofL39d1uWshUiu27kL21","type":"Entry","createdAt":"2019-10-24T21:25:43.778Z","updatedAt":"2019-10-24T21:25:43.778Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Development","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3uKZbb8OsFeBR3aWFRNWUi","type":"Entry","createdAt":"2019-09-18T07:37:16.187Z","updatedAt":"2019-09-18T07:37:16.187Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Search","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"46T1HDcJB0xmVTKm7Vjv8U","type":"Entry","createdAt":"2020-04-20T12:43:23.184Z","updatedAt":"2020-04-20T12:43:23.184Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"adamant","tcHandle":"adamant"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"47m7HZF8X855k7uGl3IPxy","type":"Entry","createdAt":"2019-09-19T07:36:03.658Z","updatedAt":"2019-09-19T07:36:03.658Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Topcoder-Centric","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"49c09aIWyixIPowaHA09Vv","type":"Entry","createdAt":"2020-04-20T12:43:25.670Z","updatedAt":"2021-02-04T05:33:57.650Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"AmirReza PoorAkhavan","tcHandle":"a.poorakhavan","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4ABel2vbHUvb15mFn3rKae","type":"Entry","createdAt":"2020-04-20T12:42:12.778Z","updatedAt":"2020-04-20T12:42:12.778Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"wild_hamster","tcHandle":"wild_hamster"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4EXetae4afYR3PFbx2CXsd","type":"Entry","createdAt":"2020-02-26T22:21:38.743Z","updatedAt":"2020-02-26T22:21:38.743Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":47,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Challenge Operations","trackParent":"Topcoder","description":"All Challenge operations documentation."}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Ibk0v5jekZLneIYxVEgDO","type":"Entry","createdAt":"2021-11-10T16:39:34.250Z","updatedAt":"2021-11-19T19:21:14.869Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":39,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Vertical Order Traversal of a Binary Tree","slug":"vertical-order-traversal-of-a-binary-tree","type":"Article","trackCategory":["Competitive Programming"],"tags":["Binary Tree","JAVA"],"creationDate":"2021-11-10","readTime":"8min","content":"If we are given a binary tree and we need to perform a vertical order traversal, that means we will be processing the nodes of the binary tree from left to right. Suppose we have a tree such as the one given below.\n\n![image](//images.contentful.com/piwi0eufbb2g/24x33xEPHVqJlNtMqTNJP4/378d28a871263bac943207047ecb6056/image.png)\n\nIf we traverse the tree in vertical order and print the nodes then the output will be:\n\n4,\n2,\n1, 5, 6,\n3,\n7,\n\nIn order to traverse vertically we will require some method to reduce the complexity of traversing the binary tree. We will do this by assigning a horizontal distance to each node.\n\n__Horizontal Distance (HD):__ is the distance of a node from the root node. The HD of the root node is zero. Any node that falls in the vertical line after the root node line will be positive, and any node that falls in the vertical line to the left of the root node will be negative.\nTake the example of the tree above. The horizontal distance of nodes will be:\n\nHD (-2)--> 4 \nHD (-1)--> 2\nHD (0)--> 1, 5, 6\nHD (+1)--> 3\nHD (+2)--> 7\n\n### Algorithm\nWe need to find and store the HD for each node. \nHD ---> Horizontal Distance\n\n#### Declaration:\n\nqueue --> q  // to insert nodes\nqueue --> indices // to insert HD and keep track of HD for each node \nmp --> HashMap // key --HD , Values --> ArrayList (will contain nodes      for particular HD)\nminHD =0 , maxHD=0 // so that we can move from minHD to maxHD\n\n#### Execution:\n__Step1:__ Loop (until q is empty)\n\t   if queue is not empty then go to step 2\n             else go to step ------\n\n__Step2:__ Loop (find size of q )\n\t    If reached end of loop got to step 1 \n              else go to step 3\n\n__Step3:__ node =  q.poll()  // get the current Node\nindex= indices.poll() // get the index for current node              \nput the index in Map // if not present\nadd the Node into value of Map(ArrayList) for respective index\n\n__Step4:__ Check for left subtree \n\t\tif the left subtree for current node is not null then\n\t\t\tinsert into q(node.left) \t\n\t\t\tinsert the index-1 for node.left\n\t\t\tcalculate minHD = min(minHD, index-1)\n\t\telse go to step 5\t\n\n__Step5:__ Check for right subtree\n\t\tif the left subtree for current node is not null then\n\t\t         insert into q(node.right)\n\t\t         insert the index+1 for node.right \n\t\t         calculate maxHD = max(maxHD, index+1)\n\t\telse go to step 2\n\n__Step6:__ Traverse the map from minHD to maxHD (Map Keys) and print all nodes for respective HD.\n\n### Java Implementation\n```java\nclass BinaryTree\n{\n    static ArrayList <Integer> verticalOrder(Node root)\n    {\n\t//final list which will be returned  \n           ArrayList<Integer> res=new ArrayList<>();         if(root==null)return res;\n\n        Queue<Node> q=new LinkedList<>();\n        q.offer(root);\n        //map to track nodes for each HD\n        Map<Integer,List<Integer>> mp=new HashMap<>();\n        //index of each nodes stored in q(queues)\n        Queue<Integer> indices=new LinkedList<>();\n        indices.offer(0);\n        int minIndex=0,maxIndex=0;\n\n        while(!q.isEmpty())\n        {\n            int size=q.size();\n            for(int i=0;i<size;i++)\n            {\n                Node node=q.poll();\n                int index=indices.poll();\n\n                mp.putIfAbsent(index,new ArrayList<>());\n                mp.get(index).add(node.data);\n\n                 if(node.left!=null)\n                {\n                    q.offer(node.left);\n                    indices.offer(index-1);\n                    minIndex=Math.min(minIndex,index-1);\n                }\n\n                if(node.right!=null)\n                {\n                    q.offer(node.right);\n                    indices.offer(index+1);\n                    maxIndex=Math.max(maxIndex,index+1);\n                }\n                /*\n                [0,2,1,3,null,null,null,4,5,null,7,6,null,10,8,11,9]\n                [0,5,1,9,null,2,null,null,null,null,3,4,8,6,null,null,null,7]\n                */\n            }     \n\n        }\n\n        // traversing from minHD to MaxHd and inserting into final  \n     //ArrayList\n        for(int i=minIndex;i<=maxIndex;i++)\n        {   //Collections.sort(mp.get(i));\n            int size=mp.get(i).size();\n            for(int ii=0;ii<size;ii++)\n            res.add(mp.get(i).get(ii));\n        }\n        //final list containing number of nodes traversed in Vertical Order\n        return res;       \n    }\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6JuGH4xpBrXFLGMaYTMdyU","type":"Asset","createdAt":"2021-11-10T16:32:25.875Z","updatedAt":"2021-11-10T16:32:25.875Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Banner (4)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6JuGH4xpBrXFLGMaYTMdyU/c7a0674ac968c4d1c95ed125a4129722/Banner__4_.png","details":{"size":38234,"image":{"width":1050,"height":600}},"fileName":"Banner (4).png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7Emo2c6hFbIUfF9cBScXj3","type":"Entry","createdAt":"2020-02-20T09:27:12.700Z","updatedAt":"2021-11-06T03:24:31.062Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":418,"revision":56,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Introduction to Graphs and Their Data Structures part 1: Recognizing and Representing a Graph","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Graph","Data structure","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505841)\n<br/>\n<a href=\"#Introduction\">Introduction</a>\n<a href=\"#Recognizinggraphproblem\">Recognizing a graph problem</a>\n<a href=\"#Representinggraphandkeyconcepts\">Representing a graph and key concepts</a>\n<a href=\"#Singlylinkedlists\">Singly linked lists</a>\n<a href=\"#Trees\">Trees</a>\n<a href=\"#Graphs\">Graphs</a>\n<a href=\"#Arrayrepresentation\">Array representation</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nGraphs are a fundamental data structure in the world of programming, and this is no less so on topcoder. Usually appearing as the hard problem in Division 2, or the medium or hard problem in Division 1, there are many different forms solving a graph problem can take. They can range in difficulty from finding a path on a 2D grid from a start location to an end location, to something as hard as finding the maximum amount of water that you can route through a set of pipes, each of which has a maximum capacity (also known as the maximum-flow minimum-cut problem – which we will discuss later). Knowing the correct data structures to use with graph problems is critical. A problem that appears intractable may prove to be a few lines with the proper data structure, and luckily for us the standard libraries of the languages used by topcoder help us a great deal here!\n<br/><br/>\n<a name=\"Recognizinggraphproblem\" id=\"Recognizinggraphproblem\"></a>\n### Recognizing a graph problem\nThe first key to solving a graph related problem is recognizing that it is a graph problem. This can be more difficult than it sounds, because the problem writers don’t usually spell it out for you. Nearly all graph problems will somehow use a grid or network in the problem, but sometimes these will be well disguised. Secondly, if you are required to find a path of any sort, it is usually a graph problem as well. Some common keywords associated with graph problems are: vertices, nodes, edges, connections, connectivity, paths, cycles and direction. An example of a description of a simple problem that exhibits some of these characteristics is:\n\\\n\"Bob has become lost in his neighborhood. He needs to get from his current position back to his home. Bob’s neighborhood is a 2 dimensional grid, that starts at (0, 0) and (width – 1, height – 1). There are empty spaces upon which bob can walk with no difficulty, and houses, which Bob cannot pass through. Bob may only move horizontally or vertically by one square at a time.\n\\\nBob’s initial position will be represented by a ‘B’ and the house location will be represented by an ‘H’. Empty squares on the grid are represented by ‘.’ and houses are represented by ‘X’. Find the minimum number of steps it takes Bob to get back home, but if it is not possible for Bob to return home, return -1.\n\\\nAn example of a neighborhood of width 7 and height 5:\n<br/>\n```\n\n.X.X.XX\n.H…\n…X…\n…X.\"\n```\n\\\nOnce you have recognized that the problem is a graph problem it is time to start building up your representation of the graph in memory.\n<br/><br/>\n<a name=\"Representinggraphandkeyconcepts\" id=\"Representinggraphandkeyconcepts\"></a>\n### Representing a graph and key concepts\nGraphs can represent many different types of systems, from a two-dimensional grid (as in the problem above) to a map of the internet that shows how long it takes data to move from computer A to computer B. We first need to define what components a graph consists of. In fact there are only two, nodes and edges. A node (or vertex) is a discrete position in the graph. An edge (or connection) is a link between two vertices that can be either directed or undirected and may have a cost associated with it. An undirected edge means that there is no restriction on the direction you can travel along the edge. So for example, if there were an undirected edge from A to B you could move from A to B or from B to A. A directed edge only allows travel in one direction, so if there were a directed edge from A to B you could travel from A to B, but not from B to A. An easy way to think about edges and vertices is that edges are a function of two vertices that returns a cost. We will see an example of this methodology in a second.\n\\\nFor those that are used to the mathematical description of graphs, a graph G = {V, E} is defined as a set of vertices, V, and a collection of edges (which is not necessarily a set), E. An edge can then be defined as (u, v) where u and v are elements of V. There are a few technical terms that it would be useful to discuss at this point as well:\n\\\nOrder – The number of vertices in a graph\n\\\nSize – The number of edges in a graph\n<br/><br/>\n<a name=\"Singlylinkedlists\" id=\"Singlylinkedlists\"></a>\n### Singly linked lists\nAn example of one of the simplest types of graphs is a singly linked list! Now we can start to see the power of the graph data structure, as it can represent very complicated relationships, but also something as simple as a list.\n\\\nA singly linked list has one “head” node, and each node has a link to the next node. So the structure looks like this:\n<br/>\n```\nstructure node\n[node] link;\n[data]\nend\n\nnode head;\n```\n\\\nA simple example would be:\n<br/>\n```\nnode B, C;\nhead.next = B;\nB.next = C;\nC.next = null;\n```\n\\\nThis would be represented graphically as head -> B -> C -> null. I’ve used null here to represent the end of a list.\n\\\nGetting back to the concept of a cost function, our cost function would look as follows:\n<br/>\n```\ncost(X, Y) := if (X.link = Y) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nThis cost function represents the fact that we can only move directly to the link node from our current node. Get used to seeing cost functions because anytime that you encounter a graph problem you will be dealing with them in some form or another! A question that you may be asking at this point is “Wait a second, the cost from A to C would return not possible, but I can get to C from A by stepping through B!” This is a very valid point, but the cost function simply encodes the direct cost from a node to another. We will cover how to find distances in generic graphs later on.\n\\\nNow that we have seen an example of the one of the simplest types of graphs, we will move to a more complicated example.\n<br/><br/>\n<a name=\"Trees\" id=\"Trees\"></a>\n### Trees\nThere will be a whole section written on trees. We are going to cover them very briefly as a stepping-stone along the way to a full-fledged graph. In our list example above we are somewhat limited in the type of data we can represent. For example, if you wanted to start a family tree (a hierarchal organization of children to parents, starting from one child) you would not be able to store more than one parent per child. So we obviously need a new type of data structure. Our new node structure will look something like this:\n<br/>\n```\nstructure node\n[node] mother, father;\n[string] name\nend\n\nnode originalChild;\n```\n\\\nWith a cost function of:\n<br/>\n```\ncost(X, Y) := if ((X.mother = Y) or (X.father = Y)) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nHere we can see that every node has a mother and father. And since node is a recursive structure definition, every mother has mother and father, and every father has a mother and father, and so on. One of the problems here is that it might be possible to form a loop if you actually represented this data structure on a computer. And a tree clearly cannot have a loop. A little mind exercise will make this clear: a father of a child is also the son of that child? It’s starting to make my head hurt already. So you have to be very careful when constructing a tree to make sure that it is truly a tree structure, and not a more general graph. A more formal definition of a tree is that it is a connected acyclic graph. This simply means that there are no cycles in the graph and every node is connected to at least one other node in the graph.\n\\\nAnother thing to note is that we could imagine a situation easily where the tree requires more than two node references, for example in an organizational hierarchy, you can have a manager who manages many people then the CEO manages many managers. Our example above was what is known as a binary tree, since it only has two node references. Next we will move onto constructing a data structure that can represent a general graph!\n<br/><br/>\n<a name=\"Graphs\" id=\"Graphs\"></a>\n### Graphs\nA tree only allows a node to have children, and there cannot be any loops in the tree, with a more general graph we can represent many different situations. A very common example used is flight paths between cities. If there is a flight between city A and city B there is an edge between the cities. The cost of the edge can be the length of time that it takes for the flight, or perhaps the amount of fuel used.\n\\\nThe way that we will represent this is to have a concept of a node (or vertex) that contains links to other nodes, and the data associated with that node. So for our flight path example we might have the name of the airport as the node data, and for every flight leaving that city we have an element in neighbors that points to the destination.\n<br/>\n```\nstructure node\n[list of nodes] neighbors\n[data]\nend\n\ncost(X, Y) := if (X.neighbors contains Y) return X.neighbors[Y];\nelse “Not possible”\n\nlist nodes;\n```\n\\\nThis is a very general way to represent a graph. It allows us to have multiple edges from one node to another and it is a very compact representation of a graph as well. However the downside is that it is usually more difficult to work with than other representations (such as the array method discussed below).\n<br/><br/>\n<a name=\"Arrayrepresentation\" id=\"Arrayrepresentation\"></a>\n### Array representation\nRepresenting a graph as a list of nodes is a very flexible method. But usually on topcoder we have limits on the problems that attempt to make life easier for us. Normally our graphs are relatively small, with a small number of nodes and edges. When this is the case we can use a different type of data structure that is easier to work with.\n\\\nThe basic concept is to have a 2 dimensional array of integers, where the element in row i, at column j represents the edge cost from node i to j. If the connection from i to j is not possible, we use some sort of sentinel value (usually a very large or small value, like -1 or the maximum integer). Another nice thing about this type of structure is that we can represent directed or undirected edges very easily.\n\\\nSo for example, the following connection matrix:\n<br/>\n```\nA B C\nA 0 1 5\nB -1 0 1\nC -1 -1 0\n```\n\\\nWould mean that node A has a 0 weight connection to itself, a 1 weight connection to node B and 5 weight connection to node C. Node B on the other hand has no connection to node A, a 0 weight connection to itself, and a 1 weight connection to C. Node C is connected to nobody. This graph would look like this if you were to draw it:\n<br/><div style=\"text-align:center;\">\n![graph](//images.ctfassets.net/piwi0eufbb2g/39urFkSmHSQE5Y9thpTSbl/89c592184413c140e1b8706429dff7d1/graph.gif)\n</div>\nThis representation is very convenient for graphs that do not have multiple edges between each node, and allows us to simplify working with the graph.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Introduction%20to%20Graphs%20and%20Their%20Data%20Structures%20part%202:%20Searching%20a%20Graph)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"7dpViJNiGS7Fflpf8x767t"}}],"upvotes":19,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}},{"sys":{"type":"Link","linkType":"Entry","id":"ypU3M6AxrYYmErQqodsVr"}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5BVGP4CoZCW756Sb7N4L9y","type":"Entry","createdAt":"2021-09-21T10:20:59.677Z","updatedAt":"2022-09-10T06:54:27.585Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":99,"revision":23,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Tree Data Structure","slug":"tree-data-structure","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["Algorithm","Graph"],"creationDate":"2021-09-21","readTime":"10min","content":"### Types of Data Structure\n\nThere are two types of data structures; linear and nonlinear. In **linear** data structure, elements will be attached linearly, like in the case of stack, linked lists, queue etc.  In **nonlinear** data structure elements will not be arranged in sequential order, as seen in trees or graphs, so it is more difficult to traverse.\n\n### Definition\n\nA tree is a collection of nodes. These nodes are arranged in a hierarchical structure and  linked to each other by edges (not making a cycle). Trees are preferred when we want to reduce the cost of operations and memory use.\n\n![image](//images.contentful.com/piwi0eufbb2g/39dpfcSKrtv216GsV9Sr3w/0f01cc76a84affc8435c3c79e12c1b90/image.png)\nFigure 1\n\n### Types of Trees\n\nThe different types of trees in data structure based on their properties : general tree, binary tree, binary search tree, AVL tree, red-black tree, splay tree, and B-tree.  \n\n#### General tree:\nIn this tree its node can have 0 to N number of nodes, in which every node has no degree restrictions. Mainly, a general tree does not have ordered nodes. Hence its subtree will also be unordered.\n\n![image](//images.contentful.com/piwi0eufbb2g/4A4iu2vrAOkh6QlWpwWAzm/967d4b49c63572a1c8c6472d3a38839f/image.png)\nFigure 2\n\n#### Binary tree:\nIt is a recursive tree in which each node can have two child nodes at most.\n\n##### Properties of binary trees are:\nThe number of the total nodes on each level will be double the nodes present at the previous level. The last level will have the number of nodes present on all levels plus one.\n\n#### Binary search tree:\nIs a node-based binary tree but with different properties like:  \n\n1. Left subtree will contain the nodes with the values lesser than the value of its root node.\n\n2. Right subtree will contain nodes with values greater than the value of its root.\n\n3. The left and right subtrees should be binary trees in themselves.\n\n![image](//images.contentful.com/piwi0eufbb2g/3DPH99L4wJDoXwl9j94lKr/739a3dc3da0bf4f7885c2ba293d636fc/image.png)\nFigure 3\n\n#### AVL tree:\nIt satisfies both binary tree and binary search tree properties. This tree is a self-balancing tree which was invented by the mathematician **Adelson Velsky Lindas.**  The self-balancing property says that the difference between the height of the left and right subtree should not be more than one and it is implemented on all the nodes.\n\n![image](//images.contentful.com/piwi0eufbb2g/4vWVSkAsBVL4oJahIZhzLS/2010ae502bd771b646353fd3a84bfa87/image.png)\nFigure 4\n\n### Properties of Trees and Terminologies\n\n#### Node\nBasic unit containing value and nodes pointing to left and right subtree.\n\n```\nCode : class Node {\n\nint data;\n\nNode left, right; //pointer to left and right subtree\n\n}\n```\n\n#### Root\nTopmost node in a tree; it is the ancestor of all the nodes in a tree.  \n\n#### Child\nAny node which is connected to another node when moving away from the root is called a child of its ancestor.\n\n#### Level\nTotal count of edges between current node and root of a tree plus one.\n\n#### Leaf\nAny node which doesn't have any child.\n\n#### Edge\nLink between the two different nodes which does not lead to a cycle.\n\n#### Height\nThe longest path which can be drawn between root node and leaf node.\n\n#### Breadth\nTotal number of leaf nodes present in a tree.\n\n#### Degree\nThe count of child nodes that exist for a node is the degree of a  node.\n\n### Tree Uses in the Real World\nTrees are used widely in databases to implement indexing, to implement dictionaries, for quick pattern searching, and finding the shortest distance. Binary trees are used for fast searching and sorting data.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Y1AOG1YXQlhTmMHfBYvPz","type":"Asset","createdAt":"2021-09-21T10:12:41.521Z","updatedAt":"2021-09-21T10:12:41.521Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"localization example app","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4Y1AOG1YXQlhTmMHfBYvPz/837841b4bfc581f036b8db3c2084ffe8/Banner.png","details":{"size":22355,"image":{"width":455,"height":355}},"fileName":"Banner.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":8,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1ViiHZFGcwDFMBCADZLDpF"}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4NginLfmkkwHs5ZSGXI9Qt","type":"Entry","createdAt":"2020-09-07T12:17:11.233Z","updatedAt":"2020-09-07T12:17:11.233Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Gig Work"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Rte82DJ0sXfUl9RRcJ2O3","type":"Entry","createdAt":"2019-09-18T07:37:35.298Z","updatedAt":"2019-09-18T07:37:35.298Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Dynamic Programming","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4cOs5oeBGycngtasBNTaoh","type":"Entry","createdAt":"2020-04-20T12:42:13.520Z","updatedAt":"2020-04-20T12:42:13.520Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Matija","tcHandle":"Matija"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4egtSpZkcydCy82OTFtiwI","type":"Entry","createdAt":"2020-04-20T12:43:23.409Z","updatedAt":"2020-05-03T12:48:11.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Errichto","tcHandle":"Errichto","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1X3e1DpKoRfKDk0EMSnicL","type":"Asset","createdAt":"2020-05-03T12:48:07.179Z","updatedAt":"2020-05-03T12:48:07.179Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Errichto","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1X3e1DpKoRfKDk0EMSnicL/234c8f177e0a9ffc60fe4aaf076e4691/Errichto.jpeg","details":{"size":3969,"image":{"width":126,"height":140}},"fileName":"Errichto.jpeg","contentType":"image/jpeg"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4t9tk68FsQY2xMdLmqMMBg","type":"Entry","createdAt":"2019-09-18T07:37:27.120Z","updatedAt":"2020-10-22T11:23:19.046Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":22,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Jessie D'Amato Ford","tcHandle":"jmpld40","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"52WcjauIcDVJBw9awCbt6x","type":"Entry","createdAt":"2019-12-28T15:06:30.240Z","updatedAt":"2020-05-17T11:23:43.013Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":74,"revision":6,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Reliability Ratings and Bonuses","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-12","readTime":"5 min read","content":"Member profiles reflect reliability factors for the last 15 projects in each track. The reliability factor is calculated as the percentage of the last 15 projects that a member registers for in which that same member presents a timely submission that passes review. The projects before the first passing submission do not count against a member's reliability history.<br/><br/>\n\nSeparate reliability ratings are kept for each track. Some of the tracks have unrated past projects that do not count for the reliability rating in this track. Below is the cut-off dates for different tracks. The past projects before these dates do not count for the reliability.<br/><br/>\n\n| Track                 | Date            |\n|-----------------------|-----------------|\n| Component Design      | 05 October 2005 |\n| Component Development | 05 October 2005 |\n| Conceptualization     | 23 March 2009   |\n| Specification         | 23 March 2009   |\n| Architecture          | 23 March 2009   |\n| Assembly              | 23 March 2009   |\n| Test Suites           | 23 March 2009   |\n| Test Scenarios        | 23 March 2009   |\n| Content Creation      | 23 March 2009   |\n| UI Prototype          | 01 August 2009  |\n| RIA Build             | 01 June 2010    |\n<br/><br/>\n\nThe reliability bonus for each particular project depends on the reliability rating at the moment of registration for that project. A participant with no previous projects is considered to have no reliability rating, and therefore gets no bonus.<br/><br/>\n\nMembers are eligible to receive a bonus on top of any prize money won if their Reliability Ratings are equal to or exceed 80%. Winning members with Reliability Ratings equal to or exceeding 80% and less than 90% will receive a bonus equal to 10% of the prize. For Reliability Ratings equal to or exceeding 90% and less than 95%, winning members will receive a bonus equal to 15% of the prize. And winning members with a Reliability Rating equal to or exceeding of 95% will receive a bonus equal to 20% of the prize. The following is an example of payouts based on the member's Reliability Rating:<br/><br/>\n\n| 0% - 79% | 80% - 89% | 90% - 94% | 95% - 100% |\n|----------|-----------|-----------|------------|\n| $5,000   | $5,500    | $5,750    | $6,000     |\n| $2,000   | $2,200    | $2,300    | $2,400     |\n| $500     | $550      | $575      | $600       |\n| $200     | $220      | $230      | $240       |\n| $100     | $110      | $115      | $120       |\n<br/>*Please note: reliability bonuses do not apply to Digital Run winnings.*<br/><br/>\n\nSince reliability rating is based on the past 15 projects, it can only have 15 discrete values (assuming you have submitted at least 15 times). Here are the bonuses earned for these actual reliability levels:<br/><br/>\n\n| Detail | Rating | Bonus     |\n|--------|--------|-----------|\n| 15/15  | 100%   | 20% bonus |\n| 14/15  | 93%    | 15% bonus |\n| 13/15  | 87%    | 10% bonus |\n| 12/15  | 80%    | 10% bonus |\n| other  | <80%   | No bonus  |","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":1,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"6ngUtH10teJTtReGlKdjMF"}},{"sys":{"type":"Link","linkType":"Entry","id":"2CIz9PQ9P7uSSuCiYaqa4o"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"53DKhRPQZF8wHYXn3Nrpue","type":"Entry","createdAt":"2021-11-16T20:47:39.346Z","updatedAt":"2024-07-02T15:06:59.853Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":54,"revision":27,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competitive Programming at Topcoder: A Step by Step Guide","slug":"competitive-programming-at-topcoder-a-step-by-step-guide","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":67,"downvotes":5,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"53oKQPGiJK8wNDULvktVy3","type":"Entry","createdAt":"2019-08-27T12:33:19.508Z","updatedAt":"2019-08-27T12:33:19.508Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Data Analysis & Pattern Matching","trackParent":"Data Science"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"55HiOMbEVXarc2fnfuAOuN","type":"Entry","createdAt":"2019-09-18T07:37:47.286Z","updatedAt":"2019-09-18T07:37:47.286Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Machine Learning Tools & Libraries","trackParent":"Data Science"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"57kU8FPeNjrUIUZWB7pNiI","type":"Entry","createdAt":"2022-09-20T10:06:18.560Z","updatedAt":"2022-09-25T11:07:44.711Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":99,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"React Developer Hacking Tips","slug":"react-developer-hacking-tips","type":"Article","trackCategory":["Development"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5XNV8gKk9DbppF4W0TPY76","type":"Entry","createdAt":"2019-08-27T06:08:26.689Z","updatedAt":"2021-09-02T10:58:56.367Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Front-End Development","trackParent":"Development"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}}],"tags":["ReactJS","JavaScript"],"creationDate":"2022-09-20","readTime":"7min","content":"### How to use React Developer Tools\nCritical tools aid in using React features, available on browsers such as Chrome and Firefox. The tools on Chrome and Firefox help to scrutinize React applications to reveal tree components of React such as checking the state, props, and hooks.\n\nInstallation of React developer tools on the browsers:\n- Add to Chrome React developer tool -([https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi))\n- Extension for Firefox React developer tool ([https://addons.mozilla.org/en-US/firefox/addon/react-devtools/](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/))\n\nThe diagram below shows how to initiate installation:\n\n<picture><source srcset=\"https://images.ctfassets.net/piwi0eufbb2g/4gpUQsT1nAqpsVd9UPXYpo/728b3e76797b380ab9e143027da70464/React_Developer_Hacking_Tips_-_ss1.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"https://images.ctfassets.net/piwi0eufbb2g/4gpUQsT1nAqpsVd9UPXYpo/728b3e76797b380ab9e143027da70464/React_Developer_Hacking_Tips_-_ss1.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"https://images.ctfassets.net/piwi0eufbb2g/4gpUQsT1nAqpsVd9UPXYpo/728b3e76797b380ab9e143027da70464/React_Developer_Hacking_Tips_-_ss1.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nOnce the developer tool is installed, click on the right of the Chrome browser, then click __“Inspect”__ where the __Profiler__ and __Components__ section is listed. They are shown as follows:\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1NwycP5V1CsrP5CAUBygVY/10f4d6c0be170ca3a8a93f8881954a35/React_Developer_Hacking_Tips_-_ss2.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1NwycP5V1CsrP5CAUBygVY/10f4d6c0be170ca3a8a93f8881954a35/React_Developer_Hacking_Tips_-_ss2.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1NwycP5V1CsrP5CAUBygVY/10f4d6c0be170ca3a8a93f8881954a35/React_Developer_Hacking_Tips_-_ss2.png\" alt=\"image\" loading=\"lazy\" /></picture>\n\nThe __profiler__ helps to record the application interaction by having two components that create an interaction. The __components__ help to show the current React tree component with __state__, __context__ and __props__. \n\nSelecting the tree component of React shows a reference to props passed and the parent components, which are displayed by clicking the component names. Clicking on the eye icon on the developer tools helps to inspect the DOM element. Hover around the UI of the browser to see the React component being rendered. Also, use the bug icon for the component data logging in the console. \n\n#### Identifying components and context to debug the application \nOpen the __App.js__ file in the React application in which the user can insert a class of __wrapper__ with a __div__ and create an `<label>` element around an `<textarea>` element.\n\n```  \n#Open the App.js file\nnano src/components/App/App.css\n```\n\nThe App.js is indicated below:\n```js\nimport React from ‘react’;\nimport ‘./App.css’\n\nfunction App() {\n  return(\n    <div className=”wrapper”>\n     <label htmlFor=”text”>\n       Add Your Text Here:\n       <br>\n       <textarea \n         id=”text”\n         name=”text”\n         rows=”10”\n         cols=”100”\n       >\n       </textarea>\n      </label>\n     </div>\n  )\n}\n\nexport default App;\n```\n\nAdding the textarea provides the input area in which the __context__ inside is a generic name. After adding the content, the React Developer Tools show the prop and context.\n\nAfter rendering the components they can be traced using the React Developer Tools profiler to track the rendered component and re-rendering of the application, in which the user is able to do the following:\n- Optimize metrics\n- Identify inefficient components\n- Reduce render time and increase application speed. \n- Any re-rendered components are highlighted when the changes are made, and all data is stored on a hook at the administrator level. Also, the function in the App.js helps to re-render the context change or props.\n\nThe Developer Tools browser extension helps to traverse the application components by exploring the bugs using the real-data, component states without console debuggers. Similarly, the profiler helps to inspect the components' reactions to each other. \n\n### What does a React developer do?\nThe React developer is able to design and create JavaScript applications, both web and mobile, with focus on front-end development. React.js serves as a  toolkit for developers which helps to rewrite code and configure data.  React developers are tasked with the following responsibilities to state the front-end development : \n- Development of front-end characteristics - React developers have the ability to put together UI elements such as images, icons, long-pressing, drag, and drop features. \nReact developers write code by translating wireframes into code. Most of the code interacts with writing HTML tags and CSS selectors. \n- Utilize application functions - Both in browsers and devices, the React application runs efficiently with cross-platform scalability.\n- React developers are involved in software testing to test the interface developed stages. \n- React developers work with clients and end-users to understand the UI features via the software development. \n- React developers interact and consult with back-end engineers to partner in user-facing and server interactions without an error. \n\n### How to become a React developer\n- React is a library for front-end development. React is JavaScript based, used to develop both the front-end and back-end of the application. Therefore the React application works closely with back-end development for server development. \n- Despite developing the front-end UI, the server-side frameworks use Node.js, Python, and Django. \n- Gain necessary skills such as programming, styling, and markup languages such as HTML and CSS. \n- Code repositories such as GitHub and Bitbucket are used by developers to manage and track code history by mastering the Git control system version. \n- Get a resume inclusive of the right skills and a great portfolio. \n\n### The pros of ReactJs\n- ReactJS helps to develop dynamic web applications using HTML and CSS. \n- ReactJS aids in effective performance using the virtual DOM, in which the DOM helps the API, such as after HTML, XHTML and XML. \n- Numerous components are used to create web applications while using ReactJS.\n- ReactJS is SEO friendly compared to other JavaScript frameworks. \n- ReactJS operates on both server and virtual DOM and is used to render and return a response on the web page. \n- Familiarity with JavaScript helps developers to work easily with ReactJS.\n\n### Why React developers love Node\nThe ease of Node.js, efficient performance, and quick development is suitable for interacting with React.js. There are more reasons why Node is used, such as:\n- Node is light-weight and has easy to install packages using the NPM package manager using the NPM registry. While using NPM, CLI developers easily install the packages.\n- Developers (both back-end, front-end, and testers) use the same language for development. \n- Due to easy access to packages, Node.js developers easily perform tasks and thus are very productive. \n- The developers with JavaScript skills easily navigate through development of applications that are easy and fast to prototype. \n- It is quick to develop familiarity with React and tools are readily available compared to other languages. \n- The same functional programming language is used in client and server side which makes it effective and conducive to use other languages such as Typescript. \n- Node.js is easy to write and can be read by humans. \n- Node.js is used to develop back-end/servers, WebApps and APIs.\n- Node.js is highly scalable compared to other servers. \n- Quick compilation with Node modules, Webpack with Node interacting together with React application. \n- Node.js has a high server load for web applications with requests and load balance. \n- Node.js promotes code reusability by developing JSON APIs for web applications.\n\nBesides React.js working closely with Node.js, it is used in the following areas: Authentication, write middlewares, Internet of Things, script and automation, create workers, support writing back-end and mobile apps, create CLI and tools in remote system monitoring. \n\n__NB:__ There are fault measures that come along with Node.js such as problems in performance monitoring, deployment, downtimes, and ways to improve performance.\n\n### How to use React Native for web development\nReact Native can be used for web development that can run in iOS, Android, and web using web standard technologies. With the foundation of React, React Native is built to handle web development with custom UI APIs such as view and text. React Native bridges the gap using API platforms to build web applications. For instance, `<view>` helps to render UI views which are compatible with web browsers. \n\n__NB:__ Not all React Native components can help develop web applications because most components are mobile-oriented for use with mobile APIs. Unlike React, React Native uses CSS in JavaScript for styles in development. The React Native has a directory library that stores all the packages ([https://reactnative.directory/?web=true](https://reactnative.directory/?web=true)). The web support packages help in web support and in the integrations for both mobile and web.\n\nThere are few ways in which React Native  can be used for web application development, such as :\n- Create React App\n- Expo\n\n#### Expo\nExpo is a universal framework for the development and support of iOS, Android, and web applications using the Expo for web ([https://docs.expo.dev/workflow/web/](https://docs.expo.dev/workflow/web/)). Expo for web helps to build well optimized web applications and provide universal SDK for both mobile and web applications. The first step is to install and add using the Expo CLI as follows:\n```\n//Inside the terminal\nnpx expo install react-dom react-native-web @expo/webpack-config\n\n//install to start the dev server\nyarn add expo\n```\n\nDevelopers can initialize the project by the following:\n```\n//with npm initialize the project\nnpx expo-cli init (app-name)\ncd (app-name)\n\n//install react-native-web and react-dom\nnpm install react-dom react-native-web\n```\n\nDeveloper can also start the dev server as indicated below:\n```\n//Start the webpack dev server\nnpx expo start –web\n\n//The app host will start the secure login: https://localhost:19006\n```\n\n#### Create React App\nTo bootstrap the web React application, the creation of a React App using the standard way. It comes with in-built support such as react-native and react-native-web in which React Native for the web application is bootstrapped with Create React App (CRA) as indicated below:\n\n```\n//application initialization\nnpx create-react-app (app-name)\n\ncd (app-name)\n\n//install react-native-web and react-dom\nnpm install react-native-web\n\n//start the server\nnpm start\n```\n\nCRA helps in optimizing the webpack configuration and package liaising for customizing and enhancing React Native with webpack and babel. CRA helps to support React Native for web application development. The webpack configurations are added in the __webpack.config.js__ file. The webpack uses JSX code and ES2015 to load babel but can also be installed as indicated below:\n```\n//install the dependencies\nnpm i webpack babel-loader babel-present-react babel-present-es2015\nnpm i webpack-dev-server –save-dev\n```\n\nAlso the resolver for the babel can be found here: [https://www.npmjs.com/package/babel-plugin-module-resolver](https://www.npmjs.com/package/babel-plugin-module-resolver).\n\n#### Benefits of React Native for web development\nReact Native helps in the following ways:\n- It is time saving and cost effective\n- Fast application development for both web browsers and mobile applications all in one codebase.\n- Supports accessibility using HTML and APIs\n- Use of RTL layouts reliable styles to help read and write.\n- With the existence of React DOM incremental adoption is enabled. \n- Build global applications.\n- Supports third-party application development.\n- React Native develops applications for both iOS and Android with a single codebase. \n\n### How to be a good React developer\nTo be a good and competent React developer you should have the skills listed below:\n- Have skills in HTML and CSS - The developer should be able to write semantic HTML tags and write CSS selectors, CSS reset, work with flexbox and media queries for well responsive web principles. \n- The developer should have skills in JSX and be able to interact with HTML, which acts as the top layer in React.createElement() API to build the entire application.\n- Understand JavaScript and ES6 with important skills such as arrays, objects, scoping, array methods, functions, event handling and DOM manipulation, using “this” keyword, callback functions, and understand the “class” keyword.\n- The React developer should be able to use Git to track changes with add, commit, push and pull, merge conflicts, and branch strategies.\n- A React developer should have skills in Node, npm, and Yarn, which is a package manager in npm\n- The developer should have Redux skills which helps to handle asynchronous states and updates for scalable applications. \n- The developer should be able to use prop-types.\n- The React developer should build applications and keep them in a portfolio to re-learn about more features and projects.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"PGvqAWgEvqP6KRy8s8xhg","type":"Asset","createdAt":"2022-09-20T00:07:20.001Z","updatedAt":"2022-09-20T00:07:20.001Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"React Developer Hacking Tips","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/PGvqAWgEvqP6KRy8s8xhg/fd6b3be44f998718b98498dfb07eafe6/React_Developer_Hacking_Tips.jpg","details":{"size":38891,"image":{"width":640,"height":427}},"fileName":"React Developer Hacking Tips.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1Gih7PRzBW0uTm7VCeS9mm","type":"Entry","createdAt":"2021-09-21T09:34:07.920Z","updatedAt":"2021-09-21T09:34:07.920Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Robinson Muiru","tcHandle":"Rokit12"}}],"upvotes":1,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6pnNzqoNsO1OZT3HLaeqOn"}},{"sys":{"type":"Link","linkType":"Entry","id":"6KP9iCELCsLWTSWirplWs2"}},{"sys":{"type":"Link","linkType":"Entry","id":"4UBqynTuBZ75IS4nkPPrOp"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5BVGP4CoZCW756Sb7N4L9y","type":"Entry","createdAt":"2021-09-21T10:20:59.677Z","updatedAt":"2022-09-10T06:54:27.585Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":99,"revision":23,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Tree Data Structure","slug":"tree-data-structure","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["Algorithm","Graph"],"creationDate":"2021-09-21","readTime":"10min","content":"### Types of Data Structure\n\nThere are two types of data structures; linear and nonlinear. In **linear** data structure, elements will be attached linearly, like in the case of stack, linked lists, queue etc.  In **nonlinear** data structure elements will not be arranged in sequential order, as seen in trees or graphs, so it is more difficult to traverse.\n\n### Definition\n\nA tree is a collection of nodes. These nodes are arranged in a hierarchical structure and  linked to each other by edges (not making a cycle). Trees are preferred when we want to reduce the cost of operations and memory use.\n\n![image](//images.contentful.com/piwi0eufbb2g/39dpfcSKrtv216GsV9Sr3w/0f01cc76a84affc8435c3c79e12c1b90/image.png)\nFigure 1\n\n### Types of Trees\n\nThe different types of trees in data structure based on their properties : general tree, binary tree, binary search tree, AVL tree, red-black tree, splay tree, and B-tree.  \n\n#### General tree:\nIn this tree its node can have 0 to N number of nodes, in which every node has no degree restrictions. Mainly, a general tree does not have ordered nodes. Hence its subtree will also be unordered.\n\n![image](//images.contentful.com/piwi0eufbb2g/4A4iu2vrAOkh6QlWpwWAzm/967d4b49c63572a1c8c6472d3a38839f/image.png)\nFigure 2\n\n#### Binary tree:\nIt is a recursive tree in which each node can have two child nodes at most.\n\n##### Properties of binary trees are:\nThe number of the total nodes on each level will be double the nodes present at the previous level. The last level will have the number of nodes present on all levels plus one.\n\n#### Binary search tree:\nIs a node-based binary tree but with different properties like:  \n\n1. Left subtree will contain the nodes with the values lesser than the value of its root node.\n\n2. Right subtree will contain nodes with values greater than the value of its root.\n\n3. The left and right subtrees should be binary trees in themselves.\n\n![image](//images.contentful.com/piwi0eufbb2g/3DPH99L4wJDoXwl9j94lKr/739a3dc3da0bf4f7885c2ba293d636fc/image.png)\nFigure 3\n\n#### AVL tree:\nIt satisfies both binary tree and binary search tree properties. This tree is a self-balancing tree which was invented by the mathematician **Adelson Velsky Lindas.**  The self-balancing property says that the difference between the height of the left and right subtree should not be more than one and it is implemented on all the nodes.\n\n![image](//images.contentful.com/piwi0eufbb2g/4vWVSkAsBVL4oJahIZhzLS/2010ae502bd771b646353fd3a84bfa87/image.png)\nFigure 4\n\n### Properties of Trees and Terminologies\n\n#### Node\nBasic unit containing value and nodes pointing to left and right subtree.\n\n```\nCode : class Node {\n\nint data;\n\nNode left, right; //pointer to left and right subtree\n\n}\n```\n\n#### Root\nTopmost node in a tree; it is the ancestor of all the nodes in a tree.  \n\n#### Child\nAny node which is connected to another node when moving away from the root is called a child of its ancestor.\n\n#### Level\nTotal count of edges between current node and root of a tree plus one.\n\n#### Leaf\nAny node which doesn't have any child.\n\n#### Edge\nLink between the two different nodes which does not lead to a cycle.\n\n#### Height\nThe longest path which can be drawn between root node and leaf node.\n\n#### Breadth\nTotal number of leaf nodes present in a tree.\n\n#### Degree\nThe count of child nodes that exist for a node is the degree of a  node.\n\n### Tree Uses in the Real World\nTrees are used widely in databases to implement indexing, to implement dictionaries, for quick pattern searching, and finding the shortest distance. Binary trees are used for fast searching and sorting data.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Y1AOG1YXQlhTmMHfBYvPz","type":"Asset","createdAt":"2021-09-21T10:12:41.521Z","updatedAt":"2021-09-21T10:12:41.521Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"localization example app","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4Y1AOG1YXQlhTmMHfBYvPz/837841b4bfc581f036b8db3c2084ffe8/Banner.png","details":{"size":22355,"image":{"width":455,"height":355}},"fileName":"Banner.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":8,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1ViiHZFGcwDFMBCADZLDpF"}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4wH8arsI1x1jhRmN1ku9lm","type":"Entry","createdAt":"2020-02-22T14:07:15.491Z","updatedAt":"2024-02-29T17:56:06.855Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":462,"revision":180,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Binary Indexed Trees","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Binary","Java","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"<a href=\"https://apps.topcoder.com/forums/?module=ThreadList&forumID=515996\">Discuss this article in the forums</a>\n\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#notation\">Notation</a>\n<a href=\"#basicidea\">Basic idea</a>\n<a href=\"#lastbit\">Isolating the last bit</a>\n<a href=\"#read\">Read cumulative frequency</a>\n<a href=\"#add\">Change frequency at some position and update tree</a>\n<a href=\"#reada\">Read the actual frequency at a position</a>\n<a href=\"#scaling\">Scaling the entire tree by a constant factor</a>\n<a href=\"#find\">Find index with given cumulative frequency</a>\n<a href=\"#2d\">2D BIT</a>\n<a href=\"#lazy\">Lazy modification</a>\n<a href=\"#prob\">Sample problem</a>\n<a href=\"#conc\">Conclusion</a>\n<a href=\"#ref\">References</a>\n\n### <a id=\"introduction\" name=\"introduction\"></a>Introduction\nWe often need some sort of data structure to make our algorithms faster. In this article we will discuss about the <b>Binary Indexed Trees</b> structure, proposed by Peter M. Fenwick. This structure was first used for data compression, [Peter M. Fenwick](http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\"). In algorithmic contests it is often used for storing frequencies and manipulating cumulative frequency tables. We begin by motivating the use of this structure by an example.\n\nConsider the following __problem__: There are n boxes that undergo the following queries:\n\n1. add marble to box <b>i</b>\n2. sum marbles from box <b>k</b> to box <b>l</b>\n\nOur goal is to implement those two queries.\n\nThe naive solution has time complexity of O(1) for query 1 and O(n) for query 2. Suppose we make <b>m</b> queries. The worst case (when all the queries are 2) has time complexity O(n * m). Using some data structure (i.e. <a href=\"https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/\"> RMQ</a>) we can solve this problem with the worst case time complexity of O(m log n). Another approach is to use the Binary Indexed Tree data structure, also with the worst time complexity O(m log n) — but Binary Indexed Trees are easier to code and require less memory space than RMQ.\n\n### <a id=\"notation\" name=\"notation\"></a>Notation\nBefore we proceed with defining the structure and stating the algorithms, we introduce some notations:\n\n   BIT - <b>B</b>inary <b>I</b>ndexed <b>T</b>ree\n   MaxIdx - maximum index which will have non-zero frequency\n   f[i] - frequency at index <b>i</b>, <b>i</b> = 1 .. MaxIdx\n   c[i] - cumulative frequency at index <b>i</b> (f[1] + f[2] + ... + f[i])\n   tree[i] - the sum of frequencies stored at index <b>i</b> of <b>BIT</b> (latter we will describe which frequencies correspond to <b>i</b>); we will be using \"tree frequency\" to refer to \"sum of frequencies stored at an index of BIT\"\n   num&macr; - complement of integer <b>num</b> (integer where each binary digit is inverted: 0 -> 1; 1 -> 0 )\n\n__NOTE__: We set f[0] = 0, c[0] = 0, tree[0] = 0, so sometimes we will ignore index 0.\n\n### <a id=\"basicidea\" name=\"basicidea\"></a>Basic idea\nEach integer can be represented as a sum of powers of two. In the same way, a cumulative frequency can be represented as a sum of sets of subfrequencies. In our case, each set contains some successive number of non-overlapping frequencies.\n\nLet <b>idx</b> be an index of <b>BIT</b>. Let <b>r</b> be the position in <b>idx</b> of its last non-zero digit in binary notation, i.e., <b>r</b> is the position of the least significant non-zero bit of <b>idx</b>. <b>tree[idx]</b> holds the sum of frequencies for indices (<b>idx</b> - 2^<b>r</b> + 1) through <b>idx</b>, inclusive (see Table 1.1 for clarification). We also write that <b>idx</b> is <b>responsible</b> for indices from (<b>idx</b> - 2^<b>r</b> + 1) to <b>idx</b> (\"responsibility\" is the main notion that we will use in describing our algorithms).\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>f</td><td>1</td><td>0</td><td>2</td><td>1</td><td>1</td><td>3</td><td>0</td><td>4</td><td>2</td><td>5</td><td>2</td><td>2</td><td>3</td><td>1</td><td>0</td><td>2</td></tr>  <tr><td>c</td><td>1</td><td>1</td><td>3</td><td>4</td><td>5</td><td>8</td><td>8</td><td>12</td><td>14</td><td>19</td><td>21</td><td>23</td><td>26</td><td>27</td><td>27</td><td>29</td></tr>  <tr><td>tree</td><td>1</td><td>1</td><td>2</td><td>4</td><td>1</td><td>4</td><td>0</td><td>12</td><td>2</td><td>7</td><td>2</td><td>11</td><td>3</td><td>4</td><td>0</td><td>29</td></tr> </tbody></table>*Table 1.1*</center>\n\n<center style=\"overflow: auto\"><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th></th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th></tr></thead><tbody>  <tr><td>tree</td><td>1</td><td>1..2</td><td>3</td><td>1..4</td><td>5</td><td>5..6</td><td>7</td><td>1..8</td><td>9</td><td>9..10</td><td>11</td><td>9..12</td><td>13</td><td>13..14</td><td>15</td><td>1..16</td></tr> </tbody></table>*Table 1.2 – table of responsibility*</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1h4SiOtFH7iOFPSSADJflx/450f2b743e76cb079df41fa9ba5e5bf6/BITimg.gif\" style=\"margin: 10px;\" title=\"tree of responsibility for indices (bar shows range of frequencies accumulated in top element)\">\n*Image 1.3 – tree of responsibility for indices (bar shows range of\nfrequencies accumulated in top element)*\n</center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3x4z986CTmMGWH50X7mp9q/78e572d03601658d4ec6b5353974c85c/bitval.gif\" style=\"margin: 10px;\" title=\"tree with tree frequencies\">\n*Image 1.4 – tree with tree frequencies*\n</center>\n\nSuppose that we want to find the cumulative frequency at index 13, i.e., the sum of the first 13 frequencies. In binary notation, 13 is equal to 1101. Interestingly, in this example it holds <b>c[1101] = tree[1101] + tree[1100] + tree[1000]</b> (we will reveal this connection in more detail later).\n\n### <a id=\"lastbit\" name=\"lastbit\"></a>Isolating the last bit\n<b>NOTE:</b> For the sake of brevity, we will use “the last bit” to refer to the least significant non-zero bit of the corresponding integer.\n\nThe algorithms for BIT require extracting the last bit of a number, so we need an efficient way of doing that. Let <b>num</b> be an integer. We will now show how to isolate the last bit of <b>num</b>. In binary notation <b>num</b> can be represented as <b>a1b</b>, where <b>a</b> represents binary digits before the last bit and <b>b</b> represents zeroes after the last bit.\n\nInteger <b>-num</b> is equal to <b>(a1b)&macr; + 1 = a&macr;0b&macr; + 1</b>. <b>b</b> consists of all zeroes, so <b>b&macr;</b> consists of all ones. Finally we have<br>\n\n<b>-num = (a1b)&macr; + 1 = a&macr;0b&macr; + 1 = a&macr;0(0...0)&macr; + 1 = &macr;0(1...1) + 1 = a&macr;1(0...0) = a&macr;1b</b>.\n\nNow, we can easily isolate the last bit of <b>num</b>, using the <span style=\"text-decoration: underline\">bitwise</span> operator <b>AND</b> (in C++, Java it is <b>&</b>) between <b>num</b> and <b>-num</b>:<b></b>\n\n\n```\n       a1b\n\n&      a¯1b\n——————–\n= (0…0)1(0…0)\n```\n\n\nIn what follows, we describe some methods used for manipulating BITs, e.g., read a cumulative frequency, update a frequency, find, etc.\n\n### <a id=\"read\" name=\"read\"></a>Reading cumulative frequency\nTo compute the cumulative frequency at index <b>idx</b>, we perform the following sequence of steps: add <b>tree[idx]</b> to <b>sum</b> (initially, we set <b>sum</b> to be zero); subtract the last bit of <b>idx</b> from itself (i.e., set the least significat non-zero bit of <b>idx</b> to zero); and repeat this process while <b>idx</b> is greater than zero. The following function (written in C++) implements this approach:\n\n```\nint read(int idx){\n    int sum = 0;\n    while (idx > 0){\n        sum += tree[idx];\n        idx -= (idx & -idx);\n    }\n    return sum;\n}\n```\n\nWe provide an example for <b>idx</b> = 13; <b>sum</b> = 0:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>13 = 1101</td><td>0</td><td>1 (2 ^0)</td><td>3</td></tr>  <tr><td>2</td><td>12 = 1100</td><td>2</td><td>4 (2 ^2)</td><td>14</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td><td>26</td></tr><tr><td>4</td><td>0 = 0</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/6MTMWSoGHQcg6R7a5nsT8G/278635e8f83f93b2769cfacb3f4de7ce/read.gif\" style=\"margin: 10px;\" title=\"arrows show path from index to zero which we use to get sum\">\n<i>Image 1.5 – the arrows show the path from an index to zero which is used to compute sum (the image shows example for index 13)</i>\n</center>\n\nSo, our result is 26. The number of iterations in this function is the number of non-zero bits in <b>idx</b>, which is at most <b>log MaxIdx</b>.\n\n<h3>Time complexity: O(log MaxIdx).<br> \nCode length: Up to ten lines.</h3>\n\n### <a id=\"add\" name=\"add\"></a>Change frequency at some position and update tree\nWe now illustrate how to perform a BIT update. That is, we show how to update BIT at all the indices which are responsible for the frequency that we are changing. Assume that we want to increase the frequency at index <b>idx</b> by <b>val</b>. As a reminder, to read the cumulative frequency at some index we repeatedly remove the last bit of the corresponding index and accumulate the corresponding tree frequency. To update the BIT corresponding to the increase of the frequency at <b>idx</b> by <b>val</b>, we apply the following steps: increment the tree frequency at the current index by <b>val</b> (the starting index is the one whose frequency has changed); add the last bit of <b>idx</b> to itself; and, repeat while <b>idx</b> is less than or equal to <b>MaxIdx</b>. The corresponding function in C++ follows:\n\n```\nvoid update(int idx, int val){\n    while (idx <= MaxIdx){\n        tree[idx] += val;\n        idx += (idx & -idx);\n    }\n}\n```\n\nNote that the functions <b>read</b> and <b>update</b> in some sense perform inverse operations of each other -- in <b>read<b/> we subtract while in <b>update</b> we add the last bit of the current index.\n\nThe following example illustrates <b>update</b> for <b>idx</b> = 5:\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>idx</th><th>position of the last bit</th><th>idx & -idx</th></tr></thead><tbody>  <tr><td>1</td><td>5 = 101</td><td>0</td><td>1 (2 ^0)</td></tr>  <tr><td>2</td><td>6 = 110</td><td>1</td><td>2 (2 ^1)</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>3</td><td>8 (2 ^3)</td></tr>  <tr><td>4</td><td>16 = 10000</td><td>4</td><td>16 (2 ^4)</td></tr>  <tr><td>5</td><td>32 = 100000</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/25Kj4cq7Ab9M6eBRyM8cfU/80c135356c9820412c84b9e65582ac83/bitupdate.gif\" style=\"margin: 10px;\" title=\"updating a tree; the picture shows each step; (in the brackets are tree frequencies before the update)\">\n  \n<i>Image 1.6 – Updating a tree (in the brackets are tree frequencies before the update); the arrows show the path while the tree is being updated from index to <b>MaxIdx</b> (the image shows an example for index 5)</i>\n</center>\n\nUsing the algorithm above or following the arrows shown in Image 1.6 we can update <b>BIT</b>.\n\n<h3>*Time complexity:* O(log MaxIdx).<br>\n*Code length:* Up to ten lines.</h3>\n\n## <a id=\"reada\" name=\"reada\"></a>Read the actual frequency at a position\nWe have described how to read the cumulative frequency at a given index. Assume that we want to get the actual frequency at index <b>idx</b>. It is obvious that we can not simply return <b>tree[idx]</b> to achieve that. One approach to get the frequency at a given index is to maintain an additional array. In this array, we separately store the frequency for each index. Reading or updating a frequency takes O(1) time; the memory space is linear. However, it is also possible to obtain the actual frequency at a given index without using additional structures.\n\nFirst, the frequency at index <b>idx</b> can be calculated by calling the function <b>read</b> twice – <b>f[idx] = read(idx) – read(idx – 1)</b> — by taking the difference of two adjacent cumulative frequencies. This procedure works in 2 * O(log n) time. There is a different approach that has lower running time complexity than invoking <b>read</b> twice, lower by a constant factor. We now describe this approach.\n\nThe main idea behind this approach is motivated by the following observation. Assume that we want to compute the sum of frequencies between two indices. For each of the two indices, consider the path from the index to the root. These two paths meet at some index (at latest at index 0), after which point they overlap. Then, we can calculate the sum of the frequencies along each of those two paths until they meet and subtract those two sums. In that way we obtain the sum of the frequencies between that two indices.\n\nWe translate this observation to an algorithm as follows. Let <b>x</b> be an index and <b>y</b>=<b>x</b>-1. We can represent (in binary notation) <b>y</b> as <b>a0b</b>, where <b>b</b> consists of all ones. Then, <b>x</b> is <b>a1b¯</b> (note that <b>b¯</b> consists of all zeros). Now, consider the first iteration of the algorithm <b>read</b> applied to <b>x</b>. In the first iteration, the algorithm removes the last bit of <b>x</b>, hence replacing <b>x</b> by <b>z</b>=<b>a0b¯</b>.\n\nNow, let us consider how the active index <b>idx</b> of the function <b>read</b> changes from iteration to iteration on the input <b>y</b>. The function <b>read</b> removes, one by one, the last bits of <b>idx</b>. After several steps, the active index <b>idx</b> becomes <b>a0b¯</b> (as a reminder, originally <b>idx</b> was equal to <b>y</b>=<b>a0b</b>), that is the same as <b>z</b>. At that point we stop as the two paths, one originating from <b>x</b> and the other one originating from <b>y</b>, have met. Now, we can write our algorithm that resembles this discussion. (Note that we have to take special care in case <b>x</b> equals 0.) A function in C++:\n\n```\nint readSingle(int idx){\nint sum = tree[idx]; // this sum will be decreased\nif (idx > 0){ // the special case\n    int z = idx - (idx & -idx);\n    idx--; // idx is not important anymore, so instead y, you can use idx\n    while (idx != z){ // at some iteration idx (y) will become z\n        sum -= tree[idx]; \n// substruct tree frequency which is between y and \"the same path\"\n        idx -= (idx & -idx);\n    }\n}\nreturn sum;\n}\n```\n\nHere is an example for getting the actual frequency for index 12:\n\nFirst, we calculate <b>z = 12 – (12 & -12) = 8</b>, <b>sum = 11</b>\n\n<center><table class=\"tableizer-table\"> <thead><tr class=\"tableizer-firstrow\"><th>iteration</th><th>y</th><th>position of the last bit</th><th>y & -y</th><th>sum</th></tr></thead><tbody>  <tr><td>1</td><td>11 = 1011</td><td>0</td><td>1 (2 ^0)</td><td>9</td></tr>  <tr><td>2</td><td>10 = 1010</td><td>1</td><td>2 (2 ^1)</td><td>2</td></tr>  <tr><td>3</td><td>8 = 1000</td><td>—</td><td>—</td><td>—</td></tr> </tbody></table></center>\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/7N1GelGEUWMWqK5NAejfsg/e08316d27d55af28ff7f8f6fd58eaa49/reada.gif\" style=\"margin: 10px;\" title=\"read actual frequency at some index in BIT\">\n*Image 1.7 – read the actual frequency at some index by using BIT (the image shows an example for index 12)*\n</center>\n\nIt is clear from the algorithm that it runs faster than invoking <b>read</b> twice -- the while loop corresponds to a single invocation of <b>read</b>. Furthermore, for any odd number this algorithm runs in constant time.\n<h3>\n<i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to fifteen lines.\n</h3>\n\n## <a id=\"scaling\" name=\"scaling\"></a>Scaling the entire tree by a constant factor\nNow we describe how to scale all the frequencies by a factor <b>c</b>. Simply, each index <b>idx</b> is updated by <b>-(c – 1) * readSingle(idx) / c</b> (because <b>f[idx] – (c – 1) * f[idx] / c = f[idx] / c</b>). The corresponding function in C++ is:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        update(-(c - 1) * readSingle(i) / c , i);\n}\n```\n\nThis can also be done more efficiently. Namely, each tree frequency is a linear composition of some frequencies. If we scale each frequency by some factor, we also scale a tree frequency by that same factor. Hence, instead of using the procedure above, which has time complexity O(MaxIdx * log MaxIdx), we can achieve time complexity of O(MaxIdx) by the following:\n\n```\nvoid scale(int c){\n    for (int i = 1 ; i <= MaxIdx ; i++)\n        tree[i] = tree[i] / c;\n}\n```\n\n<h3><i>Time complexity:</i> O(MaxIdx).<br>\n<i>Code length:</i> Just a few lines.</h3>\n\n## <a id=\"find\" name=\"find\"></a>Find index with given cumulative frequency\nConsider a task of finding an index which corresponds to a given cumulative frequency, i.e., the task of perfoming an inverse operation of <b>read</b>. A naive and simple way to solve this task is to iterate through all the indices, calculate their cumulative frequencies, and output an index (if any) whose cumulative frequency equals the given value. In case of negative frequencies it is the only known solution. However, if we are dealing only with non-negative frequencies (that means cumulative frequencies for greater indices are not smaller) we can use an algorithm that runs in a logarithmic time, that is a modification of <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> binary search</a>. The algorithms works as follows. Iterate through all the bits (starting from the highest one), define the corresponding index, compare the cumulative frequency of the current index and given value and, according to the outcome, take the lower or higher half of the interval (just like in binary search). The corresponding function in C++ follows:\n\n```\n// If in the tree exists more than one index with the same\n// cumulative frequency, this procedure will return \n// some of them\n\n// bitMask - initialy, it is the greatest bit of MaxIdx\n// bitMask stores the current interval that should be searched\nint find(int cumFre){\n  int idx = 0; // this variable will be the output\n\n  while (bitMask != 0){\n     int tIdx = idx + bitMask; // the midpoint of the current interval\n     bitMask >>= 1; // halve the current interval\n     if (tIdx > MaxIdx) // avoid overflow\n       continue;\n     if (cumFre == tree[tIdx]) // if it is equal, simply return tIdx\n       return tIdx;\n     else if (cumFre > tree[tIdx]){\n       // if the tree frequency \"can fit\" into cumFre,\n       // then include it\n       idx = tIdx; // update index\n       cumFre -= tree[tIdx]; // update the frequency for the next iteration\n     }\n }\n if (cumFre != 0) // maybe the given cumulative frequency doesn't exist\n   return -1;\n else\n   return idx;\n}\n\n// If in the tree exists more than one index with a same\n// cumulative frequency, this procedure will return \n// the greatest one\nint findG(int cumFre){\n  int idx = 0;\n\n  while (bitMask != 0){\n    int tIdx = idx + bitMask;\n    bitMask >>= 1;\n    if (tIdx > MaxIdx)\n      continue;\n    if (cumFre >= tree[tIdx]){\n      // if the current cumulative frequency is equal to cumFre,\n      // we are still looking for a higher index (if exists)\n      idx = tIdx;\n      cumFre -= tree[tIdx];\n    }\n  }\n  if (cumFre != 0)\n    return -1;\n  else\n    return idx;\n}\n```\n\nExample for cumulative frequency 21 and function <b>find</b>:\n\n__First iteration__ - tIdx is 16; tree[16] is greater than 21; halve bitMask and continue\n\n__Second iteration__ - tIdx is 8; tree[8] is less than 21, so we should include first 8 indices in result, remember idx because we surely know it is part of the result; subtract tree[8] of cumFre (we do not want to look for the same cumulative frequency again – we are looking for another cumulative frequency in the rest/another part of tree); halve bitMask and continue\n\n__Third iteration__ - tIdx is 12; tree[12] is greater than 9 (note that the tree frequencies corresponding to tIdx being 12 do not overlap with the frequencies 1-8 that we have already taken into account); halve bitMask and continue\n\n__Fourth iteration__ - tIdx is 10; tree[10] is less than 9, so we should update values; halve bitMask and continue\n\n__Fifth iteration__ - tIdx is 11; tree[11] is equal to 2; return index (tIdx)\n\n<h3><i>Time complexity:</i> O(log MaxIdx).\n<i>Code length:</i> Up to twenty lines.</h3>\n\n## <a id=\"2d\" name=\"2d\"></a>2D BIT\nBIT can be used as a multi-dimensional data structure. Suppose you have a plane with dots (with non-negative coordinates). There are three queries at your disposal:\n\n1. set a dot at (x , y)\n\n2. remove the dot from (x , y)\n\n3. count the number of dots in rectangle (0 , 0), (x , y) – where (0 , 0) is down-left corner, (x , y) is up-right corner and sides are parallel to x-axis and y-axis.\n\nIf <b>m</b> is the number of queries, <b>max_x</b> is the maximum x coordinate, and <b>max_y</b> is the maximum y coordinate, then this problem can be solved in O(m * log (max_x) * log (max_y)) time as follows. Each element of the tree will contain an array of dimension max_y, that is yet another BIT. Hence, the overall structure is instantiated as <b>tree[max_x][max_y]</b>. Updating indices of x-coordinate is the same as before. For example, suppose we are setting/removing dot (<b>a</b> , <b>b</b>). We will call <b>update(a , b , 1)/update(a , b , -1)</b>, where <b>update</b> is:\n\n```\nvoid update(int x , int y , int val){\n    while (x <= max_x){\n        updatey(x , y , val); \n        // this function should update the array tree[x]\n        x += (x & -x); \n    }\n}\n```\n\nThe function <b>updatey</b> is the “same” as function <b>update</b> provided in the beginning of this note:\n\n```\nvoid updatey(int x , int y , int val){\n    while (y <= max_y){\n        tree[x][y] += val;\n        y += (y & -y); \n    }\n}\n```\n\nThese two functions can also be written as two nested loop:\n\n```\nvoid update(int x , int y , int val){\n    int y1;\n    while (x <= max_x){\n        y1 = y;\n        while (y1 <= max_y){\n            tree[x][y1] += val;\n            y1 += (y1 & -y1); \n        }\n        x += (x & -x); \n    }\n}\n```\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/3MQKDxc9f5OmVoAkPnhvIA/3bbbda671a15aab0baec38f77e02ba80/bit2d.gif\" style=\"margin: 10px;\" title=\"BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3)\">\n<i>Image 1.8 – BIT is array of arrays, so this is two-dimensional BIT (size 16 x 8). Blue fields are fields which we should update when we are updating index (5 , 3).</i>\n</center>\n\nThe modification for other functions is very similar. Also, note that BIT can be used as an n-dimensional data structure.\n\n### <a id=\"lazy\" name=\"lazy\"></a>Lazy Modification\nSo far we have presented BIT as a structure which is entirely allocated in memory during the initialization. An advantage of this approach is that accessing tree[idx] requires a constant time. On the other hand, we might need to access only tree[idx] for a couple of different values of idx, e.g. log n different values, while we allocate much larger memory. This is especially aparent in the cases when we work with multidimensional BIT.\n\nTo alleviate this issue, we can allocate the cells of a BIT in a lazy manner, i.e. allocate when they are needed. For instance, in the case of 2D, instead of defining BIT tree as a two-dimensional array, in C++ we could define it as map<pair<int, int>, int>. Then, accessing the cell at position (x, y) is done by invoking tree[make_pair(x, y)]. This means that those (x, y) pairs that are never needed will never be created. Since every query visits O(log (max_x) * log (max_y)) cells, if we invoke q queries the number of allocated cells will be O(q log (max_x) * log (max_y)).\n\nHowever, now accessing (x, y) requires logarithmic time in the size of the corresponding map structure representing the tree, compared to only constant time previously. So, by losing a logarithmic factor in the running time we can obtain memory-wise very efficient data structure that per query uses only O(log (max_x) * log (max_y)) memory in 2D case, or only O(log MaxIdx) memory in the 1D case.\n\n### <a id=\"prob\" name=\"prob\"></a>Sample problem\n\n- <a href=\"https://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990\">SRM 310 – FloatingMedian</a>\n- Problem 2:\n__Statement:__\nThere is an array consisting of <b>n</b> cards. Initially, each card is put on the table with its face down. There are two queries:\n1. T i j (switch the side of each card from index i to index j, inclusive –- each card with face down becomes with face up; each card with face up becomes with face down)\n2. Q i (output 0 if the i-th card is face down, otherwise output 1)\n\n__Solution:__\n\nThis problem has a solution based on BIT that for each query has time complexity O(log n).\n\nFirst, we instantiate an array <b>f</b> of length <b>n + 1</b>. (The array <b>f</b> is not a BIT.) On a query \"T i j\" we set <b>f[i]++</b> and <b>f[j + 1]–-</b>. In this way, for each card <b>k</b> between <b>i</b> and <b>j</b>, inclusive, the sum <b>f[1] + f[2] + … + f[k]</b> is increased by 1, and for all the other cards that sum remains the same as before (see Image 2.0 for clarification). To answer a query \"Q k\", we compute the described cumulative sum (that can be seen as a cumulative frequency) and output it modulo 2.\n\n<center>\n<img alt=\"\" border=\"0\" src=\"//images.ctfassets.net/piwi0eufbb2g/1oYSjjMcFNbyFrOXyXt4lH/036a67fb9459c1d5b9e7136620b2cb97/problem2.gif\" style=\"margin: 10px;\"><i>Image 2.0</i></center>\n\nUse <b>BIT</b> to increase/decrease the entries of <b>f</b> and to efficiently read the corresponding cumulative frequency.\n\n\n### <a id=\"conc\" name=\"conc\"></a>Conclusion\n- Binary Indexed Trees are very easy to code.\n- Each query on Binary Indexed Tree takes constant or logarithmic time.\n- Binary Indexeds Tree require linear memory space.\n- You can use it as an n-dimensional data structure.\n- The space requirement can be additionaly optimized by lazily allocating BIT cells, while in the same time losing only logarithmic factor in the running time.\n\n### <a id=\"ref\" name=\"ref\"></a>References\n[1] <a href=\"https://www.topcoder.com/thrive/articles/Range%20Minimum%20Query%20and%20Lowest%20Common%20Ancestor\"> RMQ</a>\n[2] <a href=\"https://www.topcoder.com/thrive/articles/Binary%20Search\"> Binary Search</a>\n[3] <a href=\"http://www.topcoder.com/tc?module=LinkTracking&link=http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue3/spe884.pdf&refer=binaryIndexedTrees\" target=\"_blank\">Peter M. Fenwick</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}}],"upvotes":60,"downvotes":7,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"1vpMfunRxbnOKAGChds1YV"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5TqRULfnIOllJzEDD4l4FG","type":"Entry","createdAt":"2022-03-08T09:52:16.111Z","updatedAt":"2022-09-01T05:08:50.923Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":48,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"N-th Tribonacci Number","slug":"n-th-tribonacci-number","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Rte82DJ0sXfUl9RRcJ2O3","type":"Entry","createdAt":"2019-09-18T07:37:35.298Z","updatedAt":"2019-09-18T07:37:35.298Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Dynamic Programming","trackParent":"Competitive Programming"}},{"sys":{"type":"Link","linkType":"Entry","id":"5WVdjexpOgcs2bMMKJM2kH"}}],"tags":["C++"],"creationDate":"2022-03-08","readTime":"7min","content":"### About the problem:\nJust like the Fibonacci sequence, which can be defined as F<sub>n</sub> = F<sub>n-1</sub> + F<sub>n-2</sub> where F\\[0\\] = 0, F\\[1\\] = 1, the Tribonacci sequence can be defined as T<sub>n</sub> = T<sub>n-1</sub> + T<sub>n-2</sub> + T<sub>n-3</sub> where T\\[0\\] = 1, T\\[1\\] = 1,T\\[2\\] = 1. Here we are provided with a number and we are to return T<sub>n</sub>.\n\n__Example 1:__\nInput: 15\nOutput: 3136\n\n__Example 2:__\nInput: 26\nOutput: 2555757\n\n### Approach #1: Recursion, Brute Force\nIn this approach, we simply make recursion for the last three values for every n.\n\nCode:\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\n\nint getTrib(int n){\n    if (n == 0)\n        return 0;\n\n    if (n == 1 || n == 2)\n        return 1;\n\n    return getTrib(n-1)+getTrib(n-2)+getTrib(n-3);\n}\n\nint main(){\n\n    int n;\n    cin >> n;\n\n    cout << getTrib(n);\n}\n```\n\n__Time complexity:__ O(3n), we make three recursion calls for every n resulting in an exponential complexity.\n\n### Approach #2: Dynamic Programing\nIn the previous approach, we made calls for the same n again and again, so now we just store the values of n, as we have already calculated the answer, and simply return the calculated value when called.\nWe have discussed both top-down and bottom-up approaches here.\n\nCode:\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\nconst int N = 1e5;\n\nint trib[N];\n\nint getTribRecursive(int n){\n    if (n == 0)\n        return 0;\n\n    if (n == 1 || n == 2)\n        return 1;\n\n    if(trib[n]!=-1) return trib[n];\n\n    return trib[n] = getTribRecursive(n-1)+getTribRecursive(n-2)+getTribRecursive(n-3);\n}\n\nint getTribIterative(int n){\n\n    trib[0] = 0;\n    trib[1] = trib[2] = 1;\n\n    for (int i = 3; i <=n; i++)\n        trib[i] = trib[i - 1] + trib[i - 2] + trib[i - 3];\n\n    return trib[n];   \n}\n\nint main(){\n\n    int n;\n    cin >> n;\n\n    memset(trib,-1,sizeof trib);\n    // Recursive DP approach i.e, memorization\n    cout << getTribRecursive(n) << endl;\n\n    // Iterative DP approach\n    cout << getTribIterative(n) << endl;\n}\n```\n\n__Time complexity:__ O(n), both the above solutions have a linear runtime complexity.\n\n### Approach #3: Space Efficient\nThe above approach has an O(n) space complexity for storing the values of subproblems. We can reduce it to O(1) as we only need to store the last three values for calculating the values of next.\n\nCode:\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\n\nint getTrib(int n){\n    if (n == 0)\n        return 0;\n\n    if (n < 3)\n        return 1;\n\n    int x = 0, y = 1,z = 1,ans;\n\n    for (int i = 3; i <=n; i++){\n        ans = x + y + z;\n            x = y;\n            y = z;\n            z = ans;\n    }\n    return ans;\n}\n\nint main(){\n\n    int n;\n    cin >> n;\n\n    cout << getTrib(n) << endl;\n\n}\n```\n\n__Time complexity:__ O(n)\n__Space complexity:__ O(1), only three variables are used.\n\n### Approach #4: Matrix Exponentiation\nTo solve recurrence relations like Fibonacci or, in this case, Tribonacci, matrix exponentiation can be employed.\n\nCode:\n```cpp\n#include <bits/stdc++.h>\nusing namespace std;\n\nvector<vector<int>> M = {{1,1,1},\n                        {1,0,0},\n                        {0,1,0}};\nvector<vector<int>> matrixMul(const vector<vector<int>> &A, const vector<vector<int>> &B) {\n    int n = A.size(),m=B.size(),o=B[0].size();\n\n    vector<vector<int>> C(m, vector<int>(o, 0));\n\n    for(int i=0;i<n;++i)\n        for(int k=0;k<m;++k)\n            for(int j=0;j<o;++j)\n                C[i][j] = C[i][j] + A[i][k] * B[k][j]; \n\n    return C;\n}\n\nvector<vector<int>> matrixPow(const vector<vector<int>> &A, int k) {\n    if(k == 0) {\n        vector<vector<int>> C(A.size(), vector<int>(A.size(), 0));\n        for(int i=0; i < A.size(); ++i) C[i][i] = 1;\n        return C;\n    }\n    if(k == 1) return A;\n\n    vector<vector<int>> C = matrixPow(A, k/2);\n    C = matrixMul(C, C);\n    if(k%2 == 1) return matrixMul(C,A);\n    return C;\n}\n\nint getTrib(int n) {\n    if(n == 0) return 0;\n    if(n<3) return 1;\n\n    int a = 0,b = 1,c = 1;\n\n    vector<vector<int>> C = matrixPow(M, n-2);\n\n    return matrixMul(C, {\n        {c},\n        {b},\n        {a}\n    })[0][0];\n}\n\nint main(){\n\n    int n;\n    cin >> n;\n    cout << getTrib(n) << endl;\n}\n```\n\nWe have three equations:\nf(n) = f(n-1) + f(n-2) + f(n-3)\nf(n-1) = f(n-1)\nf(n-2) = f(n-2)\n\nBy turning them into a matrix relation we get:\n\n| f(n)   |     | 1 1 1 |     | f(n-1) |\n| f(n-1) |  =  | 1 0 0 |  *  | f(n-2) |\n| f(n-2) |     | 0 1 0 |     | f(n-3) |\n\nSince we can compute a matrix exponent by O(log(n)), simplify the relation into exponents.\n\n| f(n)   |     | 1 1 1 |^(n-2)     | f(2) |\n| f(n-1) |  =  | 1 0 0 |       *   | f(1) |\n| f(n-2) |     | 0 1 0 |           | f(0) |\n\nThe matrix multiplication cost is k^3, k=3. So the total cost is O(k^3log(n)).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"a3l0Zo35J49OubdaXhw4v","type":"Asset","createdAt":"2022-03-08T09:45:18.283Z","updatedAt":"2022-03-08T09:45:35.718Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"interpolation (1)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/a3l0Zo35J49OubdaXhw4v/7ba5af4d80e65266c2603ac5aaf8e4bf/interpolation__1_.jpeg","details":{"size":20289,"image":{"width":455,"height":431}},"fileName":"interpolation (1).jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":3,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3lwBHWCkVXIu8uGg0P7MnK"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2FyFPuf9ftL4DguU4YFcoe","type":"Entry","createdAt":"2020-02-19T12:59:58.263Z","updatedAt":"2022-07-11T04:33:32.572Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":148,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Find a Solution","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["SRM","Flood Fill","Problem","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"30 min","content":"[Discuss this article in the forums.](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505843)\n<br/>\n<a href=\"#introduction\">Introduction</a>\n<a href=\"#straightforward\">Straight-forward problems that don’t require a special technique</a>\n<a href=\"#bfs\">Breadth First Search (BFS)</a>\n<a href=\"#floodfill\">Flood Fill</a><\n<a href=\"#bruteNback\">Brute Force and Backtracking</a>\n<a href=\"#bruteforce\">Brute Force</a>\n<a href=\"#backtracking\">Backtracking</a>\n<a href=\"#dp\">Dynamic Programming</a>\n<a href=\"#harddrills\">Hard Drills</a>\n<a href=\"#maximumflow\">Maximum Flow</a>\n<a href=\"#optimal\">Optimal Pair Matching</a>\n<a href=\"#lp\">Linear Programming (Simplex)</a>\n<a href=\"#conclusion\">Conclusion</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nWith many Topcoder problems, the solutions may be found instantly just by reading their descriptions. This is possible thanks to a collection of common traits that problems with similar solutions often have. These traits serve as excellent hints for experienced problem solvers that are able to observe them. The main focus of this article is to teach the reader to be able to observe them too.\n\\\n<a name=\"straightforward\" id=\"straightforward\"></a> __Straight-forward problems that don’t require any special technique (e.g. simulation, searching, sorting etc.)__\n\tIn most cases, these problems will ask you to perform some step by step, straight-forward tasks. Their constraints are not high, and not too low. In most cases the first problems (the easiest ones) in topcoder Single Rounds Matches are of this kind. They test mostly how fast and properly you code, and not necessarily your algorithmic skills.\n\\\nMost simple problems of this type are those that ask you just to execute all steps described in the statement.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BusinessTasks](http://community.topcoder.com/stat?c=problem_statement&pm=1585&rd=6535) – SRM 236 Div 1:__\nN tasks are written down in the form of a circular list, so the first task is adjacent to the last one. A number n is also given. Starting with the first task, move clockwise (from element 1 in the list to element 2 in the list and so on), counting from 1 to n. When your count reaches n, remove that task from the list and start counting from the next available task. Repeat this procedure until one task remains. Return it.\n</div>\n\\\nFor N&lt;=1000 this problem is just a matter of coding, no special algorithm is needed – do this operation step by step until one item is left. Usually these types of problems have a much smaller N, and so we’ll not consider cases where N is very big and for which complicated solution may be needed. Remember that in topcoder competitions even around 100 millions sets of simple operations (i.e. some multiplications, attributions or if statements) will run in allowed time.\n\\\nThis category of problems also includes those that need some simple searches.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[TallPeople](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2923&amp;rd=5854) – SRM 208 Div 1:__\nA group of people stands before you arranged in rows and columns. Looking from above, they form an R by C rectangle of people. Your job is to return 2 specific heights – the first is computed by finding the shortest person in each row, and then finding the tallest person among them (the \"tallest-of-the-shortest\"); and the second is computed by finding the tallest person in each column, and then finding the shortest person among them (the \"shortest-of-the-tallest\").\n</div>\n\\\nAs you see this is a really simple search problem. What you have to do is just to follow the steps described in the statement and find those 2 needed heights. Other TC problems may ask you to sort a collection of items by respecting certain given rules. These problems may be also included in this category, because they too are straight-forward – just sort the items respecting the rules! You can do that with a simple O(N^2) sorting algorithm, or use standard sorting algorithm that exist in your coding language. It’s just a matter of coding.\n<br/>\n__Other example(s):__\n\t__[MedalTable](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2922&amp;rd=5855) – SRM 209 Div 1__.\n<br/>\n\\\n<a name=\"bfs\" id=\"bfs\"></a> __Breadth First Search (BFS)__\n\nProblems that use BFS usually ask to find the fewest number of steps (or the shortest path) needed to reach a certain end point (state) from the starting one. Besides this, certain ways of passing from one point to another are offered, all of them having the same cost of 1 (sometimes it may be equal to another number). Often there is given a N x M table (formed of N lines and M columns) where certain cells are passable and others are impassable, and the target of the problem is to find the shortest time/path needed to reach the end point from the start one. Such tables may represent mazes, maps, cities, and other similar things. These may be considered as classical BFS problems. Because BFS complexity is in most cases linear (sometimes quadratic, or N logN), constraints of N (or M) could be high – even up to 1 million.\n\\\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[SmartWordToy](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3935&amp;rd=6532) – SRM 233 Div 1:__\nA word composed of four Latin lowercase letters is given. With a single button click you can change any letter to the previous or next letter in alphabetical order (for example ‘c’ can be changed to ‘b’ or ‘d’). The alphabet is circular, thus ‘a’ can become ‘z’, and ‘z’ can become ‘a’ with one click.<br/>\nA collection of constraints is also given, each defining a set of forbidden words. A constraint is composed of 4 strings of letters. A word is forbidden if each of its characters is contained in corresponding string of a single constraint, i.e. first letter is contained in the first string, the second letter – in the second string, and so on. For example, the constraint \"lf a tc e\" defines the words \"late\", \"fate\", \"lace\" and \"face\".<br/>\nYou should find the minimum number of button presses required to reach the word finish from the word start without passing through forbidden words, or return -1 if this is not possible.\n</div>\n\\\n__Problem hints:__\n* Words can be considered as states. There are at most 26^4 different words composed of 4 letters (thus a linear complexity will run in allowed time).\n* There are some ways to pass from one state to another.\n* The cost of passing from a state to another is always 1 (i.e. a single button click).\n* You need to find the minimum number of steps required to reach the end state from start state.\n\nEverything indicates us that it’s a problem solved by the help of a BFS. Similar things can be found in any other BFS problems. Now let’s see an interesting case of BFS problems.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[CaptureThemAll](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2915&amp;rd=5853) – SRM 207 Div 2 (3rd problem):__\nHarry is playing a chess game. He has one knight, and his opponent Joe has a queen and a rook. Find the minimum number of steps that Harry’s knight has to jump so that it captures both the queen and the rook.\n</div>\n\n__Problem hints:__ At first sight this may seem like dynamic programming or backtracking. But as always, take a look into the text of the statement. After a while you should observe the following things: \n\n* A table is given.\n* The knight can jump from one cell to some of its neighbors.\n* The cost of passing from a cell to another is always 1 (just one jump).\n* You need to find the minimum number of steps (jumps).\n\nGiven this information we can see that the problem can be easily solved by the help of BFS. Don’t get confused by the fact that connected points are represented by unconnected cells. Think of cells as points in a graph, or states (whatever you want) – and in order to pass from one point to another, the knight should be able to jump from the first to the second point.\n\nNotice again that the most revealing hint about the BFS solution is the cost of 1 for any jump.\n\nTrain yourself in finding the hints of a BFS problem in following examples:\n\n__Other example(s):__\n__[RevolvingDoors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3064&amp;rd=5869) – SRM 223 Div 1__.\n__[WalkingHome](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3444&amp;rd=5868) – SRM 222 Div 1__.\n__[TurntableService](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3117&amp;rd=5865) – SRM 219 Div 1__.\n<br/>\n\\\n<a name=\"floodfill\" id=\"floodfill\"></a> __Flood Fill__\nSometimes you may encounter problems that are solved by the help of Flood Fill, a technique that uses BFS to find all reachable points. The thing that makes them different from BFS problems described above is that a minimum path/cost is not needed.\nFor example, imagine a maze where 1 represents impassable cells and 0 passable cells. You need to find all cells that are reachable from the upper-left corner. The solution is very simple – take one-by-one a visited vertex, add its unvisited neighbors to the queue of visited vertices and proceed with the next one while the queue is still populated. Note that in most cases a DFS (Depth First Search) will not work for such problems due to stack overflows. Better use a BFS. For inexperienced users it may seem harder to implement, but after a little training it becomes a \"piece of cake\". A good example of such problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[grafixMask](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2998&amp;rd=5857) – SRM 211 Div 1:__\nA 400 x 600 bitmap is given. A set of rectangles covers certain parts of this bitmap (the corners of rectangles have integer coordinates). You need to find all contiguous uncovered areas, including their sizes.\n</div>\n\n__Problem hints:__ What do we have here?\n* A map (table)\n* Certain points are impassable (those covered by given rectangles)\n* Contiguous areas need to be found\n\nIt is easy to understand that a problem with such a statement needs a Flood Fill. Usually problems using it are very easy to detect.\n\\\n<a name=\"bruteNback\" id=\"bruteNback\"></a> __Brute Force and Backtracking__\nI have placed these 2 techniques in the same category because they are very similar.  Both do the same thing – try all possible cases (situations) and choose the best one, or count only those that are needed (depending on the problem). Practically, Backtracking is just more advanced and optimized than Brute Force. It usually uses recursion and is applied to problems having low constraints (for example N&lt;=20). </p>\n\\\n<a name=\"bruteforce\" id=\"bruteforce\"></a>\n__Brute Force__\nThere are many problems that can be solved by the help of a simple brute force. Note that the limits must not be high. How does a brute force algorithm work? Actually, it tries all possible situations and selects the best one. It’s simple to construct and usually simple to implement. If there is a problem that asks to enumerate or find all possible ways (situations) of doing a certain thing, and that doesn’t have high limits – then it’s most probably a brute force problem.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[GeneralChess](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2430&amp;rd=5072) – SRM 197 Div 1:__\nYou are given some knights (at most 8), with their positions on the table (-10000&lt;=x, y&lt;=10000). You need to find all positions to place another one, so that it threatens all given pieces. \n</div>\n\n__Problem hints:__ Well, this is one of the easiest examples. So which are the hints of this statement?\n* You need to find all possible situations (positions) that satisfy a certain rule (threatens all given pieces).\n* The limits are very low – only 8 knights are at most given.\n\nIt’s a common Brute Force problem’s statement. Note that x and y limits are not relevant, because you need only try all positions that threaten one of the knights. For each of these positions see if the knight placed at that position threatens all others too.\n\nAnother interesting problem would be:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[LargestCircle](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3005&amp;rd=5858) – SRM 212 Div 2 (3rd problem):__\nGiven a regular square grid, with some number of squares marked, find the largest circle you can draw on the grid that does not pass through any of the marked squares. The circle must be centered on a grid point (the corner of a square) and the radius must be an integer. Return the radius of the circle.\n<br/> The size of the grid is at most 50.\n</div>\n\n__Problem hints:__ And again one of the most important hints is the low limit of the size of the grid – only 50. This problem is possible to be solved with the help of the Brute Force because for each cell you can try to find the circle whose center is situated in that cell and that respects the rules. Among all of these circles found, select the one that has the greatest radius.\n\nComplexity analysis: there are at most 50×50 cells, a circle’s radius is an integer and can be at most 25 units, and you need a linear time (depending on your implementation) for searching the cells situated on the border of the circle. Total complexity is low and thus you can apply a simple Brute Force here.\n\n__Other example(s):__\n__[Cafeteria](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3080&amp;rd=6518) - SRM 229 Div 1__\n__[WordFind](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3972&amp;rd=6521) - SRM 232 Div 1__\n\n<a name=\"backtracking\" id=\"backtracking\"></a> __Backtracking__\nThis technique may be used in many types of problems.  Just take a look at the limits (N, M and other main parameters). They serve as the main hint of a backtrack problem. If these are very small and you haven’t found a solution that’s easier to implement – then just don’t waste your time on searching it and implement a straight-forward backtracking solution.\n\nUsually problems of this kind ask you to find (similarly to Brute Force):\n1. Every possible configuration (subset) of items. These configurations should respect some given rules.\n2. The \"best\" configuration (subset) that respects some given rules.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[BridgeCrossing](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1599&amp;rd=4535) – SRM 146 Div 2 (3rd problem):__\nA group of people is crossing an old bridge. The bridge cannot hold more than two people at once. It is dark, so they can’t walk without a flashlight, and they only have one flashlight! Furthermore, the time needed to cross the bridge varies among the people in the group. When people walk together, they always walk at the speed of the slowest person. It is impossible to toss the flashlight across the bridge, so one person always has to go back with the flashlight to the others. What is the minimum amount of time needed to get all the people across the bridge?\n<br/> There are at most 6 people.\n</div>\n\n__Problem hints:__\n* First look at the constraints – there are at most ONLY 6 people! It’s enough for generating all possible permutations, sets etc.\n* There are different possible ways to pass the people from one side to another and you need to find the best one.\n\nThis is of course a problem solved with a backtracking: at the beginning choose any 2 people to pass the bridge first, and after that at each step try to pass any of those that have been left on the start side. From all these passages select the one that needs the smallest amount of time. Note that among persons that have passed over the bridge, the one having the greatest speed should return (it’s better than returning one having a lower speed). This fact makes the code much easier to implement. After having realized these things – just code the solution. There may be others – but you will lose more time to find another than to code this one.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[MNS](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – SRM 148 Div 1:__\n9 numbers need to be arranged in a magic number square. A magic number square is a square of numbers that is arranged such that every row and column has the same sum. You are given 9 numbers that range from 0 to 9 inclusive. Return the number of distinct ways that they can be arranged in a magic number square. Two magic number squares are distinct if they differ in value at one or more positions. \n</div>\n\n__Problem hints:__ Only 9 numbers are given at most; and every distinct way (configuration) to arrange the numbers so that they form a magic number square should be found.\n\nThese are the main properties of a Backtracking problem. If you have observed them – think about the code. You can generate all permutations of numbers and for each of them check if it forms a magic square. If so – add it to the answer. Note that it must be unique. A possible way to do that – is to have a list of earlier found configurations, thus for each new magic square check if it exists in that list and if it doesn’t – add it to the answer. There will not be many distinct magic squares, thus no additional problems will appear when applying this method.\n\n__Other example(s):__\n\n__[WeirdRooks](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3998&amp;rd=6533) - SRM 234 Div 1__\n\\\n<a name=\"dp\" id=\"dp\"></a> __Dynamic Programming__\nQuite a few problems are solved with the help of this technique. Knowing how to detect this type of problem can be very valuable.  However in order to do so, one has to have some experience in dynamic programming. Usually a DP problem has some main integer variables (e.g. N) which are neither too small, nor too big – so that a usual DP complexity of N^2, N^3 etc. fits in time. Note that in the event that N is very small (for TC problems usually less than 30) – then it is likely the problem is not a DP one. Besides that there should exist states and one or more ways (rules) to reach one greater state from another lower one.  In addition, greater states should depend only upon lower states. What is a so-called state? It’s just a certain configuration or situation. To better understand dynamic programming, you may want to read [this article](http://community.topcoder.com/tc?module=Static&amp;d1=tutorials&amp;d2=dynProg).\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nLet’s analyze a simple classic DP problem:<br/>\nGiven a list of N coins with their values (V1, V2, … ,VN), and the total sum S. Find the minimum number of coins the sum of which is S (you can use as many coins of one type as you want), or report that it’s not possible to select coins in such a way that they sum up to S.<br/>\nLet N &lt;= 1,000 and S &lt;= 1,000.\n</div>\n\n__Problem hints:__\n* Two main integer variables are given (N and S). These are neither too small, nor are they too big (i.e. a complexity of N*S fits in time).\n* A state can be defined as the minimum number of coins needed to reach a certain sum.\n* A sum (state) i depends only on lower sums (states) j (j&lt;i).\n* By adding a coin to a certain sum – another greater sum is reached. This is the way to pass from one state to another.\n\nThus all properties of a DP problem are uncovered in this statement. Let’s see another (slightly harder) DP problem:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[ZigZag](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1744&amp;rd=4545) – 2003 TCCC Semifinals 3:__\nA sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a zig-zag sequence. Given a sequence of integers, return the length of the longest subsequence that is a zig-zag sequence. A subsequence is obtained by deleting some number of elements (possibly zero) from the original sequence, leaving the remaining elements in their original order. Assume the sequence contains between 1 and 50 elements, inclusive. \n</div>\n\n__Problem hints:__\n* There are N numbers given (1&lt;=N&lt;=50), thus N isn’t too small, nor too big.\n* A state (i,d) can be defined as the length of the longest zig-zag subsequence ending with the i-th number, for which the number before the last one is smaller than it for d=0, and bigger for d=1.\n* A state i (i.e. a subsequence ending with the i-th number) depends only on lower states j (j&lt;i).\n* By adding a number to the end of a subsequence – another bigger (greater) subsequence is created. This is the way to pass from one state to another.\n\nAs you can see – this statement has almost the same traits (pattern) as in the previous problem. The most difficult part in identifying a DP problem statement is observing/seeing the states with the properties described above. Once you can do that, the next step is to construct the algorithm, which is out of the scope of this article.\n\n__Other example(s):__\n__[ChessMetric](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1592&amp;rd=4482) - 2003 TCCC Round 4__\n__[AvoidRoads](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1889&amp;rd=4709) - 2003 TCO Semifinals 4__\n__[FlowerGarden](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1918&amp;rd=5006) - 2004 TCCC Round 1__\n__[BadNeighbors](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2402&amp;rd=5009) - 2004 TCCC Round 4__\n\\\n<a name=\"harddrills\" id=\"harddrills\"></a> __Hard Drills:__\n<a name=\"maximumflow\" id=\"maximumflow\"></a> __Maximum Flow__\n\nIn many cases it’s hard to detect a problem whose solution uses maximum flow.  Often you have to create/define graphs with capacities based on the problem statement.\n\nHere are some signs of a Maximum Flow problem:\n* Take a look at the constraints, they have to be appropriate for a O(N^3) or O(N^4) solution, i.e. N shouldn’t be greater than 500 in extreme cases (usually it’s less than 100).\n* There should be a graph with edges having capacities given, or you should be able to define/create it from data given in the statement.\n* You should be finding a maximum value of something.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\nSample problem:<br/>\nYou are given a list of water pipes, each having a certain maximum water flow capacity. There are water pipes connected together at their extremities. <br/>\nYou have to find the maximum amount of water that can flow from start junction to end junction in a unit of time. <br/>\nLet N&lt;=100. <br/>\n</div>\n\nAs you can see – it’s a straight-forward maximum flow problem: water pipes represent edges of the graph, their junctions – vertices; and you have to find the maximum value of amount of water that can flow from start to end vertex in a unit of time.\n\\\n<a name=\"optimal\" id=\"optimal\"></a> __Optimal Pair Matching:__\nThese problems usually have a list of items (from a set A) for which other items (from a set B) should be assigned under some rules, so that all (or a maximum possible number of) items from set A have to each be assigned to a certain item from set B.\n\n__Mixed:__\nSome problems need other techniques in addition to network flows.\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Parking](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3530&amp;rd=6535) - SRM 236 Div 1:__\nN cars and M parking lots are given. They are situated on a rectangular surface (represented by a table), where certain cells are impassable. You should find a way to assign each car to a parking lot, so that the greatest of the shortest distances from each car to its assigned parking lot is as small as possible. Each parking lot can have at most one car assigned to it. \n</div>\n__Problem hints:__ By reading this problem one can simply understand the main idea of the solution – it should be something similar to optimal pair matching, because each car (point from a set A) should be assigned to a parking lot (point from a set B) so that all are assigned and that there is at most one car assigned to a parking lot. Additionally, there can be cars that can’t reach certain parking lots, thus some pairs of points (one point from A and the other from B) are not connected. However a graph should be created for optimal pair matching. The way to make it is clear – an edge exists between a car and a parking lot if only there is a path between them, and its cost is equal to the shortest distance needed for the car to reach the parking lot. The next step of the solution is a binary search on the longest edge. Although it may be out of the scope of this article, I will provide a short explanation: At each step delete those edges of the initial graph that have costs greater than a certain value C (Note that you’ll have to save the initial graph’s state in order to repeat this step again for other C values). If it’s possible in this case to assign all the cars to parking lots – then take a smaller C, and repeat the same operation. If not – take a greater C. After a complete binary search, the smallest C for which a complete assignment is possible will be found. This will be the answer.\n\\\n<a name=\"lp\" id=\"lp\"></a> __Linear Programming (Simplex)__\nMost of the common traits of problems solved with the help of the linear programming technique are:\n* You are given collection of items having different costs/weights. There is a certain quantity of each item that must be achieved.\n* A list of sets is given. These sets are composed of some of the available items, having certain quantities of each of them. Each set has a certain cost. \n* The goal of the problem is to find an optimal combination (the cheapest one) of these sets so that the sum of quantities of each of the items they have is exactly the one needed to achieve.\n\nAt first it may seem confusing, but let’s see an example:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n__[Mixture](http://community.topcoder.com/stat?c=problem_statement&amp;pm=3942&amp;rd=6520) - SRM 231 Div 1:__\nA precise mixture of a number of different chemicals, each having a certain amount, is needed. Some mixtures of chemicals may be purchased at a certain price (the chemical components for the mixture might not be available in pure form). Each of them contains certain amounts of some of the chemicals. You need not purchase the available mixtures in integral amounts. Hence if you purchase a 1.5 of a mixture having a price of 3 and amounts of \"2 0 1\", you’ll pay 4.5 and get \"3 0 1.5\" amounts of chemicals. Your task is to determine the lowest price that the desired mixture can be achieved. \n</div>\n__Problem hints:__\n* A collection of items (chemicals).\n* A list of sets (available mixtures), each containing certain amounts of each of the items, and having a certain cost.\n* You need to find the lowest price of the desired collection of items achieved by the combination of the available sets. More than that – you can take also non-integral amounts of mixtures.\n\nThese are exactly the traits described above.\n\\\n<a name=\"conclusion\" id=\"conclusion\"></a>\n__Conclusion__\nIf you have found this article interesting and you have learned new things from it – train yourself on any of the problems in the topcoder Algorithm Arena. Try hard to see the hints and determine the type of the solution by carefully reading through the problem statement. Remember, there are still many problems that may not be included properly in any of the categories described above and may need a different approach.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":27,"downvotes":1}},{"sys":{"type":"Link","linkType":"Entry","id":"KSh5Ua02xAveBntVYQdO9"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5VlvQn11IM6AF3cAjNZ1gy","type":"Entry","createdAt":"2022-05-11T07:11:39.558Z","updatedAt":"2022-05-11T07:11:39.558Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":57,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Reverse Doubly Linked Lists","slug":"reverse-doubly-linked-lists","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["Data Structures","JAVA"],"creationDate":"2022-05-11","readTime":"13min","content":"Suppose we are given a Doubly Linked List (DLL) and we need to reverse it so that the pointer currently pointing to the head of the list will point to the tail of the DLL. In this article we will learn about DLLs and then we will go through different methods of reversing a doubly linked list.\n\n### Difference Between a Linked List and Doubly Linked List\n\n#### Linked List\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/75dKfwFXZIBhf46T2VsL2E/d346a52487f1d0cca81253b87e01f47d/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/75dKfwFXZIBhf46T2VsL2E/d346a52487f1d0cca81253b87e01f47d/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/75dKfwFXZIBhf46T2VsL2E/d346a52487f1d0cca81253b87e01f47d/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n#### Doubly Linked List\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7GDBeNliJWFEDgBxmO31ZI/236f6874535ff6be253e032afd238783/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/7GDBeNliJWFEDgBxmO31ZI/236f6874535ff6be253e032afd238783/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/7GDBeNliJWFEDgBxmO31ZI/236f6874535ff6be253e032afd238783/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### Structures of Singly and Doubly Linked Lists\n\n#### Singly Linked List\n```java\n// A Singly Linked List Node\nclass NodeStructure_SLL\n{\n    int data;\n    Node next; \n    Node(int data, Node next)\n    {\n        this.data = data;\n        this.next = next;\n    }\n}\n```\n\n#### Doubly Linked List\n\n```java\n// A Node Structure for Doubly LinkedList\nclass NodeStructure_DLL\n{\n    public:\n    int data;\n    Node* next; // ptr to nxt node in node in DLL\n    Node* prev; // prev Node in DLL\n\n      Node(int d)\n        {\n            data = d;\n            next = prev = null;\n        }\n\n};\n```\n\n### Structure \nThe basic structure of a linked list will have only data and a link to the next node. But, in the case of a doubly linked list it will include data, a link pointing to the previous node, and a second link pointing to the next node. In a single linked list we cannot traverse in a backward direction, but in a doubly linked list that is possible using the link which points to the previous node. This link to the previous node will increase access to elements of the doubly linked list. This also means that a doubly linked list will use more space as the number of fields will be increased by one for each node. We prefer a doubly linked list when space is not an issue and any traversal algorithm has to be performed.\n\n### Types\nThere are two types of doubly linked lists.\n\n#### Open Linked List\nA doubly linked list where the pointer to the next node of a last node is pointing to null.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1rpbmECaLogH3Pwp285vV4/453c1e154e70c8e8322668f715c321e2/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1rpbmECaLogH3Pwp285vV4/453c1e154e70c8e8322668f715c321e2/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1rpbmECaLogH3Pwp285vV4/453c1e154e70c8e8322668f715c321e2/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n#### Circular Linked List\nA doubly linked list where the pointer to the next node of the last node is pointing to the head node rather than pointing to null. This makes the DLL circular.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3PiPyVCJ8dnRxbA4BGl0qB/49ad53e7818806cdcb123f213455a681/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3PiPyVCJ8dnRxbA4BGl0qB/49ad53e7818806cdcb123f213455a681/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3PiPyVCJ8dnRxbA4BGl0qB/49ad53e7818806cdcb123f213455a681/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### Insertion Deletion Algorithms for Doubly Linked List\nInsertion complexity into singly linked lists is O(N), but in the case of a doubly linked list it becomes O(1) as we also have access to the previous node.\n\n#### Insertion in DLL\nIf we are given node (N1) after which we need to insert a new node (N2) in a DLL, then we will take the pointer to the next node of N1 and keep it in the next of N2. Then the address of current Node N1 will be placed in the first (pointer) of N2 and the address of N2 will be placed in the next (pointer) of N1.\n\n__Algorithm:__\nStep1 : InsertDLL(Node N2, Node current, Node head) // Current = N1\nStep2:  N2->next = current.next;\nStep3:  current.next= N2;\nStep4:  N2.first= current  \nStep5: Return Head of DLL\n\n#### Deletion in a Doubly Linked List\nSuppose a pointer pointing to a node is given which has to be deleted from a DLL. First we will check if this is the only node in the DLL. If yes, NULL (Empty DLL) will be returned, otherwise we will take the next (pointer) of the current node and keep it in next (pointer) of the previous node to this. Then we can remove or delete this node or it can be garbage collected.\n\n__Algorithm__\nStep1: DeleteNodeDLL(Node head, Node current)\n\nStep2: check if current Node if First Node, only One Node in DLL\nIf First Node then head= current->next; Then Step 4\nIf only one Node then head= null, then Step 4\n\nStep3:  prevNode=current.prev;\nprev.next=current.next;\n\nStep4: Return head\n\n#### Reversing a Doubly Linked List \nReversing a DLL is easier than reversing a singly linked list because of the presence of a pointer to the previous node. That means after the end of a function call where we are passing a head pointer to the DLL, we will get a linked list reversed, whose head will be pointing to the last node of passed DLL. In this we will check if the DLL has only one node, then head will be returned, or else we will take a current node and will store its pointer to prev node. Then we will take the next node (N2) of the current node and will make the next pointer of N2 point to the current node. Note we have to update the prev of the current node with temp. Then we can update the current node by making it point to the current’s prev pointer. For better understanding, it is helpful to take a paper and pen and draw a DLL and the process, using the steps accordingly as mentioned in the algorithm.\n\n__Algorithm__\n\nStep 1: function Called reverseDLL(Node head)\n\nStep 2: if head == null or head.next=null GOTO step 6\n\nStep 3: declaration \ntempNode with NULL\ncurrentNode pointing to head of DLL\n\nStep 4: Run a Loop until currentNode start pointing to NULL\n\nStep 5: Under Loop\n//will store the prev because next Node will be pointed from here as it will become previous to current Node \n→temp= current.prev \n//current Node should come after its Next Node so\n→current.prev=current.next\n//current’s previous Node should come after it so will take it and keep it in its Next \n//Which we have stored in temp\n→current.next=temp\n//Current Should be updated for processing next nodes\n→current= current.prev\nNote:\nReason behind above (current= current.prev) is as the next node has become previous to current node, we will take that node from current’s prev pointer.\n\nStep6: Return temp.prev as It will be New head of reversed DLL\n\n__Java Implementation__\n\n```java\npublic class UserDefDLL {\n\n\tpublic Node head;\n\tpublic Node tail;\n\n\tstatic class Node {\n\n    \t//data\n    \tint data;\n    \t// pointer to nxtNode\n    \tNode next;\n    \t// pointer to prevNode\n    \tNode prev;\n\n    \t}\n//Node Class Ends\n\n\t// Create a Doubly Linked List\n\tpublic UserDefDLL() {\n    \tthis.head = null;\n    \tthis.tail = null;\n\t}\n\n\t// Method for reversing doubly linked list\n\tpublic Node reverseDLL() {\n\n    \t//this will store our Previous Node which we will used to make prev Node\n    \t//to make it as Next node of Current Node\n    \tNode previousNode = null;\n\n    \tNode current = head;\n\n\twhile (current != null) {\n        \tpreviousNode = current.prev;\n        \tcurrent.prev = current.next;\n        \tcurrent.next = previousNode;\n        \tcurrent = current.prev;\n    \t}\n    \treturn previousNode;\n\t}\n}\n\npublic static void main(String[] args) {\n\n\t//userDefined Class for Doubly Linked List\n\tUserDefDLL dll = new UserDefDLL();\n\n\t//insertDLL will insert into DLL\n\tdll.insertDLL(4);\n\tdll.insertDLL(3);\n\tdll.insertDLL(2);\n\tdll.insertDLL(1);\n\t// Now DLL we have is 4->3->2->1\n\n\tdll = dll.reverseList();\n\n\t//Now we have reversed DLL\n}\n}\n```\n\n__Code Output__\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4EWHroFymAzRqDJD9WecGp/947facc7843060df27e810d74ff0ea56/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/4EWHroFymAzRqDJD9WecGp/947facc7843060df27e810d74ff0ea56/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/4EWHroFymAzRqDJD9WecGp/947facc7843060df27e810d74ff0ea56/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### References\nhttps://en.wikipedia.org/wiki/Theoretical_Computer_Science_(journal)\nhttps://www.worldscientific.com/doi/abs/10.1142/S0218195911003767\n","contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70ppAv0WygqfWWlipllAZu","type":"Entry","createdAt":"2020-02-20T15:37:44.048Z","updatedAt":"2022-02-13T10:37:14.930Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":372,"revision":78,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Data Structures","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Data Structures","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505847)\n<br/>\nEven though computers can perform literally millions of mathematical computations per second, when a problem gets large and complicated, performance can nonetheless be an important consideration. One of the most crucial aspects to how quickly a problem can be solved is how the data is stored in memory.\n\\\nTo illustrate this point, consider going to the local library to find a book about a specific subject matter. Most likely, you will be able to use some kind of electronic reference or, in the worst case, a card catalog, to determine the title and author of the book you want. Since the books are typically shelved by category, and within each category sorted by author’s name, it is a fairly straightforward and painless process to then physically select your book from the shelves.\n\\\nNow, suppose instead you came to the library in search of a particular book, but instead of organized shelves, were greeted with large garbage bags lining both sides of the room, each arbitrarily filled with books that may or may not have anything to do with one another. It would take hours, or even days, to find the book you needed, a comparative eternity. This is how software runs when data is not stored in an efficient format appropriate to the application.\n<br/><br/>\n### Simple Data Structures\nThe simplest data structures are primitive variables. They hold a single value, and beyond that, are of limited use. When many related values need to be stored, an array is used. It is assumed that the reader of this article has a solid understanding of variables and arrays.\n\\\nA somewhat more difficult concept, though equally primitive, are pointers. Pointers, instead of holding an actual value, simply hold a memory address that, in theory, contains some useful piece of data. Most seasoned C++ coders have a solid understanding of how to use pointers, and many of the caveats, while fledgling programmers may find themselves a bit spoiled by more modern “managed” languages which, for better or worse, handle pointers implicitly. Either way, it should suffice to know that pointers “point” somewhere in memory, and do not actually store data themselves.\n\\\nA less abstract way to think about pointers is in how the human mind remembers (or cannot remember) certain things. Many times, a good engineer may not necessarily know a particular formula/constant/equation, but when asked, they could tell you exactly which reference to check.\n<br/><br/>\n### Arrays\nArrays are a very simple data structure, and may be thought of as a list of a fixed length. Arrays are nice because of their simplicity, and are well suited for situations where the number of data items is known (or can be programmatically determined). Suppose you need a piece of code to calculate the average of several numbers. An array is a perfect data structure to hold the individual values, since they have no specific order, and the required computations do not require any special handling other than to iterate through all of the values. The other big strength of arrays is that they can be accessed randomly, by index. For instance, if you have an array containing a list of names of students seated in a classroom, where each seat is numbered 1 through n, then studentName[i] is a trivial way to read or store the name of the student in seat i.\n\\\nAn array might also be thought of as a pre-bound pad of paper. It has a fixed number of pages, each page holds information, and is in a predefined location that never changes.\n<br/><br/>\n### Linked Lists\nA linked list is a data structure that can hold an arbitrary number of data items, and can easily change size to add or remove items. A linked list, at its simplest, is a pointer to a data node. Each data node is then composed of data (possibly a record with several data values), and a pointer to the next node. At the end of the list, the pointer is set to null.\n\\\nBy nature of its design, a linked list is great for storing data when the number of items is either unknown, or subject to change. However, it provides no way to access an arbitrary item from the list, short of starting at the beginning and traversing through every node until you reach the one you want. The same is true if you want to insert a new node at a specific location. It is not difficult to see the problem of inefficiency.\n\\\nA typical linked list implementation would have code that defines a node, and looks something like this:\n<br/>\n```\nclass ListNode {\nString data;\nListNode nextNode;\n}\nListNode firstNode;\n```\n\\\nYou could then write a method to add new nodes by inserting them at the beginning of the list:\n<br/>\n```\nListNode newNode = new ListNode();\nNewNode.nextNode = firstNode;\nfirstNode = newNode;\n```\n\\\nIterating through all of the items in the list is a simple task:\n<br/>\n```\nListNode curNode = firstNode;\nwhile (curNode != null) {\nProcessData(curNode);\ncurNode = curNode.nextNode;\n}\n```\n\\\nA related data structure, the doubly linked list, helps this problem somewhat. The difference from a typical linked list is that the root data structure stores a pointer to both the first and last nodes. Each individual node then has a link to both the previous and next node in the list. This creates a more flexible structure that allows travel in both directions. Even still, however, this is rather limited.\n<br/><br/>\n### Queues\nA queue is a data structure that is best described as “first in, first out”. A real world example of a queue is people waiting in line at the bank. As each person enters the bank, he or she is “enqueued” at the back of the line. When a teller becomes available, they are “dequeued” at the front of the line.\n\\\nPerhaps the most common use of a queue within a topcoder problem is to implement a Breadth First Search (BFS). BFS means to first explore all states that can be reached in one step, then all states that can be reached in two steps, etc. A queue assists in implementing this solution because it stores a list of all state spaces that have been visited.\n\\\nA common type of problem might be the shortest path through a maze. Starting with the point of origin, determine all possible locations that can be reached in a single step, and add them to the queue. Then, dequeue a position, and find all locations that can be reached in one more step, and enqueue those new positions. Continue this process until either a path is found, or the queue is empty (in which case there is no path). Whenever a “shortest path” or “least number of moves” is requested, there is a good chance that a BFS, using a queue, will lead to a successful solution.\n\\\nMost standard libraries, such the Java API, and the .NET framework, provide a Queue class that provides these two basic interfaces for adding and removing items from a queue.\n\\\nBFS type problems appear frequently on challenges; on some problems, successful identification of BFS is simple and immediately, other times it is not so obvious.\n\\\nA queue implementation may be as simple as an array, and a pointer to the current position within the array. For instance, if you know that you are trying to get from point A to point B on a 50×50 grid, and have determined that the direction you are facing (or any other details) are not relevant, then you know that there are no more than 2,500 “states” to visit. Thus, your queue is programmed like so:\n<br/>\n```\nclass StateNode {\nint xPos;\nint yPos;\nint moveCount;\n}\n\n\nclass MyQueue {\nStateNode[] queueData = new StateNode[2500];\nint queueFront = 0;\nint queueBack = 0;\n\n\nvoid Enqueue(StateNode node) {\nqueueData[queueBack] = node;\nqueueBack++;\n}\n\n\nStateNode Dequeue() {\nStateNode returnValue = null;\nif (queueBack > queueFront) {\nreturnValue = queueData[queueFront];\nQueueFront++;\n}\nreturn returnValue;\n}\n\n\nboolean isNotEmpty() {\nreturn (queueBack > queueFront);\n}\n}\n```\n\\\nThen, the main code of your solution looks something like this. (Note that if our queue runs out of possible states, and we still haven’t reached our destination, then it must be impossible to get there, hence we return the typical “-1” value.)\n<br/>\n```\nMyQueue queue = new MyQueue();\nqueue.Enqueue(initialState);\nwhile (queue.isNotEmpty()) {\nStateNode curState = queue.Dequeue();\nif (curState == destState)\nreturn curState.moveCount;\nfor (int dir = 0; dir < 3; dir++) {\nif (CanMove(curState, dir))\nqueue.Enqueue(MoveState(curState, dir));\n}\n}\n```\n<br/><br/>\n### Stacks\nStacks are, in a sense, the opposite of queues, in that they are described as “last in, first out”. The classic example is the pile of plates at the local buffet. The workers can continue to add clean plates to the stack indefinitely, but every time, a visitor will remove from the stack the top plate, which is the last one that was added.\n\\\nWhile it may seem that stacks are rarely implemented explicitly, a solid understanding of how they work, and how they are used implicitly, is worthwhile education. Those who have been programming for a while are intimately familiar with the way the stack is used every time a subroutine is called from within a program. Any parameters, and usually any local variables, are allocated out of space on the stack. Then, after the subroutine has finished, the local variables are removed, and the return address is “popped” from the stack, so that program execution can continue where it left off before calling the subroutine.\n\\\nAn understanding of what this implies becomes more important as functions call other functions, which in turn call other functions. Each function call increases the “nesting level” (the depth of function calls, if you will) of the execution, and uses increasingly more space on the stack. Of paramount importance is the case of a recursive function. When a recursive function continually calls itself, stack space is quickly used as the depth of recursion increases. Nearly every seasoned programmer has made the mistake of writing a recursive function that never properly returns, and calls itself until the system throws up an “out of stack space” type of error.\n\\\nNevertheless, all of this talk about the depth of recursion is important, because stacks, even when not used explicitly, are at the heart of a depth first search. A depth first search is typical when traversing through a tree, for instance looking for a particular node in an XML document. The stack is responsible for maintaining, in a sense, a trail of what path was taken to get to the current node, so that the program can “backtrack” (e.g. return from a recursive function call without having found the desired node) and proceed to the next adjacent node.\n\\\n[Soma](http://community.topcoder.com/stat?c=problem_statement&pm=2824&rd=5073) (SRM 198) is an excellent example of a problem solved with this type of approach.\n<br/><br/>\n### Trees\nTrees are a data structure consisting of one or more data nodes. The first node is called the “root”, and each node has zero or more “child nodes”. The maximum number of children of a single node, and the maximum depth of children are limited in some cases by the exact type of data represented by the tree.\n\\\nOne of the most common examples of a tree is an XML document. The top-level document element is the root node, and each tag found within that is a child. Each of those tags may have children, and so on. At each node, the type of tag, and any attributes, constitutes the data for that node. In such a tree, the hierarchy and order of the nodes is well defined, and an important part of the data itself. Another good example of a tree is a written outline. The entire outline itself is a root node containing each of the top-level bullet points, each of which may contain one or more sub-bullets, and so on. The file storage system on most disks is also a tree structure.\n\\\nCorporate structures also lend themselves well to trees. In a classical management hierarchy, a President may have one or more vice presidents, each of whom is in charge of several managers, each of whom presides over several employees.\n\\\n[PermissionTree](http://community.topcoder.com/stat?c=problem_statement&pm=3093&rd=5864) (SRM 218) provides an unusual problem on a common file system.\n\\\n[bloggoDocStructure](http://community.topcoder.com/stat?c=problem_statement&pm=3025&rd=5860) (SRM 214) is another good example of a problem using trees.\n<br/><br/>\n### Binary Trees\nA special type of tree is a binary tree. A binary tree also happens to be one of the most efficient ways to store and read a set of records that can be indexed by a key value in some way. The idea behind a binary tree is that each node has, at most, two children.\n\\\nIn the most typical implementations, the key value of the left node is less than that of its parent, and the key value of the right node is greater than that of its parent. Thus, the data stored in a binary tree is always indexed by a key value. When traversing a binary tree, it is simple to determine which child node to traverse when looking for a given key value.\n\\\nOne might ask why a binary tree is preferable to an array of values that has been sorted. In either case, finding a given key value (by traversing a binary tree, or by performing a binary search on a sorted array) carries a time complexity of O(log n). However, adding a new item to a binary tree is an equally simple operation. In contrast, adding an arbitrary item to a sorted array requires some time-consuming reorganization of the existing data in order to maintain the desired ordering.\n\\\nIf you have ever used a field guide to attempt to identify a leaf that you find in the wild, then this is a good way to understand how data is found in a binary tree. To use a field guide, you start at the beginning, and answer a series of questions like “is the leaf jagged, or smooth?” that have only two possible answers. Based upon your answer, you are directed to another page, which asks another question, and so on. After several questions have sufficiently narrowed down the details, you are presented with the name, and perhaps some further information about your leaf. If one were the editor of such a field guide, newly cataloged species could be added to field guide in much the same manner, by traversing through the questions, and finally at the end, inserting a new question that differentiates the new leaf from any other similar leaves. In the case of a computer, the question asked at each node is simply “are you less than or greater than X?”\n<br/><br/>\n### Priority Queues\nIn a typical breadth first search (BFS) algorithm, a simple queue works great for keeping track of what states have been visited. Since each new state is one more operational step than the current state, adding new locations to the end of the queue is sufficient to insure that the quickest path is found first. However, the assumption here is that each operation from one state to the next is a single step.\n\\\nLet us consider another example where you are driving a car, and wish to get to your destination as quickly as possible. A typical problem statement might say that you can move one block up/down/left/right in one minute. In such a case, a simple queue-based BFS works perfectly, and is guaranteed to provide a correct result.\n\\\nBut what happens if we say that the car can move forward one block in two minute, but requires three minutes to make a turn and then move one block (in a direction different from how the car was originally facing)? Depending on what type of move operation we attempt, a new state is not simply one “step” from the current state, and the “in order” nature of a simple queue is lost.\n\\\nThis is where priority queues come in. Simply put, a priority queue accepts states, and internally stores them in a method such that it can quickly pull out the state that has the least cost. (Since, by the nature of a “shortest time/path” type of problem, we always want to explore the states of least cost first.)\n\\\nA real world example of a priority queue might be waiting to board an airplane. Individuals arriving at their gate earlier will tend to sit closest to the door, so that they can get in line as soon as they are called. However, those individuals with a “gold card”, or who travel first class, will always be called first, regardless of when they actually arrived.\n\\\nOne very simple implementation of a priority queue is just an array that searches (one by one) for the lowest cost state contained within, and appends new elements to the end. Such an implementation has a trivial time-complexity for insertions, but is painfully slow to pull objects out again.\n\\\nA special type of binary tree called a heap is typically used for priority queues. In a heap, the root node is always less than (or greater than, depending on how your value of “priority” is implemented) either of its children. Furthermore, this tree is a “complete tree” from the left. A very simple definition of a complete tree is one where no branch is n + 1 levels deep until all other branches are n levels deep. Furthermore, it is always the leftmost node(s) that are filled first.\n\\\nTo extract a value from a heap, the root node (with the lowest cost or highest priority) is pulled. The deepest, rightmost leaf then becomes the new root node. If the new root node is larger than at at least one of its children, then the root is swapped with its smallest child, in order to maintain the property that the root is always less than its children. This continues downward as far as necessary. Adding a value to the heap is the reverse. The new value is added as the next leaf, and swapped upward as many times as necessary to maintain the heap property.\n\\\nA convenient property of trees that are complete from the left is that they can be stored very efficiently in a flat array. In general, element 0 of the array is the root, and elements 2k + 1 and 2k + 2 are the children of element k. The effect here is that adding the next leaf simply means appending to the array.\n<br/><br/>\n### Hash Tables\nHash tables are a unique data structure, and are typically used to implement a “dictionary” interface, whereby a set of keys each has an associated value. The key is used as an index to locate the associated values. This is not unlike a classical dictionary, where someone can find a definition (value) of a given word (key).\n\\\nUnfortunately, not every type of data is quite as easy to sort as a simple dictionary word, and this is where the “hash” comes into play. Hashing is the process of generating a key value (in this case, typically a 32 or 64 bit integer) from a piece of data. This hash value then becomes a basis for organizing and sorting the data. The hash value might be the first n bits of data, the last n bits of data, a modulus of the value, or in some cases, a more complicated function. Using the hash value, different “hash buckets” can be set up to store data. If the hash values are distributed evenly (which is the case for an ideal hash algorithm), then the buckets will tend to fill up evenly, and in many cases, most buckets will have no more than one or only a few objects in them. This makes the search even faster.\n\\\nA hash bucket containing more than one value is known as a “collision”. The exact nature of collision handling is implementation specific, and is crucial to the performance of the hash table. One of the simplest methods is to implement a structure like a linked list at the hash bucket level, so that elements with the same hash value can be chained together at the proper location. Other, more complicated schemes may involve utilizing adjacent, unused locations in the table, or re-hashing the hash value to obtain a new value. As always, there are good and bad performance considerations (regarding time, size, and complexity) with any approach.\n\\\nAnother good example of a hash table is the Dewey decimal system, used in many libraries. Every book is assigned a number, based upon its subject matterï¿½ the 500′s are all science books, the 700′s are all the arts, etc. Much like a real hash table, the speed at which a person could find a given book is based upon how well the hash buckets are evenly dividedï¿½ It will take longer to find a book about frogs in a library with many science materials than in a library consisting mostly of classical literature.\n\\\nIn applications development, hash tables are a convenient place to store reference data, like state abbreviations that link to full state names. In problem solving, hash tables are useful for implementing a divide-and-conquer approach to knapsack-type problems. In LongPipes, we are asked to find the minimum number of pipes needed to construct a single pipe of a given length, and we have up to 38 pieces of pipe. By dividing this into two sets of 19, and calculating all possible lengths from each set, we create hash tables linking the length of the pipe to the fewest number of segments used. Then, for each constructed pipe in one set, we can easily look up, whether or not we constructed a pipe of corresponding length in the other set, such that the two join to form a complete pipe of the desired length.\n<br/><br/>\n### Conclusion\nThe larger picture to be seen from all of this is that data structures are just another set of tools that should be in the kit of a seasoned programmer. Comprehensive libraries and frameworks available with most languages nowadays preempt the need for a full understanding of how to implement each of these tools. The result is that developers are able to quickly produce quality solutions that take advantage of powerful ideas. The challenge lies in knowing which one to select.\n\\\nNonetheless, knowing a little about how these tools work should help to make the choices easier. And, when the need arises, perhaps leave the programmer better equipped to think up a new solution to a new problemï¿½ if not while on the job doing work for a client, then perhaps while contemplating the 1000 point problem 45 minutes into the coding phase of the next SRM.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"5rg0EyMG9aQUeBU99KbVPd"}}],"upvotes":34,"downvotes":3,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"28xML395bHNDwAhdOKvY9R"}},{"sys":{"type":"Link","linkType":"Entry","id":"3RUcXHuc3tXWkmdesAkmr7"}},{"sys":{"type":"Link","linkType":"Entry","id":"6qQ5n5nHfLRZ0DyCdK5Zfg"}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6LQfbpjC6eQK3yXQpKUVMr"}},{"sys":{"type":"Link","linkType":"Entry","id":"3YPeWSMpzjxNxU8zacGgjg"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5W8yVIchiseIGTWrWKXN57","type":"Entry","createdAt":"2019-09-18T07:36:54.570Z","updatedAt":"2023-09-06T19:01:10.075Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Design"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5WDqV2dANBrT2sl8nK0BDZ","type":"Entry","createdAt":"2022-01-12T16:39:15.593Z","updatedAt":"2022-01-12T16:39:15.593Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":" Riya Kumari","tcHandle":"fornaxxx"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5XNV8gKk9DbppF4W0TPY76","type":"Entry","createdAt":"2019-08-27T06:08:26.689Z","updatedAt":"2021-09-02T10:58:56.367Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Front-End Development","trackParent":"Development"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5XYGp5aRhJPMMVq6V2yiVg","type":"Entry","createdAt":"2019-09-18T07:38:15.252Z","updatedAt":"2019-10-15T16:40:39.130Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dmitri Kamenetsky","tcHandle":"dimkadimon"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5YddmJoyCue4bAErVt8M75","type":"Entry","createdAt":"2023-07-10T19:23:18.193Z","updatedAt":"2023-08-28T07:34:36.537Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":61,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Quality Assurance vs. Quality Control: A Guide to the Differences","slug":"quality-assurance-vs-quality-control-a-guide-to-the-differences","type":"Article","trackCategory":["QA"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"18iyI2bjOA7TozUFV8DFoB"}}],"tags":["Quality assurance","quality control","differences","benefits","implementation","high-quality product"],"creationDate":"2023-07-10","readTime":"10 min","content":"**Level up your game and leave no room for errors!**\n\nQuality refers to the degree a product meets or exceeds the expectations, requirements, and standards set by customers or stakeholders. A high-quality product is free from defects, satisfies user needs, and delivers a positive and satisfying user experience.\n\nWhen it comes to delivering top-notch products and services, understanding the dynamic duo of quality assurance (QA) and quality control (QC) is your ticket to success. Have a look at a brief breakdown of QA and QC.\n\n> QA and QC: A Partnership for Quality\n\n**Quality Assurance (QA):** The guardian angel of flawlessness, it swoops in to prevent defects from even thinking about spoiling your masterpiece. It accomplishes this by establishing and implementing processes that proactively prevent defects, including risk assessments, developing and implementing quality standards, employee training on quality procedures, and conducting audits.\n\n**Quality Control (QC):** The fearless warrior that hunts down and eradicates those quality issues that dare to slip through the cracks. QC is achievable through testing products, inspection of processes, and implementation of corrective actions as needed.\n\nGet ready to unlock the secrets of QA and QC and unleash the power of uncompromising quality. It's time to take control and assurance to a whole new level!\n\nWithin this article, we will explore the distinctions between QA and QC, delve into their implementation within your organization, and uncover the advantages that each brings.\n\n### **What is Quality Assurance?**\n\nIt is a proactive approach to ensuring quality. It aims to prevent defects from occurring in the first place. It focuses on identifying flaws in the development process, such as inefficient practices, inadequate documentation, or insufficient training.\n\nQA activities include planning project implementation, documenting processes, training staff, creating schedules, inspecting checklists, and conducting audits.\n\nThe primary goal of QA is to identify and address flaws in the software development process, aiming for a **\"Zero Defect Approach.\"**\n\n### **What is Quality Control?**\n\nIt is a reactive approach to ensuring quality. QC focuses on the identification and correction of defects that have already arisen.\n\nThe activities typically occur during the testing phase involve inspections, testing, debugging, and Validation.\n\nThe primary goal of QC is to detect defects in the final software product and address them before release, ensuring that the product meets the specified requirements and the product quality is high.\n\n### **The Relationship between QA and QC**\n\n|Features|QA|QC|\n|:----|:----|:----|\n|__Focus__|Preventing defects from occurring|Identifying and correcting defects  |\n|__Timing__|Pre-production|Post-production  |\n|__Responsibility__|The whole team is involved during the SDLC  |The testing team is involved in the STLC|\n|__Approach__|Proactive and process-oriented  |Reactive and product-oriented  |\n|__Activities__|Process checklists, standards, documentation, and project audits|Deliverable peer reviews, inspection, and the process of software testing|\n|__Outcome__|Verification - you are doing the right thing in the right manner|Validation - the product against the requirements|\n\nQA and QC are two important aspects of software development. QA focuses on preventing the problem from occurring. Whereas QC mainly focuses on finding and fixing errors after they have occurred. QA and QC are complementary; working together can help ensure high-quality software products.\n\nQA activities are typically carried out during the pre-production stage of the software development lifecycle (SDLC). In contrast, QC activities are often carried out by the testing team in the post-production stage of the software testing life cycle (STLC).\n\n### **How to Implement QA and QC**\n\n#### Quality Assurance (QA)\n\nThe goal of QA is to ensure that software products meet customer expectations. QA is achievable by following several steps, including:\n\n1. **Identify and mitigate potential problems:** Conduct a thorough analysis of potential risks and challenges that could affect the quality of the software product. Thus, develop strategies and action plans that could resolve these risks.\n\n2. **Define and implement quality standards:** Establish clear quality standards and guidelines that outline the desired level of quality for the software product. These standards should cover various aspects such as functionality, performance, security, and user experience.\n\n3. **Train employees on quality procedures:** Provide training and education to employees involved in the software development process. Ensure they understand and follow the established quality procedures, including best practices, coding standards, and testing methodologies.\n\n4. **Conduct regular audits:** Perform regular audits to assess compliance with quality standards and procedures. This entails reviewing the documentation, processes, and artifacts to identify areas needed for improvement and ensure the standards are being followed.\n\n5. **Promote a culture of quality:** Foster a quality culture within the organization by promoting collaboration, communication, and accountability. Encourage continuous improvement and empower team members to take collective ownership of the quality of their work.\n\n> Suppose you are developing a web application. You conduct a risk assessment and identify potential security vulnerabilities as part of QA. You then implement secure coding practices, perform regular security audits, and train the development team on secure coding techniques. Additionally, you establish quality standards for performance and user experience, ensuring the application meets specified requirements.\n\n#### Quality Control (QC)\n\nQC aims to identify and correct defects that have already occurred in the software product. QC is achievable by following several steps, including:\n\n1. **Testing the product:** Develop and execute a comprehensive testing strategy that includes functional testing, performance testing, security testing, and other relevant types of testing. Use appropriate tools and techniques to identify defects and ensure the software meets specified requirements.\n\n2. **Inspect the production process:** Perform inspections and reviews of the software development process to identify potential problems or deviations from established quality standards. It can involve code reviews, design reviews, and documentation reviews.\n\n3. **Take corrective action:** When defects are identified, take immediate disciplinary action to address them. It may involve debugging, fixing code, retesting, and ensuring the necessary modifications are made to meet the desired quality standards.\n\n4. **Monitor and measure quality metrics:** Establish and track quality metrics to measure the effectiveness of the QC process. This includes defect density, test coverage, and customer satisfaction metrics. Use these metrics to identify trends, make data-driven decisions, and drive continuous improvement.\n\n> During the QC phase, you conduct various types of testing, such as functional testing to check that all features operate as intended and performance testing to ensure the application functions appropriately under expected loads. You also examine the development process to look for deviations from the defined standards for quality. If any flaws are discovered, you immediately take corrective action to fix them and ensure the finished product is of the desired level of quality.\n\n### **The KEY Benefits of QA and QC**\n\n#### Benefits of QA :\n\n1. **Early bug identification and fixing:** QA helps identify and fix bugs at the beginning of the software development lifecycle (SDLC). It can save time and money, preventing the need to fix bugs later in the development process when they can be more difficult and expensive.\n\n2. **Reduced costs:** QA can help to reduce the overall cost of software development by preventing defects from occurring in the first place. It can be done by identifying and mitigating potential problems, developing and implementing quality standards, training employees on quality procedures, and conducting audits.\n\n3. **Compliance with regulations:** QA may assist organizations in complying with rules, laws, and industry standards. It can help the organization avoid costly fines and penalties while enhancing its reputation.\n\n4. **Improved process controls:** QA can help to improve the development process by identifying areas for optimization, efficiency gains, and quality enhancements. This can lead to shorter development cycles, higher-quality products, and increased customer satisfaction.\n\n5. **Easier and smoother QC:** By identifying and fixing bugs early in the SDLC, QA can make the work of the QC team easier and smoother. This is because the QC team will have fewer bugs to fix, and they will be able to focus on more high-level quality assurance activities.\n\n#### Benefits of QC :\n\n1. **Defect detection and correction:** QC focuses on identifying defects in the software product through testing, inspections, and reviews. It enables organizations to catch and address issues before the product is delivered to customers, improving overall product quality.\n\n2. **Continuous improvement:** QC activities provide valuable feedback and insights into the development process. By analyzing defects and gathering metrics, organizations can identify areas for improvement, refine development practices, and enhance future product iterations.\n\n3. **Improved customer satisfaction:** Defect-free software products significantly enhance customer satisfaction. When customers receive software that functions flawlessly, meets their requirements, and is free from bugs and errors, they are more likely to be satisfied with their purchase. Positive user experiences lead to greater customer loyalty and positive word-of-mouth recommendations.\n\n### Wrap Up\n\nThe article gave you a clear understanding of quality assurance and control concepts. Understanding distinctions between quality assurance and control will enable you to address the client's specific requirements and deliver high-quality software products that meet their expectations. Embracing quality assurance and quality control practices will help you establish a robust quality management framework and contribute to project success.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"239h0OBv0NnoVKO2FqTyQt","type":"Asset","createdAt":"2023-07-10T18:40:42.469Z","updatedAt":"2023-07-10T18:40:42.469Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"turned on black and grey laptop computer","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/239h0OBv0NnoVKO2FqTyQt/6783896940660baa8e235ecf68fd6d5f/photo-1504868584819-f8e8b4b6d7e3.avif","details":{"size":55904,"image":{"width":1476,"height":978}},"fileName":"photo-1504868584819-f8e8b4b6d7e3.avif","contentType":"image/avif"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6kIxt3XnHszjSpDpmJ0bqK","type":"Entry","createdAt":"2022-08-19T09:20:43.142Z","updatedAt":"2022-08-19T09:20:43.142Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Maryam Siddiqui","tcHandle":"maryamsidd"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"75xG9R2pApVSPLlIHk5y06"}},{"sys":{"type":"Link","linkType":"Entry","id":"36aTd2yYZO0xU30JtvkU5Q"}},{"sys":{"type":"Link","linkType":"Entry","id":"3Zq3Rp3z6PJd9vnUfPRl4f"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5pjpijWpkZDtQEvBNKJN9a","type":"Entry","createdAt":"2021-01-07T07:49:04.332Z","updatedAt":"2021-10-07T13:10:26.845Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Shivam Singh","tcHandle":"shivam51","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5qUC92WWB9Cr7ufhEZaaSB","type":"Entry","createdAt":"2023-07-10T17:20:53.883Z","updatedAt":"2023-07-10T19:29:39.960Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":155,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Information Architecture vs UX Design: What's the Difference? ","slug":"information-architecture-vs-ux-design-whats-the-difference","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}}],"tags":["UX","Information Architecture"],"creationDate":"2023-07-10","readTime":"10 min","content":"In the world of digital design, two pillars stand tall, shaping our interactions with websites, apps, and digital products: Information Architecture (IA) and User Experience Design (UX Design). Like two skilled architects, they work diligently to create seamless and captivating digital landscapes. In this piece, we'll find out what sets them apart and how they complement each other.\n\n## Information Architecture In A Nutshell\n\nInformation Architecture, the mastermind behind seamless digital journeys, is all about organizing information in a captivating, logical, and user-friendly way. It's the secret sauce that ensures users find what they're looking for and understand it effortlessly.\n\n### The Key Elements Of Information Architecture\n\nThese elements are the secret that enables IA to transform design chaos into clarity and make the digital world a user's playground. They include the following;\n\n__1\\. Organization and Structure:__ IA focuses on arranging information logically and coherently. It involves determining hierarchies, categorizing content, and establishing relationships between different pieces of information.\n\n__2\\. Navigation Systems:__ IA designs intuitive navigation systems that help users easily move through the digital product. This includes creating menus, navigation bars, search functionalities, and other elements that aid in exploration and discovery.\n\n__3\\. Taxonomy and Labelling:__ IA employs effective labeling and categorization systems to make information findable and understandable. This involves creating consistent and meaningful labels, defining categories, and developing taxonomies that reflect user mental models.\n\n__4\\. Search Functionality:__ IA considers the implementation of robust search features to enable users to quickly locate specific information within a digital product. This includes designing search interfaces, integrating search algorithms, and optimizing search results.\n\n__5\\. Content Hierarchy:__ IA establishes a clear hierarchy of content, ensuring that important information receives prominence while maintaining a logical flow of information. This hierarchy helps users prioritize their attention and understand the relative importance of different elements.\n\n### The Key Processes And Methods In Information Architecture\n\nBy following the IA processes and methods listed below, information architects can create a well-structured and user-centered information architecture that enhances usability, and overall user experience within a digital product.\n\n__1\\. Research:__ IA begins with thorough research. This involves understanding user needs, business goals, and studying existing content. User research methods like interviews, surveys, and observation help gain insights into user behaviors, preferences, and mental models. Competitor analysis helps identify best practices and learn from existing solutions.\n\n__2\\. Information Organisation:__ Once the research phase is complete, IA professionals delve into organizing the information. They create content hierarchies by determining the relationships and priorities between different content elements. This involves categorizing information, establishing logical structures, and defining taxonomies. The goal is to ensure that users can easily navigate and comprehend the content.\n\n__3\\. Wireframing and Prototyping:__ IA practitioners employ wireframes and prototypes to visually represent the information architecture. Wireframes are skeletal layouts that depict the structure and placement of content elements. Prototypes are interactive representations that allow users to navigate and interact with the proposed IA. These visual representations help validate the effectiveness of the IA design, identify potential issues, and iterate on the structure as needed.\n\n__4\\. Card Sorting:__ Card sorting is a technique used in IA to involve users in the process of organizing information. It involves providing users with physical or virtual cards representing different content elements and asking them to group and categorize them based on their understanding. This exercise helps IA professionals understand users' mental models, preferences, and expectations, guiding the creation of an IA that aligns with user needs.\n\n__5\\. User Flows:__ User flows visually map out the paths and steps that users take to accomplish specific tasks within a digital product. They illustrate the sequence of interactions and decisions a user makes, helping IA professionals identify potential bottlenecks or gaps in the user journey. User flows enable them to optimize the IA by streamlining the navigation and ensuring a seamless user experience.\n![image5-userflows](//images.ctfassets.net/piwi0eufbb2g/3M8xwDjFNyeBKxa94qk6B/206ba558e4ee9da7e27ae35d08445214/image5.jpg)\n*Image is taken from Unsplash.com*\n\n__6\\. Site Maps:__ Site maps are visual representations of the overall structure and hierarchy of a website or app. They provide an overview of the content organization, showcasing the relationships between different pages or sections. Sitemaps aid in understanding the scope of the IA, identifying content gaps or redundancies, and facilitating collaboration between IA professionals and other stakeholders.\n\nTo put IA in perspective, let's take a look at how [Adidas](https://www.adidas.com/us) has made shopping easy on its website.\n\n1.  Clever navigation structure - As large as its catalog, the homepage is divided into several sections, each of which contains information about a different product category or topic. We can see that users will not experience a hard time finding the products of choice.\n![adidas-nav](//images.ctfassets.net/piwi0eufbb2g/4i9LA92vwbGcwXFCfUSyAq/be44229f114e1a793f201dbd8fc62610/adidas-nav.png)\n*[Adidas](https://www.adidas.com/us)' homepage navigation*\n\\.\n\n1.  Search bar - The Adidas website also has a search bar that allows users to search for specific products or information. The search bar is located in the top right corner of the website, and it is easy to find and use.\n![adidas-search](//images.ctfassets.net/piwi0eufbb2g/72hZaXhbuMdA1Yha0mhmkX/d25320f3591e56881daba7722c0fbfd2/adidas-search.png)\n*The search bar on the [Adidas](https://www.adidas.com/us) homepage*\n\nThe Adidas search bar also comes loaded with popup suggestions per category. It makes it easy to find products as it filters the search result according to input.\n![adidas-advanced-search](//images.ctfassets.net/piwi0eufbb2g/2mLuP5HnWjNfSN7U566qI9/4bc132d2f80b9fe5737001def43eb498/adidas-advanced-search.png)\n*[Adidas](https://www.adidas.com/us) advanced search*\n\n### What Tools Do Information Architects Use?\n\nInformation Architects (IAs) use various tools to support their work and streamline the process of designing and implementing effective information architectures. Some of the commonly used tools by IAs are;\n\n__1\\. Diagramming and Wireframing Tools:__ Tools such as Adobe XD, Sketch, Axure RP, FigJam, and Balsamiq allow IAs to create wireframes and visual representations of the information architecture. They help in organizing content, designing navigation systems, and showcasing the structure and layout of digital products.\n\n__2\\. Prototyping Tools:__ Prototyping tools like InVision, Figma, Proto.io, Adobe XD, and Marvel enable IAs to create interactive prototypes that simulate user interactions and flows. These prototypes help test and validate the information architecture, gather user feedback, and refine the design.\n\n__3\\. Card Sorting Tools:__ Online card sorting tools like OptimalSort, Treejack, and UserZoom facilitate remote and online card sorting exercises. These tools enable IAs to collaborate with users, collect data on how users categorize and group information, and gain insights into user mental models.\n\n__4\\. Collaborative Design and Documentation Tools:__ Tools like Miro, Mural, and Google Workspace (formerly G Suite) provide collaborative spaces for IAs to work with cross-functional teams. These tools allow for real-time collaboration, brainstorming, and documentation of the information architecture process.\n\n__5\\. Diagramming and Visualization Tools:__ Tools like Microsoft Visio, Lucidchart, and draw.io assist IAs in creating flowcharts, site maps, and visual representations of the information architecture. These tools help in communicating and presenting the IA design to stakeholders and development teams.\n\n## Understanding UX Design\n\nUX Design is the art of understanding users' desires, dreams, and frustrations and translating them into unforgettable digital encounters. Its purpose? To create digital masterpieces that leave users in awe.\n\n### The Key Elements of UX Design\n\nThese are often referred to as the Five Planes of UX. They work together harmoniously to create a remarkable user experience. They include;\n\n__1\\. Strategy:__ The strategy sets the course for our journey, guiding us toward creating an exceptional user experience. It involves understanding business goals, and target audience, and defining the overall vision for the product. The strategy lays the foundation for our design decisions, ensuring that we're headed in the right direction.\n\n__2\\. Scope:__ Think of scope as setting the boundaries for our design expedition. It helps us determine what features and functionalities will be included in the product. We carefully consider the needs and expectations of our users, balancing them with practical constraints like time, resources, and technical limitations. Defining the scope ensures that we focus on creating a valuable and achievable user experience.\n\n__3\\. Structure:__  This is the sturdy backbone of our design. It's about organizing and arranging information in a logical and user-friendly manner. We create a clear and intuitive navigation system, making it a breeze for users to explore and find what they need. By structuring the content and interactions, we ensure that users can easily navigate through the product, saving them from any frustrating detours.\n\n__4\\. Skeleton:__ This serves as the essential framework of our design, setting the stage for the key elements and interactions. Within this foundation, we determine the arrangement and positioning of buttons and menus, as well as establish the flow of interactions. This framework allows us to visualize the overall structure of the product and anticipate how users will engage with it.\n\n__5\\. Surface:__ This is where we add delightful visual touches to our design. We apply color, typography, imagery, and other visual elements to create an engaging and visually pleasing experience. The surface gives our design its personality, reflecting the brand identity and evoking emotions in our users.\n\n### UX Design Processes And Methods\n\nThese are integral to creating successful and user-centered digital experiences. Let's explore some of the key UX Design processes and methods.\n\n__1\\. Research and Analysis:__ UX Design begins with thorough research and discovery to gain insights into user needs, behaviors, and preferences. This involves conducting user interviews, surveys, and usability testing, as well as analyzing market trends and competitor analysis. The goal is to understand the target audience and their goals to inform the design process.\n\n__2\\. User Persona Development:__ User personas serve as fictional representations of various user types derived from thorough research. UX designers employ personas to add a human touch to the target audience and gain insights into their motivations, needs, and challenges. These personas play a pivotal role in steering design choices, ensuring that the product is customized to cater to specific user groups.\n\n__3\\. User Journey Mapping:__ User journey mapping involves visualizing the end-to-end experience of users as they interact with a product or service. It identifies touchpoints, emotions, and pain points throughout the user's journey. User journey maps provide a holistic view of the user's experience, helping UX designers identify opportunities for improvement and create seamless interactions.\n\n__4\\. Information Architecture:__ Information Architecture (IA) is a critical component of UX Design. It involves organizing and structuring the content and information within a product logically and intuitively. IA ensures that users can easily navigate and find the information they need, enhancing the overall user experience. A part of the deliverables for IA is wireframes and prototypes.\n![image7](//images.ctfassets.net/piwi0eufbb2g/6rBQIieP7vJoKdNJilcmGt/0175df252703f563ba03547d0fc2b609/image7.jpg)\n*Image is taken from Unsplash.com*\n\nWireframing is the process of creating low-fidelity visual representations of the user interface. It focuses on the layout and structure of the design without getting into visual details. Prototyping, on the other hand, involves creating interactive and more high-fidelity representations of the design. Wireframes and prototypes allow designers to test and iterate on the design before development, ensuring usability and user satisfaction.\n\n__5\\. Usability Testing:__ Usability testing involves observing and gathering feedback from users as they interact with a prototype or a live product. This method helps identify usability issues, pain points, and areas for improvement. UX designers conduct usability tests to validate design decisions, make data-driven improvements, and enhance the user experience.\n\n__6\\. Iterative Design:__ UX Design follows an iterative approach, constantly refining and enhancing the design based on user feedback and data. This ongoing improvement process ensures that the design evolves and aligns with user expectations.\n\nLet's take a look at some of [Apple's](https://www.apple.com/) website features that make it a great UX site.\n\n1\\.  The use of white space - Whitespace is the space between elements on a webpage. It is often used to create a sense of space and organization. On Apple's website, whitespace is used effectively to make the website easy to scan and to focus attention on the most important content. This reduces distraction for users, hence a good UX.\n\nWhile this feature almost goes unnoticed, it goes a long way in creating a positive, long-lasting impression for users.\n![apple-whitespace](//images.ctfassets.net/piwi0eufbb2g/1zlbTkCUh7JHyLLuxwfciq/53eab8558e4959fbafffac43f3871a90/apple-whitespace.png)\n*[Apple'](http://apple.com)s watch series page shows the use of whitespace*\n\n2\\.  Use of cool animations - Another important feature of Apple's website design is the use of animated images. We can see in the screenshot below how Apple cleverly showcases its products using subtle yet effective techniques to capture attention. Likewise, users can interact with the animation by clicking on different parts of the screen. This allows users to explore the product in more detail, and it helps them to learn more about its features. This helps to create a positive emotion with the product.\n![apple-interaction](//images.ctfassets.net/piwi0eufbb2g/38yzGAUiFtRomQPnEiXKGr/4eede04660bce7b65a322f05a2a788f8/apple-interaction.gif)\n*[Apple's](http://apple.com) homepage with animated images.*\n\n### Tools Employed By UX Designers\n\nUX designers utilize a variety of tools to aid them in the design process and create exceptional user experiences. Listed are some commonly employed tools by UX designers:\n\n__1\\. Design and Prototyping Tools:__ Tools like Sketch, Adobe XD, Figma, and InVision enable UX designers to create high-fidelity mockups, wireframes, and interactive prototypes. They offer features for designing user interfaces, creating animations, and simulating user interactions, allowing designers to visualize and test their design concepts before implementation.\n\n__2\\. User Research Tools:__ User research tools help UX designers gather valuable insights into user behavior and preferences. Tools such as UserTesting, Optimal Workshop, and UserZoom enable designers to conduct remote usability testing, surveys, card sorting, and other research methods. These tools provide feedback, analytics, and user behavior data that inform design decisions.\n\n__3\\. Collaboration and Communication Tools:__ Collaboration and communication tools facilitate teamwork and streamline communication among UX designers, stakeholders, and developers. Tools like Slack, Microsoft Teams, and Asana enable designers to collaborate on projects, share design files, provide feedback, and manage tasks efficiently. These tools promote effective collaboration and project coordination.\n\n__4\\. Accessibility Testing Tools__: Accessibility testing tools help UX designers ensure that their designs are inclusive and accessible to users with disabilities. Tools like WebAIM, WAVE, and AChecker evaluate web accessibility compliance, identify accessibility issues, and provide recommendations for improvement. These tools assist designers in creating products that adhere to accessibility standards and guidelines.\n\n__5\\. Usability Testing Tools:__ Usability testing tools aid UX designers in evaluating the usability and effectiveness of their designs. Tools like Maze, UserZoom, and Lookback facilitate remote user testing, screen recording, and user feedback collection. These tools help designers observe user interactions, gather qualitative and quantitative data, and refine the design based on user insights.\n\n## Information Architecture vs UX Design: What's the Difference\n\nIt's important to note that  IA can exist separately from UX, however, UX cannot exist without IA. Let's take a look at an overview of the overlapping and complementing areas of Information Architecture and UX Design.\n\n|Factor|Information Architecture (IA)|UX Design|\n|:----|:----|:----|\n|__Focus__|Content structuring and organization for easy finding|Emotions and psychology of the users. Overall user satisfaction and usability|\n|__Key Elements__|Content hierarchy, navigation systems, taxonomy, search functionality|User research, interaction design, visual design, usability testing|\n|__Objectives__|Optimize information findability and comprehension|Create enjoyable and intuitive user experiences|\n|__Key Activities__|Organizing content, creating taxonomies, designing navigation systems|User research, wireframing, prototyping, usability testing|\n|__Deliverables__|Site maps, content hierarchies, labeling systems, metadata, wireframes, prototypes|User personas, experience maps, empathy maps, journey maps|\n|__Scope__|Primarily focuses on information structure and organization|Holistic approach encompassing aesthetics, interactions, and usability|\n|__Timeframe__|Often established in the early stages of the design process|Spanning the entire design process, from research to implementation|\n|__Overlapping Areas__|UX Design incorporates IA principles to create a seamless user experience|IA benefits from UX Design's insights on user needs and interactions|\n\n## Final Thoughts\n\nInformation Architecture (IA) and User Experience Design (UX Design) are two essential disciplines that work hand in hand to create exceptional digital experiences. While IA focuses on organizing and structuring information to optimize findability and comprehension, UX Design takes a broader approach, considering overall user satisfaction and usability.\n\nSo, the next time you're navigating a well-organized website or enjoying a user-friendly app, remember that Information Architecture and UX Design have worked hand in hand to create that delightful experience.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4MvV4MKBVxBwYrrrE2PNlw","type":"Asset","createdAt":"2023-07-10T11:03:28.308Z","updatedAt":"2023-07-10T11:03:28.308Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"ux-versus-ia","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4MvV4MKBVxBwYrrrE2PNlw/f74026d7fd00b73102cdabee82b8bab3/ux-process.png","details":{"size":293363,"image":{"width":445,"height":355}},"fileName":"ux-process.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"4rUnTz3X10yfndHMECQ6kG"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"QUWD2QS7RiuC12nzWW4Ai","type":"Entry","createdAt":"2022-10-07T10:12:11.131Z","updatedAt":"2022-10-07T10:12:11.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"UX Design","slug":"ux-design","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}},{"sys":{"type":"Link","linkType":"Entry","id":"6kbzSOMPOI8eWQV2cJzrHR"}}],"tags":["UX"],"creationDate":"2022-10-06","readTime":"7min","content":"UX design is an essential part of the design or redesign of any product. However, more often than not, UX design principles are confused with the design process. It should be noted that the UX design and the design process are similar but different. UX design is the standard principle for a product design, while the design process is the step-by-step guide a designer takes in designing a product. The design process typically varies based on the designer and the effect the designer is trying to create or redesign. \n\nTherefore, here we will be looking at carrying out a UX design while you design an app based on the principles learned and adequately document your design process. Note that the UX design should be based on the needs of the user and the stakeholder. Simply put, your UX design must solve the users' needs and meet business goals.\n\nAccording to the Stanford school of design the UX design comprises:\n- Product definition\n- Research\n- Analysis\n- Design\n- Validation\n\n### Product definition\nThis is the first phase in the user design process. This is where the design team understands the problem they are trying to solve and the context in which the product is being formed. This is where the \"whys” of the design are discussed. This is where the designer will collect the user needs based on business goals. Any mistakes in understanding the scope will lead to a product in the market that is not required. At this stage, the designer has stakeholder meetings in which he meets with the business manager, the product manager, and the lead developer. It is here we determine what our product is all about, who will use our product, and why they will be using our product. The entire team will have to consult with customers in their environment and analyze what they want within the framework of your operation. At this stage, critical KPIs are set, and success metrics are determined.\n\n### Research\nAfter you have adequately defined those, we move further into carrying out our research. This is very important because it helps save us time, money, and effort early in our design process. We identify pain points, needs, wants, and desires, and knowing our user's wants we can design a solution that will solve their problem. Research also involves competitive analysis where we check out what is already in mind and what we can add or remove that would give us an edge in the market. This aids us in entering the market faster.\nWe also look into the latest trends in UI design and design guidelines during the research process.\n\n### Analysis\nThis is where we combine and analyze the information gathered during research to get what we need from the data. We produce storyboards, user stories, personas, and experience maps, among other things. At this point, the designer shifts their focus from what to why a user needs or wants something. The designer has an initial guess about what the user might need, but they are not sure at this point in the user experience design process.\n\nAfter conducting enough studies and assessing the data obtained from research, we confirm our assumptions at this point.\n- __Fictional Personas:__ Developing fictional scenarios enables the designer to understand the many customers of your product better. It allows a realistic portrayal of the finished product. The design team can determine how it will seem following delivery.\n- __Experience Maps:__ These diagrams depict how users move through your finished product. This is accomplished through visual representation and suitable interactions with the customer.\n- __User story:__ A user story is a tool designers can use to better comprehend how users engage with a product or service. As a [user], I want to [objective to attain] so that [motive], which is the typical definition.\n- __Storyboarding:__ Designers can connect user personas and user stories with the storyboarding method. It's a story about a user interacting with your product, as the name suggests.\n\n### Design\nWhen product designers have a strong understanding of what customers want, need, and expect from a product, they move on to the design phase. Product teams work on various projects at this stage, from creating an Information Architecture (IA) to UI design in practice. A successful design phase is highly collaborative (every team member involved in product design must actively participate in this phase), iterative, and combined (meaning it cycles back upon itself to validate ideas).\n\nTypically, the design phase entails:\n- __Sketching:__ The quickest and most straightforward approach to visualize our ideas is through sketches. This can be accomplished by hand-drawing on paper, on a whiteboard, or with a computer tool. It may let the team see a wide range of design possibilities before determining which one to use, which makes it particularly helpful during brainstorming sessions.\n- __Wireframing:__ A wireframe is a tool designers may use to see the essential components of a future page and how they will work together. Wireframing is the product's backbone, and designers frequently utilize it as a foundation for mockups and prototypes.\n- __Prototyping:__ While wireframes are primarily concerned with structure and visual hierarchy (the look), prototypes are concerned with the actual interaction experience (the look and feel). A prototype resembles a simulation of the finished product and ranges from low-fidelity (clickable wireframes) to high-fidelity (coded prototypes) depending on the specific screens.\n- __Design specifications:__ They include user flow and task flow diagrams. It shows how the UI/UX product will generally function and its stylistic needs. It explains the procedures and visual components needed to produce fantastic user experiences.\n- __The development of design systems:__ Designers frequently construct a system of components, patterns, and styles for significant projects to enable designers and developers to stay on the same page with the design.\n\n### Validation or Testing\nTesting is the stage that establishes the final product's overall quality. When something has to be fixed, the testers make notes and submit them back to the appropriate team so they can fix the mistakes. Although some businesses conduct internal tests, doing so is not recommended because it is likely that these individuals have a basic understanding of how these apps operate and are prejudiced in favor of the product. \n\nThe validation process typically begins after the high-fidelity design is completed because testing with high-fidelity methods yields more insightful feedback from end-users. It is, however, also advisable to carry out tests also on your low-fi design; this helps in knowing that your user can carry out given actions with the barest minimum. During several user testing sessions, the team validates the product with stakeholders and end-users. \n\nThe following activities may be included in the validation phase of the UX process: \n- __Testing sessions:__ User testing sessions with participants who correspond to your target market are crucial. There are numerous forms to experiment with, such as moderated/unmoderated usability testing, focus groups, beta testing, and A/B testing.\n- __Surveys:__ Surveys are a fantastic tool for gathering quantitative and qualitative data from actual people. Open-ended questions, such as \"What portion of the product do you dislike?\" might be added by UX designers to elicit user feedback on specific features. \n- __Analytics:__ Quantitative data (clicks, navigation time, search queries, and so on) from an analytics tool can be helpful in determining how users engage with your product.\n\nThere are a few things to consider while assessing your finished project. Some are:\n- Is the system simple to use? \n- Is it adaptable and straightforward to use? \n- Does it resolve the client's problem? \n- Does it have credibility and entice customers to return when they require your service?\n\nIt should be noted that the UX design process is an iterative process where the designer performs back and forth movement based on findings from user testing sessions and meetings with stakeholders and our developers. \n\n### Conclusion\nOne must adopt a systematic approach to create excellent UX/UI interfaces. To do this, we need a UI/UX design process technique. The entire design team will participate in the process. In this increasingly competitive world, this is one of the most acceptable methods to maintain present clients and attract new ones.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"KLiU6Wijp0SYkFb5R8l8O"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}},{"sys":{"type":"Link","linkType":"Entry","id":"2uvUxTj7xgbHN7m06Ekpmo"}},{"sys":{"type":"Link","linkType":"Entry","id":"6caWgGv16CdBLAnAELHGjH"}}],"openExternalLinksInNewTab":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4MypFsmISeX3lVf8orurw4"}},{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6NCHwlE0g9NQmUhvL0WIY6","type":"Entry","createdAt":"2022-01-07T18:24:49.501Z","updatedAt":"2023-09-24T18:40:29.354Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":77,"revision":15,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Edmonds-Karp and Dinic’s Algorithms for Maximum Flow","slug":"edmonds-karp-and-dinics-algorithms-for-maximum-flow","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"675c3u6tacMXieHHlB6n7X"}}],"tags":["Python"],"creationDate":"2022-01-07","readTime":"9min","content":"Edmonds-Karp is a maximum flow algorithm. This is a specific implementation of the Ford-Fulkerson algorithm that uses different techniques for finding augmenting paths.\n\nThe Ford-Fulkerson method is used to find the maximum flow. Maximum flow is very useful for finding bipartite matching.\nAt a high level, Ford-Fulkerson says that we want to repeatedly find an augmenting path from source to sink (s->t) in the flow graph, augment flow and repeat until no more paths exist.\n\nThe key takeaway here is that the Ford-Fulkerson method does not specify how to actually find augmenting paths. This is where optimizations come into play. There are many articles where we see that this method uses a DFS to find augmenting paths that take O(Ff) where E is the number of the edges and f is the maxflow.\n\nEach edge of the flow graph has a certain flow and capacity specified by the fraction adjacent to each edge. Initially, the flow through each edge is 0 and the capacity is non-negative.\n\nTo find the maximum flow (and min-cut as a product) the Ford-Fulkerson method repeatedly finds augmenting graphs through the residual graphs and augments the flow until no more augmenting paths can be found.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5AUHpeBvpYjiz32RzhEsbr/b26afd5ed9ceeb6d250d03c69d353783/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/5AUHpeBvpYjiz32RzhEsbr/b26afd5ed9ceeb6d250d03c69d353783/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/5AUHpeBvpYjiz32RzhEsbr/b26afd5ed9ceeb6d250d03c69d353783/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n*Credits for the image go to <a href=\"https://cp-algorithms.com/graph/edmonds_karp.html\">jakobkogler, DamianArado, adamant-pwn, infalmo, LUTLJS, Aryamn, Kakalinn, obiwac, shivensinha4, lm10-piyush, ShayekhBinIslam, wikku, roll-no-1</a>.*\n\n### Edmonds-Karp Algorithm:\nThe Edmonds-Karp algorithm is a modified form of the Ford-Fulkerson algorithm. The difference Is that Ford-Fulkerson uses the DFS approach and Edmonds-Karp uses the BFS approach.\nThe time complexity of this algorithm Is O(E^2) for irrational capacities and maximum longest path from source to sink.\n\n#### Implementation\nHere we use the BFS approach so we will make a 2-D array where we store the capacity of each vertex .We will also have an adjacency list for storing graphs because we will reverse the graph for finding an augmenting path.\nThe function maxflow is used to get the maximum value of a network from a 2-D array which is already created.\n\n```python\ndef bfs(arr, dp, source, sink):\n    q=[source]\n    paths={source:[]}\n    if source==sink:\n        return paths[source]\n    while queue:\n        u=queue.pop(0)\n        for neigh in range(len(arr)):\n            if arr[u][neigh]-dp[u][neigh]>0 and neigh not in paths:\n                paths[neigh]=paths[u]+[(u, neigh)]\n                print(paths)\n                if neigh==sink:\n                    return paths[neigh]\n                q.append(neigh)\n    return \ndef max_flow(arr, source, sink):\n    n=len(arr)\n    dp=[[0]*n for i in range(n)]\n    path=bfs(arr, dp,source, sink)\n    while path!=None:\n        flow=min(arr[u][v]-dp[u][v] for u,v in path)\n        for u,v in path:\n            dp[u][v]+=flow\n            dp[u][v]-=flow\n        path=bfs(arr, dp, source sink)\n    return sum(dp[source][i] for i in range(n))\n```\n\n#### Time complexity:\nThe time complexity of the Edmonds-Karp algorithm is O(VE^2) and space complexity is O(E+V), here E and V are the edges and vertices.\n\n#### Applications:\n1. Maximum flow algorithm\n2. Packet transfer on transport layer in computer network\n3. Traffic flow control on roads\n\n### Dinic’s Algorithm:\nLike the Ford-Fulkerson and Edmonds-Karp algorithms for finding maximum flow, Dinic’s algorithm is efficient for finding network flow of unweighted bipartite graphs. Dinic’s algorithm is fast and convenient. Here we work on combining multiple graph traversal techniques together.\nDinic’s is a strongly polynomial maximum flow algorithm with a runtime of O(VE^2).\nIt is extremely fast and works better on bipartite graphs, giving time complexity of O(VE^(1/2)) due to algorithm reduction.\nThe algorithm was invented by Yefim Dinitz in 1969 and published in 1970.\n\n#### Implementation\n1. Construct a level graph by doing a BFS from the source to sink, all the levels of the current flow graphs.\n2. If the sink was never reached while building the level graph, then stop and return the maxflow.\n3. Using only valid edges in the level graph, do multiple DFS from source to sink (s->t) until blocking flow is reached to sum the bottleneck values of all the augmenting paths found to calculate the maxflow.\n\n```python\ndef Bfs(C, First, s, t):  # C is the capacity matrix\n        n = len(C)\n        queue = []\n        queue.append(s)\n        global steps\n        steps = n * [0]  # initialization\n        steps[s] = 1  \n        while queue:\n            k = queue.pop(0)\n            for i in range(n):\n                    if (First[k][i] < C[k][i]) and (steps[i] == 0): # not visited\n                            steps[i] = steps[k] + 1\n                            queue.append(i)\n        return steps[t] > 0\n\n#search augmenting path by using DFS\ndef Dfs(C, F, k, cp):\n        tmp = cp\n        if k == len(C)-1:\n            return cp\n        for i in range(len(C)):\n            if (level[i] == level[k] + 1) and (F[k][i] < C[k][i]):\n                f = Dfs(C,F,i,min(tmp,C[k][i] - F[k][i]))\n                F[k][i] = F[k][i] + f\n                F[i][k] = F[i][k] - f\n                tmp = tmp - f\n        return cp - tmp\n\n#calculate max flow\n#_ = float('inf')\ndef MaxFlow(C,s,t):\n        n = len(C)\n        F = [n*[0] for i in range(n)] # F is the flow matrix\n        flow = 0\n        while(Bfs(C,F,s,t)):\n               flow = flow + Dfs(C,F,s,100000)\n        return flow\n```\n\n### Comparison Among Various Algorithms\nWe have already read about Edmonds-Karp and Dinic’s algorithms. Now let’s look at a comparison of all the algorithms for maximum flow in a graph.\n\n#### Ford-Fulkerson Max Flow Algorithm:\nFor the max flow f*, the maximum value |f*| denotes a bound in the number of iterations. Total running time is O(|f*|m).\nEdmonds-Karp Algorithm:\nWorst case time complexity O(|f*|m) to O(nm²).\n\n#### Goldberg-Tarjan Algorithm:\nTime complexity is O(n²m).\nBelow is a tabular analysis of all algorithms.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1MLwQtDAok1VpiOMDPCkDV/0a5b321ff19f4b3b1defee12de452717/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/1MLwQtDAok1VpiOMDPCkDV/0a5b321ff19f4b3b1defee12de452717/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/1MLwQtDAok1VpiOMDPCkDV/0a5b321ff19f4b3b1defee12de452717/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7koRSof4dMlEfXfkdGMKdH","type":"Asset","createdAt":"2022-01-07T18:18:28.869Z","updatedAt":"2023-09-24T18:35:10.267Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":2,"locale":"en-US"},"fields":{"title":"1200px-Pets flow.svg","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7koRSof4dMlEfXfkdGMKdH/b60c11fac7cb4e507a0af6e26b4fb7ff/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"phRCEOBFWzgGECLgjgpy6"}}],"upvotes":11,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2OIybkcX2PxUf6xgY98vXQ"}},{"sys":{"type":"Link","linkType":"Entry","id":"7lY31xHjXnvKIZaAx6u2ef"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2LF4An9w0IDCr6w8k43kXF","type":"Entry","createdAt":"2020-02-24T22:44:09.126Z","updatedAt":"2024-07-31T06:30:05.201Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1296,"revision":586,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Dynamic Programming: From Novice to Advanced","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Sorting","Libraries","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"<a href=\"http://apps.topcoder.com/forums/?module=ThreadList&forumID=505844\">Discuss this article in the forums</a> \n\\\nAn important part of given problems can be solved with the help of dynamic programming (<strong>DP</strong> for short).  Being able to tackle problems of this type would greatly increase your skill. I will try to help you in understanding how to solve problems using DP. The article is based on examples, because a raw theory is very hard to understand. \n\\\n__Note__: If you’re bored reading one section and you already know what’s being discussed in it – skip it and go to the next one. \n\n### Introduction (Beginner)\n<em><strong>What is a dynamic programming, how can it be described?</strong></em> A <strong>DP</strong> is an algorithmic technique which is usually based on a recurrent formula and one (or some) starting states. A sub-solution of the problem is constructed from previously found ones. DP solutions have a polynomial complexity which assures a much faster running time than other techniques like backtracking, brute-force etc.\n\\\nNow let’s see the base of DP with the help of an example: \n\\\nGiven a list of N coins, their values (<strong>V<sub>1</sub></strong>, <strong>V<sub>2</sub></strong>, … , <strong>V<sub>N</sub></strong>), and the total sum <strong>S</strong>. Find the minimum number of coins the sum of which is <strong>S</strong> (we can use as many coins of one type as we want), or report that it’s not possible to select coins in such a way that they sum up to <strong>S</strong>. \n\\\nNow let’s start constructing a DP solution: \n\\\nFirst of all we need to find a state for which an optimal solution is found and with the help of which we can find the optimal solution for the next state. \n\\\n<em><strong>What does a \"state\" stand for?</strong></em> \n\\\nIt’s a way to describe a situation, a sub-solution for the problem. For example a state would be the solution for sum <strong>i</strong>, where <strong>i≤S</strong>. A smaller state than state <strong>i</strong> would be the solution for any sum <strong>j</strong>, where <strong>j&lt;i</strong>. For finding a <strong>state i</strong>, we need to first find all smaller states <strong>j (j&lt;i) </strong>. Having found the minimum number of coins which sum up to <strong>i</strong>, we can easily find the next state – the solution for <strong>i+1</strong>. \n\\\n<em><strong>How can we find it?</strong></em> \n\\\nIt is simple – for each coin <strong>j, V<sub>j</sub>≤i</strong>, look at the minimum number of coins found for the <strong>i-V<sub>j</sub></strong>sum (we have already found it previously). Let this number be <strong>m</strong>. If <strong>m+1</strong> is less than the minimum number of coins already found for current sum <strong>i</strong>, then we write the new result for it. \n\\\nFor a better understanding let’s take this example:<br>Given coins with values 1, 3, and 5.<br>And the sum <strong>S</strong> is set to be 11. \n\\\nFirst of all we mark that for state 0 (sum 0) we have found a solution with a minimum number of 0 coins. We then go to sum 1. First, we mark that we haven’t yet found a solution for this one (a value of Infinity would be fine). Then we see that only coin 1 is less than or equal to the current sum. Analyzing it, we see that for sum 1-<strong>V<sub>1</sub></strong>= 0  we have a solution with 0 coins. Because we add one coin to this solution, we’ll have a solution with 1 coin for sum 1. It’s the only solution yet found for this sum. We write (save) it. Then we proceed to the next state – <strong>sum 2</strong>. We again see that the only coin which is less or equal to this sum is the first coin, having a value of 1. The optimal solution found for sum (2-1) = 1  is coin 1. This coin 1 plus the first coin will sum up to 2, and thus make a sum of 2 with the help of only 2 coins. This is the best and only solution for sum 2. Now we proceed to sum 3. We now have 2 coins which are to be analyzed – first and second one, having values of 1 and 3. Let’s see the first one. There exists a solution for sum 2 (3 – 1) and therefore we can construct from it a solution for sum 3 by adding the first coin to it. Because the best solution for sum 2 that we found has 2 coins, the new solution for sum 3 will have 3 coins. Now let’s take the second coin with value equal to 3. The sum for which this coin needs to be added to make 3 , is 0. We know that sum 0 is made up of 0 coins. Thus we can make a sum of 3 with only one coin – 3. We see that it’s better than the previous found solution for sum 3 , which was composed of 3 coins. We update it and mark it as having only 1 coin. The same we do for sum 4, and get a solution of 2 coins – 1+3. And so on. \n\\\n<strong>Pseudocode:</strong> \n```\nSet Min[i] equal to Infinity for all of i\nMin[0]=0\n\nFor i = 1 to S\nFor j = 0 to N - 1\n\tIf (Vj<=i AND Min[i-Vj]+1 < Min[i])\nThen Min[i]=Min[i-Vj]+1\n\nOutput Min[S]\n```\n\nHere are the solutions found for all sums:\n\\\n<table class=\"tableizer-table\"><thead><tr class=\"tableizer-firstrow\"><th style=\"width:20%\">Sum</th><th style=\"width:32%\">Min. nr. of coins</th><th>Coin value (Previous Smaller Sum)</th></tr></thead><tbody><tr><td>0</td><td>0</td><td>-</td></tr><tr><td>1</td><td>1</td><td>1 (0)</td></tr><tr><td>2</td><td>2</td><td>1 (1)</td></tr><tr><td>3</td><td>1</td><td>3 (0)</td></tr><tr><td>4</td><td>2</td><td>1 (3)</td></tr><tr><td>5</td><td>1</td><td>5 (0)</td></tr><tr><td>6</td><td>2</td><td>3 (3)</td></tr><tr><td>7</td><td>3</td><td>1 (6)</td></tr><tr><td>8</td><td>2</td><td>3 (5)</td></tr><tr><td>9</td><td>3</td><td>1 (8)</td></tr><tr><td>10</td><td>2</td><td>5 (5)</td></tr><tr><td>11</td><td>3</td><td>1 (10)</td></tr> </tbody></table>\n\nAs a result we have found a solution of 3 coins which sum up to 11. \n\nAdditionally, by tracking data about how we got to a certain sum from a previous one, we can find what coins were used in building it. For example: to sum 11 we got by adding the coin with value 1 to a sum of 10. To sum 10 we got from 5. To 5 – from 0. This way we find the coins used: 1, 5 and 5. \n\nHaving understood the basic way a <strong>DP</strong> is used, we may now see a slightly different approach to it. It involves the change (update) of best solution yet found for a sum i, whenever a better solution for this sum was found. In this case the states aren’t calculated consecutively. Let’s consider the problem above. Start with having a solution of 0 coins for sum 0. Now let’s try to add first coin (with value 1) to all sums already found. If the resulting sum <strong>t</strong> will be composed of fewer coins than the one previously found – we’ll update the solution for it. Then we do the same thing for the second coin, third coin, and so on for the rest of them. For example, we first add coin 1 to sum 0 and get sum 1. Because we haven’t yet found a possible way to make a sum of 1 – this is the best solution yet found, and we mark <strong>S[1]=1</strong>. By adding the same coin to sum 1, we’ll get sum 2, thus making <strong>S[2]=2</strong>. And so on for the first coin. After the first coin is processed, take coin 2 (having a value of 3) and consecutively try to add it to each of the sums already found. Adding it to 0, a sum 3 made up of 1 coin will result. Till now, <strong>S[3]</strong> has been equal to 3, thus the new solution is better than the previously found one. We update it and mark <strong>S[3]=1</strong>. After adding the same coin to sum 1, we’ll get a sum 4 composed of 2 coins. Previously we found a sum of 4 composed of 4 coins; having now found a better solution we update <strong>S[4]</strong> to 2. The same thing is done for next sums – each time a better solution is found, the results are updated.\n\n### Elementary\n\nTo this point, very simple examples have been discussed. Now let’s see how to find a way for passing from one state to another, for harder problems. For that we will introduce a new term called recurrent relation, which makes a connection between a lower and a greater state.\n\nLet’s see how it works: \n\nGiven a sequence of N numbers – <strong>A[1] </strong>, <strong>A[2] </strong>, …, <strong>A[N] </strong>. Find the length of the longest non-decreasing sequence. \n\nAs described above we must first find how to define a \"state\" which represents a sub-problem and thus we have to find a solution for it. Note that in most cases the states rely on lower states and are independent from greater states. \n\nLet’s define a state <strong>i</strong> as being the longest non-decreasing sequence which has its last number <strong>A[i] </strong>. This state carries only data about the length of this sequence. Note that for <strong>i&lt;j</strong> the state <strong>i</strong> is independent from <strong>j</strong>, i.e. doesn’t change when we calculate state <strong>j</strong>. Let’s see now how these states are connected to each other. Having found the solutions for all states lower than <strong>i</strong>, we may now look for state <strong>i</strong>. At first we initialize it with a solution of 1, which consists only of the <strong>i-th</strong> number itself. Now for each <strong>j&lt;i</strong> let’s see if it’s possible to pass from it to state i. This is possible only when <strong>A[j]≤A[i] </strong>, thus keeping (assuring) the sequence non-decreasing. So if <strong>S[j] </strong> (the solution found for state <strong>j</strong>) + <strong>1</strong> (number <strong>A[i] </strong> added to this sequence which ends with number <strong>A[j] </strong>) is better than a solution found for <strong>i</strong> (ie. <strong>S[j]+1&gt;S[i] </strong>), we make <strong>S[i]=S[j]+1</strong>. This way we consecutively find the best solutions for each <strong>i</strong>, until last state N. \n\nLet’s see what happens for a randomly generated sequence: 5, 3, 4, 8, 6, 7: \n\n<table><thead><tr class=\"tableizer-firstrow\"><th style=\"width:20%\">I</th><th style=\"width:32%\">Length of Longest non-decreasing sequence (first I numbers)</th><th>The last sequence i from which we \"arrived\" to this one</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>1 (first number itself)</td></tr><tr><td>2</td><td>1</td><td>2 (second number itself)</td></tr><tr><td>3</td><td>2</td><td>2</td></tr><tr><td>4</td><td>3</td><td>3</td></tr><tr><td>5</td><td>3</td><td>3</td></tr><tr><td>6</td><td>4</td><td>5</td></tr> </tbody></table>\n\n<strong>Practice problem:</strong><br>\n\nGiven an undirected graph <strong>G</strong> having <strong>N</strong> (1&lt;N&lt;=1000) vertices and positive weights. Find the shortest path from vertex 1 to vertex N, or state that such path doesn’t exist.\n\nHint: At each step, among the vertices which weren’t yet checked and for which a path from vertex 1 was found, take the one which has the shortest path, from vertex 1 to it, yet found. \n\nTry to solve the following problems from Topcoder competitions:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4493&pm=1259\">ZigZag</a> – 2003 TCCC Semifinals 3\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5009&pm=2402\">BadNeighbors</a> – 2004 TCCC Round 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5006&pm=1918\">FlowerGarden</a> – 2004 TCCC Round 1\n\n### Intermediate\n\nLet’s see now how to tackle bi-dimensional DP problems.\n\n<strong>Problem:</strong>\n\nA table composed of <strong>N x M</strong> cells, each having a certain quantity of apples, is given. You start from the upper-left corner. At each step you can go down or right one cell. Find the maximum number of apples you can collect. \n\nThis problem is solved in the same way as other DP problems; there is almost no difference.\n\nFirst of all we have to find a state. The first thing that must be observed is that there are at most 2 ways we can come to a cell – from the left (if it’s not situated on the first column) and from the top (if it’s not situated on the most upper row). Thus to find the best solution for that cell, we have to have already found the best solutions for all of the cells from which we can arrive to the current cell. \n\nFrom above, a recurrent relation can be easily obtained:<br>\n<strong>S[i][j]=A[i][j] + max(S[i-1][j], if i&gt;0 ; S[i][j-1], if j&gt;0) </strong> (where <strong>i</strong> represents the row and <strong>j</strong> the column of the table , its left-upper corner having coordinates {0,0} ; and <strong>A[i][j]</strong> being the number of apples situated in cell <strong>i,j</strong>). \n\n<strong>S[i][j] </strong> must be calculated by going first from left to right in each row and process the rows from top to bottom, or by going first from top to bottom in each column and process the columns from left to right. \n\nPseudocode:\n```\nFor i = 0 to N - 1\n\tFor j = 0 to M - 1\n\tS[i][j] = A[i][j] +\n\t\tmax(S[i][j-1], if j>0 ; S[i-1][j], if i>0 ; 0)\n\nOutput S[n-1][m-1]\n```\n\nHere are a few problems, from Topcoder Competitions, for practicing:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4709&pm=1889\">AvoidRoads</a> – 2003 TCO Semifinals 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4482&pm=1592\">ChessMetric</a> – 2003 TCCC Round 4\n\n### Upper-Intermediate\n\nThis section will discuss about dealing DP problems which have an additional condition besides the values that must be calculated.\n\nAs a good example would serve the following problem: \n\nGiven an undirected graph <strong>G</strong> having positive weights and <strong>N</strong> vertices.\n\nYou start with having a sum of <strong>M</strong> money. For passing through a vertex <strong>i</strong>, you must pay <strong>S[i] </strong> money. If you don’t have enough money – you can’t pass through that vertex. Find the shortest path from vertex 1 to vertex N, respecting the above conditions; or state that such path doesn’t exist. If there exist more than one path having the same length, then output the cheapest one. Restrictions: 1&lt;N&lt;=100 ; 0&lt;=M&lt;=100 ; for each i, 0&lt;=S[i]&lt;=100. As we can see, this is the same as the classical Dijkstra problem (finding the shortest path between two vertices), with the exception that it has a condition. In the classical Dijkstra problem we would have used a uni-dimensional array <strong>Min[i] </strong>, which marks the length of the shortest path found to vertex <strong>i</strong>. However in this problem we should also keep information about the money we have. Thus it would be reasonable to extend the array to something like <strong>Min[i][j] </strong>, which represents the length of the shortest path found to vertex <strong>i</strong>, with <strong>j</strong> money being left. In this way the problem is reduced to the original path-finding algorithm. At each step we find the unmarked state (i,j) for which the shortest path was found. We mark it as visited (not to use it later), and for each of its neighbors we look if the shortest path to it may be improved. If so – then update it. We repeat this step until there will remain no unmarked state to which a path was found. The solution will be represented by <strong>Min[N-1][j] </strong> having the least value (and the greatest <strong>j</strong> possible among the states having the same value, i.e. the shortest paths to which has the same length). \n\nPseudocode:\n```\nSet states(i,j) as unvisited for all (i,j)\nSet Min[i][j] to Infinity for all (i,j)\n\nMin[0][M]=0\n\nWhile(TRUE)\n\nAmong all unvisited states(i,j) find the one for which Min[i][j]\nis the smallest. Let this state found be (k,l).\n\nIf there wasn't found any state (k,l) for which Min[k][l] is\nless than Infinity - exit While loop.\n\nMark state(k,l) as visited\n\nFor All Neighbors p of Vertex k.\n\tIf (l-S[p]>=0 AND\n\tMin[p][l-S[p]]>Min[k][l]+Dist[k][p])\n\t\tThen Min[p][l-S[p]]=Min[k][l]+Dist[k][p]\ni.e.\nIf for state(i,j) there are enough money left for\ngoing to vertex p (l-S[p] represents the money that\nwill remain after passing to vertex p), and the\nshortest path found for state(p,l-S[p]) is bigger\nthan [the shortest path found for\nstate(k,l)] + [distance from vertex k to vertex p)],\nthen set the shortest path for state(i,j) to be equal\nto this sum.\nEnd For\n\nEnd While\n\nFind the smallest number among Min[N-1][j] (for all j, 0<=j<=M);\nif there are more than one such states, then take the one with greater\nj. If there are no states(N-1,j) with value less than Infinity - then\nsuch a path doesn't exist.\n```\n\nHere are a few Topcoder problems for practicing:\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4705&pm=1166\">Jewelry</a> – 2003 TCO Online Round 4\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4555&pm=1215\">StripePainter</a> – SRM 150 Div 1\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829\">QuickSums</a> – SRM 197 Div 2\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4630&pm=1861\">ShortPalindromes</a> – SRM 165 Div 2\n\n### Advanced\n\nThe following problems will need some good observations in order to reduce them to a dynamic solution.\n\n<strong>Problem <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5854&pm=2940\">StarAdventure</a> – SRM 208 Div 1:</strong> \n\nGiven a matrix with <strong>M</strong> rows and <strong>N</strong> columns (<strong>N x M</strong>). In each cell there’s a number of apples.<br> You start from the upper-left corner of the matrix. You can go down or right one cell. You need to arrive to the bottom-right corner. Then you need to go back to the upper-left cell by going each step one cell left or up. Having arrived at this upper-left cell, you need to go again back to the bottom-right cell.<br> Find the maximum number of apples you can collect.<br>When you pass through a cell – you collect all the apples left there.\n\nRestrictions: 1 &lt; <strong>N</strong>, <strong>M</strong> &lt;= 50 ; each cell contains between 0 and 1000 apples inclusive. \n First of all we observe that this problem resembles to the classical one (described in Section 3 of this article), in which you need to go only once from the top-left cell to the bottom-right one, collecting the maximum possible number of apples. It would be better to try to reduce the problem to this one. Take a good look into the statement of the problem – what can be reduced or modified in a certain way to make it possible to solve using DP? First observation is that we can consider the second path (going from bottom-right cell to the top-left cell) as a path which goes from top-left to bottom-right cell. It makes no difference, because a path passed from bottom to top, may be passed from top to bottom just in reverse order. In this way we get three paths going from top to bottom. This somehow decreases the difficulty of the problem. We can consider these 3 paths as left, middle and right. When 2 paths intersect (like in the figure below) \n\n<center>\n<img src=\"https://www.topcoder.com/i/education/dynProg_1.gif\" border=\"0/\">\n</center>\n\nwe may consider them as in the following picture, without affecting the result: \n\n<center>\n<img src=\"https://www.topcoder.com/i/education/dynProg_2.gif\" border=\"0/\">\n</center>\n\nThis way we’ll get 3 paths, which we may consider as being one left, one middle and the other – right. More than that, we may see that for getting an optimal results they must not intersect (except in the leftmost upper corner and rightmost bottom corner). So for each row <strong>y</strong> (except first and last), the <strong>x</strong> coordinates of the lines (<strong>x1[y] </strong>, <strong>x2[y] </strong> and respectively <strong>x3[y] </strong>) will be : <strong>x1[y] </strong> &lt; <strong>x2[y] </strong> &lt; <strong>x3[y] </strong>. Having done that – the DP solution now becomes much clearer. Let’s consider the row y. Now suppose that for any configuration of <strong>x1[y-1] </strong>, <strong>x2[y-1] </strong> and <strong>x3[y-1] </strong> we have already found the paths which collect the maximum number of apples. From them we can find the optimal solution for row <strong>y</strong>. We now have to find only the way for passing from one row to the next one. Let <strong>Max[i][j][k] </strong> represent the maximum number of apples collected till row <strong>y-1</strong> inclusive, with three paths finishing at column <strong>i</strong>, <strong>j</strong>, and respectively <strong>k</strong>. For the next row <strong>y</strong>, add to each <strong>Max[i][j][k] </strong> (obtained previously) the number of apples situated in cells (<strong>y,i</strong>) , (<strong>y,j</strong>) and (<strong>y,k</strong>). Thus we move down at each step. After we made such a move, we must consider that the paths may move in a row to the right. For keeping the paths out of an intersection, we must first consider the move to the right of the left path, after this of the middle path, and then of the right path. For a better understanding think about the move to the right of the left path – take every possible pair of, <strong>k</strong> (where <strong>j&lt;k</strong>), and for each i (1 i&lt;j) consider the move from position (<strong>i-1,j,k</strong>) to position (<strong>i,j,k</strong>). Having done this for the left path, start processing the middle one, which is done similarly; and then process the right path.  \n\nTC problems for practicing:\n\n- <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4710&pm=1996\">MiniPaint</a> – SRM 178 Div 1\n\n<strong>Additional Note:</strong>\n\nWhen have read the description of a problem and started to solve it, first look at its restrictions. If a polynomial-time algorithm should be developed, then it’s possible that the solution may be of DP type. In this case try to see if there exist such states (sub-solutions) with the help of which the next states (sub-solutions) may be found. Having found that – think about how to pass from one state to another. If it seems to be a DP problem, but you can’t define such states, then try to reduce the problem to another one (like in the example above, from Section 5).\n\n<strong>Mentioned in this writeup:</strong>\n\nTCCC ’03 Semifinals 3 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4493&pm=1259\">ZigZag</a>\nTCCC ’04 Round 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5009&pm=2402\">BadNeighbors</a>\nTCCC ’04 Round 1 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5006&pm=1918\">FlowerGarden</a>\nTCO ’03 Semifinals 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4709&pm=1889\">AvoidRoads</a>\nTCCC ’03 Round 4 Div I Easy – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4482&pm=1592\">ChessMetric</a>\nTCO ’03 Round 4 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4705&pm=1166\">Jewelry</a>\nSRM 150 Div I Med – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4555&pm=1215\">StripePainter</a>\nSRM 197 Div II Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829\">QuickSums</a>\nSRM 165 Div II Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4630&pm=1861\">ShortPalindromes</a>\nSRM 208 Div I Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=5854&pm=2940\">StarAdventure</a>\nSRM 178 Div I Hard – <a href=\"http://community.topcoder.com/tc?module=ProblemDetail&rd=4710&pm=1996\">MiniPaint</a>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6ApTxswgnc51lFyJsCTKPs","type":"Entry","createdAt":"2020-02-19T12:51:56.736Z","updatedAt":"2020-02-19T12:51:56.736Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Dumitru","tcHandle":"Dumitru"}}],"upvotes":200,"downvotes":32}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"sys":{"type":"Link","linkType":"Entry","id":"6RtWLyyPIjfqoG7K6pAfGJ","circular":true}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"sys":{"type":"Link","linkType":"Entry","id":"6RtWLyyPIjfqoG7K6pAfGJ","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6SVKkQffchAt1KAGrhgch4","type":"Entry","createdAt":"2020-02-22T15:26:17.339Z","updatedAt":"2022-06-22T21:17:05.347Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Primality Testing : Non-deterministic Algorithms","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","Testing","Java","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=519109)\n\n### Introduction\n\nPrimality testing of a number is perhaps the most common problem concerning number theory that topcoders deal with. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. Some basic algorithms and details regarding primality testing and factorization can be found [here](https://www.topcoder.com/thrive/articles/Prime%20Numbers,%20Factorization%20and%20Euler%20Function).\n\nThe problem of detecting whether a given number is a prime number has been studied extensively but nonetheless, it turns out that all the deterministic algorithms for this problem are too slow to be used in real life situations and the better ones amongst them are tedious to code. But, there are some probabilistic methods which are very fast and very easy to code. Moreover, the probability of getting a wrong result with these algorithms is so low that it can be neglected in normal situations.\n\nThis article discusses some of the popular probabilistic methods such as Fermat’s test, Rabin-Miller test, Solovay-Strassen test.\n\n### Modular Exponentiation\n\nAll the algorithms which we are going to discuss will require you to efficiently compute (ab)%c ( where a,b,c are non-negative integers ). A straightforward algorithm to do the task can be to iteratively multiply the result with ‘a’ and take the remainder with ‘c’ at each step.\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* a function to compute (ab)%c */\nint modulo(int a,int b,int c){\n    // res is kept as long long because intermediate results might overflow in \"int\"\n    long long res = 1; \n    for(int i=0;i<b;i++){\n        res *= a;\n        res %= c; // this step is valid because (a\\*b)%c = ((a%c)\\*(b%c))%c\n    }\n    return res%c;\n}\n</div>\n\nHowever, as you can clearly see, this algorithm takes O(b) time and is not very useful in practice. We can do it in O( log(b) ) by using what is called as exponentiation by squaring. The idea is very simple:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n   (a2)(b/2)           if b is even and b > 0\nab = a*(a2)((b-1)/2)    if b is odd\n   1                  if b = 0\n   </div>\n\nThis idea can be implemented very easily as shown below:\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* This function calculates (ab)%c */\nint modulo(int a,int b,int c){\n    long long x=1,y=a; // long long is taken to avoid overflow of intermediate results\n    while(b > 0){\n        if(b%2 == 1){\n            x=(x*y)%c;\n        }\n        y = (y*y)%c; // squaring the base\n        b /= 2;\n    }\n    return x%c;\n}\n</div>\nNotice that after i iterations, b becomes b/(2i), and y becomes (y(2i))%c. Multiplying x with y is equivalent to adding 2i to the overall power. We do this if the ith bit from right in the binary representation of b is 1. Let us take an example by computing (7107)%9\\. If we use the above code, the variables after each iteration of the loop would look like this: ( a = 7, c = 9 )\n\niterations&nbsp;&nbsp;&nbsp;     b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  y\n    0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   107 &nbsp;&nbsp;&nbsp;    1  &nbsp;&nbsp;&nbsp;&nbsp;   7\n    1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    53 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          7  &nbsp;&nbsp;&nbsp;&nbsp;    4\n    2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    26 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          1  &nbsp;&nbsp;&nbsp;&nbsp;    7\n    3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    13 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          1  &nbsp;&nbsp;&nbsp;&nbsp;   4\n    4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     6   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          4  &nbsp;&nbsp;&nbsp;&nbsp;   7\n    5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     3  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           4  &nbsp;&nbsp;&nbsp;&nbsp;   4\n    6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        7  &nbsp;&nbsp;&nbsp;&nbsp;   7\n    7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           4&ensp;&nbsp;&nbsp;&nbsp;&nbsp;                       4\n    \n\n\nNow b becomes 0 and the return value of the function is 4. Hence (7107)%9 = 4.\n\nThe above code could only work for a,b,c in the range of type “int” or the intermediate results will run out of the range of “long long”. To write a function for numbers up to 10^18, we need to compute (a\\*b)%c when computing a\\*b directly can grow larger than what a long long can handle. We can use a similar idea to do that:\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n    (2\\*a)\\*(b/2)              if b is even and b > 0\na\\*b = a + (2\\*a)*((b-1)/2)    if b is odd\n    0       if b = 0\n</div>\n\nHere is some code which uses the idea described above ( you can notice that its the same code as exponentiation, just changing a couple of lines ):\n\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* this function calculates (a\\*b)%c taking into account that a\\*b might overflow */\nlong long mulmod(long long a,long long b,long long c){\n    long long x = 0,y=a%c;\n    while(b > 0){\n        if(b%2 == 1){\n            x = (x+y)%c;\n        }\n        y = (y*2)%c;\n        b /= 2;\n    }\n    return x%c;\n}\n</div>\n\nWe could replace x=(x\\*y)%c with x = mulmod(x,y,c) and y = (y\\*y)%c with y = mulmod(y,y,c) in the original function for calculating (ab)%c. This function requires that 2*c should be in the range of long long. For numbers larger than this, we could write our own BigInt class ( java has an inbuilt one ) with addition, multiplication and modulus operations and use them.\n\nThis method for exponentiation could be further improved by using Montgomery Multiplication. Montgomery Multiplication algorithm is a quick method to compute (a*b)%c, but since it requires some pre-processing, it doesn’t help much if you are just going to compute one modular multiplication. But while doing exponentiation, we need to do the pre-processing for ‘c’ just once, that makes it a better choice if you are expecting very high speed. You can read about it at the links mentioned in the reference section.\n\nSimilar technique can be used to compute (ab)%c in O(n3 \\* log(b)), where a is a square matrix of size n x n. All we need to do in this case is manipulate all the operations as matrix operations. Matrix exponentiation is a very handy tool for your algorithm library and you can see problems involving this every now and then.\n\n### Fermat Primality Test\n\n**Fermat’s Little Theorem**  \nAccording to Fermat’s Little Theorem if p is a prime number and a is a positive integer less than p, then\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n    ap = a ( mod p )\nor alternatively:\n    a(p-1) = 1 ( mod p )\n</div>\n**Algorithm of the test**  \nIf p is the number which we want to test for primality, then we could randomly choose a, such that a < p and then calculate (a(p-1))%p. If the result is not 1, then by Fermat’s Little Theorem p cannot be prime. What if that is not the case? We can choose another a and then do the same test again. We could stop after some number of iterations and if the result is always 1 in each of them, then we can state with very high probability that p is prime. The more iterations we do, the higher is the probability that our result is correct. You can notice that if the method returns composite, then the number is sure to be composite, otherwise it will be probably prime.\n\nGiven below is a simple function implementing Fermat’s primality test:\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* Fermat's test for checking primality, the more iterations the more is accuracy */\nbool Fermat(long long p,int iterations){\n    if(p == 1){ // 1 isn't prime\n        return false;\n    }\n    for(int i=0;i<iterations;i++){\n        // choose a random integer between 1 and p-1 ( inclusive )\n        long long a = rand()%(p-1)+1; \n        // modulo is the function we developed above for modular exponentiation.\n        if(modulo(a,p-1,p) != 1){ \n            return false; /* p is definitely composite */\n        }\n    }\n    return true; /* p is probably prime */\n}\n</div>\nMore iterations of the function will result in higher accuracy, but will take more time. You can choose the number of iterations depending upon the application.\n\nThough Fermat is highly accurate in practice there are certain composite numbers p known as Carmichael numbers for which all values of a<p for which gcd(a,p)=1, (a(p-1))%p = 1. If we apply Fermat’s test on a Carmichael number the probability of choosing an a such that gcd(a,p) != 1 is very low ( based on the nature of Carmichael numbers ), and in that case, the Fermat’s test will return a wrong result with very high probability. Although Carmichael numbers are very rare ( there are about 250,000 of them less than 1016 ), but that by no way means that the result you get is always correct. Someone could easily challenge you if you were to use Fermat’s test :). Out of the Carmichael numbers less than 1016, about 95% of them are divisible by primes < 1000. This suggests that apart from applying Fermat’s test, you may also test the number for divisibility with small prime numbers and this will further reduce the probability of failing. However, there are other improved primality tests which don’t have this flaw as Fermat’s. We will discuss some of them now.\n\n### Miller-Rabin Primality Test\n\n**Key Ideas and Concepts**  \n\n1.  Fermat’s Little Theorem.\n2.  If p is prime and x2 = 1 ( mod p ), then x = +1 or -1 ( mod p ). We could prove this as follows:\n    <div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n    x2 = 1 ( mod p )\n    x2 \\- 1 = 0 ( mod p )\n    (x-1)(x+1) = 0 ( mod p )\n        </div>\n    \n\nNow if p does not divide both (x-1) and (x+1) and it divides their product, then it cannot be a prime, which is a contradiction. Hence, p will either divide (x-1) or it will divide (x+1), so x = +1 or -1 ( mod p ).\n\nLet us assume that p – 1 = 2d \\* s where s is odd and d >= 0. If p is prime, then either as = 1 ( mod p ) as in this case, repeated squaring from as will always yield 1, so (a(p-1))%p will be 1; or a(s*(2r)) = -1 ( mod p ) for some r such that 0 <= r < d, as repeated squaring from it will always yield 1 and finally a(p-1) = 1 ( mod p ). If none of these hold true, a(p-1) will not be 1 for any prime number a ( otherwise there will be a contradiction with fact #2 ).\n\n**Algorithm**  \nLet p be the given number which we have to test for primality. First we rewrite p-1 as (2d)*s. Now we pick some a in range \\[1,n-1\\] and then check whether as = 1 ( mod p ) or a(s*(2r)) = -1 ( mod p ). If both of them fail, then p is definitely composite. Otherwise p is probably prime. We can choose another a and repeat the same test. We can stop after some fixed number of iterations and claim that either p is definitely composite, or it is probably prime.\n\nA small procedure realizing the above algorithm is given below:\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n/\\* Miller-Rabin primality test, iteration signifies the accuracy of the test */\nbool Miller(long long p,int iteration){\n    if(p<2){\n        return false;\n    }\n    if(p!=2 && p%2==0){\n        return false;\n    }\n    long long s=p-1;\n    while(s%2==0){\n        s/=2;\n    }\n    for(int i=0;i<iteration;i++){\n        long long a=rand()%(p-1)+1,temp=s;\n        long long mod=modulo(a,temp,p);\n        while(temp!=p-1 && mod!=1 && mod!=p-1){\n            mod=mulmod(mod,mod,p);tion\n            temp *= 2;\n        }\n        if(mod!=p-1 && temp%2==0){\n            return false;\n        }\n    }\n    return true;\n}\n</div>\nIt can be shown that for any composite number p, at least (3/4) of the numbers less than p will witness p to be composite when chosen as ‘a’ in the above test. Which means that if we do 1 iteration, probability that a composite number is returned as prime is (1/4). With k iterations the probability of test failing is (1/4)k or 4(-k). This test is comparatively slower compared to Fermat’s test but it doesn’t break down for any specific composite numbers and 18-20 iterations is a quite good choice for most applications.\n\n### Solovay-Strassen Primality Test\n\n**Key Ideas and Concepts**\n\n1.  Legendre Symbol: This symbol is defined for a pair of integers a and p such that p is prime. It is denoted by (a/p) and calculated as:\n    <div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n          = 0    if a%p = 0\n    (a/p) = 1    if there exists an integer k such that k2 = a ( mod p )\n          = -1   otherwise.\n    \n    It is proved by Euler that:\n    \n    (a/p) = (a((p-1)/2)) % p\n    \n    So we can also say that:\n    \n    (ab/p) = (ab((p-1)/2)) % p = (a((p-1)/2))%p * (b((p-1)/2))%p = (a/p)*(b/p)\n       </div> \n    \n2.  Jacobian Symbol: This symbol is a generalization of Legendre Symbol as it does not require ‘p’ to be prime. Let a and n be two positive integers, and n = p1k1 \\* .. \\* pnkn, then Jacobian symbol is defined as:\n    <div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n    (a/n) = ((a/p1)k1) \\* ((a/p2)k2) \\* ..... \\* ((a/pn)kn)\n       </div> \n    \n    So you can see that if n is prime, the Jacobian symbol and Legendre symbol are equal.\n    1.  There are some properties of these symbols which we can exploit to quickly calculate them:\n    2.  (a/n) = 0 if gcd(a,n) != 1, Hence (0/n) = 0. This is because if gcd(a,n) != 1, then there must be some prime pi such that pi divides both a and n. In that case (a/pi) = 0 \\[ by definition of Legendre Symbol \\].\n    3.  (ab/n) = (a/n) * (b/n). It can be easily derived from the fact (ab/p) = (a/p)(b/p) ( here (a/p) is the Legendry Symbol ).\n    4.  if a is even, than (a/n) = (2/n)*((a/2)/n). It can be shown that:\n        <div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n              = 1 if n = 1 ( mod 8 ) or n = 7 ( mod 8 )\n        (2/n) = -1 if n = 3 ( mod 8 ) or n = 5 ( mod 8 )\n              = 0 otherwise\n       </div> \n    5.  (a/n) = (n/a)*(-1((a-1)(n-1)/4)) if a and n are both odd.\n\nThe algorithm for the test is really simple. We can pick up a random a and compute (a/n). If n is a prime then (a/n) should be equal to (a((n-1)/2))%n \\[ as proved by Euler \\]. If they are not equal then n is composite, and we can stop. Otherwise we can choose more random values for a and repeat the test. We can declare n to be probably prime after some iterations.\n\nNote that we are not interested in calculating Jacobi Symbol (a/n) if n is an even integer because we can trivially see that n isn’t prime, except 2 of course.\n\nLet us write a little code to compute Jacobian Symbol (a/n) and for the test:\n<div style=\"background-color:#f5f5f5; margin:15px; padding:0 15px 15px;\">\n//calculates Jacobian(a/n) n>0 and n is odd\nint calculateJacobian(long long a,long long n){\n    if(!a) return 0; // (0/n) = 0\n    int ans=1;\n    long long temp;\n    if(a<0){\n        a=-a;    // (a/n) = (-a/n)*(-1/n)\n        if(n%4==3) ans=-ans; // (-1/n) = -1 if n = 3 ( mod 4 ) \n    }\n    if(a==1) return ans; // (1/n) = 1\n    while(a){\n        if(a<0){\n            a=-a;    // (a/n) = (-a/n)*(-1/n)\n            if(n%4==3) ans=-ans;    // (-1/n) = -1 if n = 3 ( mod 4 )\n        }\n        while(a%2==0){\n            a=a/2;    // Property (iii)\n            if(n%8==3||n%8==5) ans=-ans;    \n        }\n        swap(a,n);    // Property (iv)\n        if(a%4==3 && n%4==3) ans=-ans; // Property (iv)\n        a=a%n; // because (a/p) = (a%p / p ) and a%pi = (a%n)%pi if n % pi = 0\n        if(a>n/2) a=a-n; \n    }\n    if(n==1) return ans;\n    return 0; \n}\n/\\* Iterations determine the accuracy of the test */\nbool Solovoy(long long p,int iteration){\n    if(p<2) return false;\n    if(p!=2 && p%2==0) return false;\n    for(int i=0;i<iteration;i++){\n        long long a=rand()%(p-1)+1;\n        long long jacobian=(p+calculateJacobian(a,p))%p;\n        long long mod=modulo(a,(p-1)/2,p);\n        if(!jacobian || mod!=jacobian){ \n            return false;\n        }\n    }\n    return true;\n}\n</div>\nIt is shown that for any composite n, at least half of the a will result in n being declared as composite according to Solovay-Strassen test. This shows that the probability of getting a wrong result after k iterations is (1/2)k. However, it is generally less preferred than Rabin-Miller test in practice because it gives poorer performance.\n\nThe various routines provided in the article can be highly optimized just by using bitwise operators instead of them. For example /= 2 can be replaced by “>>= 1″, “%2″ can be replaced by “&1″ and “*= 2″ can be replaced by “<<=1″. Inline Assembly can also be used to optimize them further.\n\n### Practice Problems\n\nProblems involving non-deterministic primality tests are not very suitable for the SRM format. But problems involving modular exponentiation and matrix exponentiation are common. Here are some of the problems where you can apply the methods studied above:\n\n[PowerDigit](http://community.topcoder.com/stat?c=problem_statement&pm=4515) ( TCO 06 Online Round 2 )  \n[MarbleMachine](http://community.topcoder.com/stat?c=problem_statement&pm=8045) ( SRM 376 )  \n[DrivingAround](http://community.topcoder.com/stat?c=problem_statement&pm=7412) ( SRM 342 )  \n[PON](http://www.spoj.pl/problems/PON/)  \n[PRIC](http://www.spoj.pl/problems/PRIC/)  \n[SOLSTRAS](http://www.spoj.pl/problems/SOLSTRAS/)  \n[DIVSUM2](http://www.spoj.pl/problems/DIVSUM2/) \\[ this one also involves Pollard's Rho Algorithm \\]\n\n### References and Further Reading\n\n[http://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf](http://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf)  \n[http://security.ece.orst.edu/papers/j37acmon.pdf](http://security.ece.orst.edu/papers/j37acmon.pdf)  \n[http://icpc.baylor.edu/Past/icpc2004/RegReport/guan.cse.nsysu.edu.tw/data/montg.pdf](http://icpc.baylor.edu/Past/icpc2004/RegReport/guan.cse.nsysu.edu.tw/data/montg.pdf)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3InO6045JOvUIUWF4NcVNz"}}],"upvotes":1,"downvotes":0}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6gHA1WnDWUuz1ZtHAncxg3","type":"Entry","createdAt":"2020-04-20T12:42:14.533Z","updatedAt":"2020-04-20T12:42:14.533Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"majk","tcHandle":"majk"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6kIxt3XnHszjSpDpmJ0bqK","type":"Entry","createdAt":"2022-08-19T09:20:43.142Z","updatedAt":"2022-08-19T09:20:43.142Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Maryam Siddiqui","tcHandle":"maryamsidd"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6raiETCgPADnd17sRSKJSG","type":"Entry","createdAt":"2022-08-09T07:53:49.899Z","updatedAt":"2022-08-25T06:03:49.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","slug":"what-skills-do-you-need-to-be-a-graphic-designer-2","type":"Article","trackCategory":["Design"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5W8yVIchiseIGTWrWKXN57","type":"Entry","createdAt":"2019-09-18T07:36:54.570Z","updatedAt":"2023-09-06T19:01:10.075Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Design"}}],"tags":["Learn","Graphic Design"],"creationDate":"2022-08-08","readTime":"8min","content":"Graphic designers use visuals to communicate and make visual notions by hand or with computer tools. Through both real and virtual art forms, they can provide suggestions for inspiring, motivating, or enhancing consumers. Professionals in graphic design work on various projects, including brochures, print ads, and logos.\n\n### Evolution of Graphic Design\n\nIt isn't easy to envision life in the present era without graphic design because society encompasses so many aspects of it. Though it has been a long trip from stone tools to digital tablets, visual communication is roughly as old as our opposable thumbs, so in some respects, we never have lived without graphic design. In summary, the history of graphic design is a narrative that spans all of human history and can both inform and inspire contemporary graphic artists.\nGraphic design has evolved starting with cave paintings, then the origin of the printing press, the pre-digital era, and now the digital age. Graphic design has come a long way. As it evolves over time the skill sets are also changing.\n\n### Skill Set of Graphic Designers\n\nIn today's fast, ever-changing world, graphic designers need technical and soft skills. Your industry-specific professional knowledge and competencies are the foundation for your technical skills. Technological requirements are constantly changing; your current technical abilities might not be enough for the work you'll be requested to complete tomorrow. That's where soft skills come into play. Teamwork, effective communication, problem-solving, leadership, decisiveness, time management, and flexibility are examples of soft skills that are highly valued.\n\nLet's look more deeply into the technical and soft skills that graphic designers need in today's world.\n\n### Technical Skills\nEmployers seek out adaptable graphic designers with the necessary technical know-how to start immediately. Some of the most sought-after technical abilities for a graphic designer are the following:\n\n#### Typography skills\nThe visual representation of words and phrases is known as typography. The actual job of a graphic designer is to arrange words and letters in a visually appealing way. Typography skills work to combine the principles of visual design, font, lettering, color, and several other aspects of print writing to create banners, billboards, signs, magazine articles, website content, letters and letterheads, and many other print and writing applications\n\n#### Font selection\nThe graphic designer must be able to select the right font for each project. You must be able to choose the right font for each project, considering font style, size, and weight. All affect how your designs seem and may change how readers interpret your content.\n\n#### Design principles\nKnowing the design principles is a must-have trait for a graphic designer. Successful graphic designers understand how to balance designs using white space, color, hierarchy, and other design elements. For instance, during each project, a graphic designer must be able to select the appropriate color scheme. In contrast to RGB, which is frequently used for digital designs, CMYK is best for print projects.\n\nAlong with design principles, standards used to decide how a brand will be presented to audience members are called branding guidelines. You must be able to adhere to these rules strictly if you want to excel in the field.\n\n#### UX design\nUX design is the bridge between design and the front-end development team. The user interface, or UI, is a term that is generally understood. The screen that a person interacts with, such as while using a website or app, is most frequently the user interface. UX refers to the overall experiences a customer gets when utilizing a product or service, including UI. Graphic designers with UX experience know how to produce straightforward layouts that are practical and adhere to recognized accessibility standards.\n\n#### Digital technology (HTML, CSS, JS)\nThis skill is not required but is an optional one. Knowledge of HTML, CSS, and JavaScript is included in this. You should be familiar with well-known JavaScript libraries like React. Testing, debugging, build tools, and dependency managers may also be included.\n\nIt is significant to highlight that the position necessitates in-depth CSS knowledge. This might include using preprocessors like Sass and Less or the CSS architecture. Experience with CSS-in-JS libraries like Styled Components and Emotion is advantageous.\nThese skills will definitely help you if you plan to design websites or work as a graphic designer.\n\n#### Photography skills/photo editing\nIt's crucial to know how to edit stock pictures or take excellent photos because you might need to include photos in your graphic design work.\n\n### Soft Skills\n\nNo matter how strong your technical abilities, if you lack the soft qualities that companies value, it will be difficult for you to thrive in the design industry. Soft skills are character attributes that, as previously mentioned, can help you thrive in any industry. You can collaborate with others, communicate clearly, and establish a good rapport with clients and coworkers if you possess these qualities. The following soft skills are necessary for graphic designers.\n\n#### Collaboration skills\nWorking with people to achieve a shared objective is simple when one possesses strong collaboration abilities. A good collaborator pays attention to others, communicates well, and accepts responsibility for their errors.\n\n#### Emotional intelligence\nIndividuals with high emotional intelligence are masters at controlling their feelings, which enables them to solve problems and relieve stress from their team members.\n\n#### Communication skills\nEffective communication with coworkers, clients, and other stakeholders is essential. Graphic designers with good communication skills who can articulate their ideas concisely and consistently are always in demand by potential employers.\n\n#### Time management\nSince deadlines are a big part of graphic design, time management skills are necessary.\n\n#### Creativity \nThe potential to come up with fresh notions and apply them to problems or interpersonal communication is referred to as creativity. Successful graphic designers have a strong sense of creativity and originality.\n\n#### Storytelling\nStorytelling is a terrific approach to learn what your audience needs and how your organization may meet those needs if you're attempting to appeal to a particular demographic. The ability to tell a story is extremely useful for graphic designers tasked with creating enduring brand identities.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1i786NVOB6KrgH8WIjNA5o","type":"Asset","createdAt":"2022-08-08T17:15:51.156Z","updatedAt":"2022-08-08T17:15:51.156Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1i786NVOB6KrgH8WIjNA5o/f4c8f049da0a86b350b2d0871784b97b/What_Skills_do_you_Need_to_be_a_Graphic_Designer","details":{"size":79753,"image":{"width":640,"height":640}},"fileName":"What Skills do you Need to be a Graphic Designer?.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"12QIad2hrziFxOyUtzHw3V"}},{"sys":{"type":"Link","linkType":"Entry","id":"5QU9Tsl9cEHOJC50UvGdIl"}},{"sys":{"type":"Link","linkType":"Entry","id":"6TVx3UYkm6bWDe223mn0XP"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6vT0Zl3IZ6hSMvMgCLqQa5","type":"Entry","createdAt":"2020-04-20T12:42:15.893Z","updatedAt":"2020-04-20T12:42:15.893Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"espr1t","tcHandle":"espr1t"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70YxrEsN7e5v9oDe58CoZA","type":"Entry","createdAt":"2020-02-19T07:56:51.990Z","updatedAt":"2022-05-31T13:27:51.562Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":158,"revision":17,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs: Extras and FAQs","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["FAQ","SRMs","Arena","C/C++","JAVA"],"creationDate":"2020-02-19","readTime":"15 min","content":"### Extras\n##### Local Firewall and Network Considerations\nThe following port access will be necessary in order to run the Topcoder Arena: __Outbound access to www.topcoder.com on port 5001__.\n\n__HTTP Tunneling__ While running on your machine, the Topcoder Arena will need to create a direct socket connection to the Topcoder competition server. In order for this to function properly, your local networking environment must allow outbound TCP connections to www.topcoder.com on port 5001. Since port 5001 is a non-standard port, many firewalls will not allow this access. If you do not have control over allowing this access, your only option will be to run the Arena utilizing HTTP tunneling.\n\nBy selecting either the HTTP Tunneling option on the Arena login screen, all network traffic to and from the Topcoder competition server will be wrapped as if it were standard HTTP traffic on a standard port (port 80). This should resolve most firewall issues. However, you should only utilize the tunneling option if it is necessary since the performance of the Arena will be significantly slower while the tunneling option is being utilized. HTTP Tunnel A is faster than HTTP Tunnel B but may not work on all connections. We suggest you try them in order (Direct, Tunnel A, Tunnel B), or use the Autodetect button to automate this process.\n\n##### Chatting in the Arena\nIn each room there is a place to chat. You can communicate with the others in the room by simply typing in the chat line at the bottom of the screen. There are a number of features to make chatting easier.\n\nNext to the chat line, you will find a box populated with a \">>\". Clicking on this box will expand your chat options and present two dropdown lists. The first list represents the type of chat message, while the second contains a list of the handles of all coders currently in the room.\n\n__General Chat__ The most basic form of chat is the \"General\" chat, which will simply allow you to type in a message. A general chat message will be sent to all the coders currently in that room. The general chat message type is equivalent to simply typing a message in the chat line without the chat feature box expanded.\n\n__Reply To__ When the chat gets busy in a specific room, it can be helpful to address a specific person with a chat message. Using the \"ReplyTo\" feature in the expanded chat box will allow you to choose a handle to which the chat message will be directed. A \"ReplyTo\" chat message is analogous to typing \"[handle]: this is the message\" on the chat line. The advantage of this is that the recipient of the message will see your chat as a highlighted message, indicating that the message is intended for them. A \"ReplyTo\" message will be seen by all coders who are currently in the room.\n\n__Whisper__ A whisper is a message that will be displayed to the recipient only. Choosing a whisper message type is the same as typing \"/whisper [handle] this is the message\" in the chat line. \"/msg\" can also be used in place of \"/whisper\". Whisper messages can also be used to communicate with coders who are in a different room than where you are. Keep in mind that any Topcoder administrators (the orange handles) will also see any messages that are whispered at any time.\n\n__Emoting__ On occasion, you may find it useful to convey an emotion in the chat area in the third person. Any time the string \"/me\" appears as the first part of a chat message, the \"/me\" will be replaced with your Topcoder handle and the message will appear to all users in italics. (i.e. \"/me is very happy\")\n\n##### Other Members In The Arena\n__Searching for a Member__ Using the \"Search\" feature under the \"Main Menu\" will allow you to enter a member's handle in order to find out if they are currently logged into the Arena and if so what room they are in. If the member is in fact currently logged in, you will be given the option of moving directly to the room they are in - without it being necessary to use the menus to navigate.\n\nYou may also use \"/find handle\" to locate another member in the Arena. If you wish to locate the assigned room for a given competitor - regardless of whether they are actually in that room, you have the option to use \"/room handle\" for information on that competitors assigned competition room.\n\n__Who is in the Arena now?__ The \"Active Users\" menu option under the \"Main Menu\" will provide you with a list of all Topcoder members who are currently logged in to the Arena. You may sort the list by either Topcoder handle or by rating by clicking on the column headings. In addition, by right clicking on any of the handles in this list you will have the option to either perform a search for that member or retrieve information for that member.\n\n##### This is where to find the statistics after an SRM match!\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on Topcoder's website. This includes both summary information regarding success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your Topcoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), Topcoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the Topcoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n##### Using pre-written code\nMany Topcoder participants find it useful to create code libraries for situations that commonly arise in Topcoder competitions. Doing such is perfectly legal - as long as the code used has been entirely authored by you. Use of any code other than that which has been authored by you is cheating (and you know how we feel about cheating). Keep in mind, however, that onsite rounds of Topcoder advancements tournaments are handled differently. On-site finalists of Topcoder advancement tournaments are not allowed to bring anything \"on stage\" - including code libraries.\n\nPasting large libraries of code into each submission with the intent of only using a small percentage (if any) is against the Excessive / Extra Code Rule.\n\n##### Arena Plugins\nThe Topcoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to install and use them, check [here](https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).\n\n### FAQ\n\nHere are a few answers to our most common questions\n\n##### There are no active SRMs now, is there a way to practice?\nThere absolutely is!\n\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the Topcoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: 1) exactly how to structure your class, 2) the various input and output types that are specific to your language, and 3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n__Timing in the Practice Room__\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase.\n\n__Selecting a Problem__\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, Topcoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n__System Testing__\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.\n\n__The Room Summary__\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n__Challenging__\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\nHere's a link for a description of the Challenge Phase during a rated event.\n\n__Clearing Problems__\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.\n\n##### How Are Rated Events Different Than Any Other Events?\n__When are the Rated Events?__\nTopcoder holds two types of rated events, Single Round Matches(SRMs) and advancement tournaments(The Topcoder Open). The day and time of SRMs varies from week-to-week. See the [event schedule](https://www.topcoder.com/community/events) on Topcoder's web site for the dates and times of future SRMs. Please keep in mind that all times on Topcoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. In addition, you may elect to receive a reminder email preceding each SRM. To do so, visit your [email settings](https://www.topcoder.com/settings/email/) and make sure the switch next to \"Data Science Newsletter\" is turned on. By checking this option, you will also receive emails regarding upcoming Topcoder tournaments and events.\n\nIn addition to SRMs, Topcoder holds two advancement tournaments (the Topcoder Open and the Topcoder Collegiate Challenge) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, which is why they are also considered \"rated events\". The details on each of these events are posted on Topcoder as they are finalized. You can also view the information and details of most [past tournaments](https://www.topcoder.com/community/hall-of-fame/tco).\n\n__How does a Rated Event Differ from the Practice Room?__\nThere are a number of differences - the biggest being that participating in a rated event will affect your Topcoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the Topcoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n__Division One versus Division Two__\nAt Topcoder, there are two divisions of competition. The specific division that you are in is dependant only on your Topcoder rating. If your Topcoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are not rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n##### Is it possible to get penalized points even if I passed system tests?\nTopcoder has a policy against including extra content in a submission that is not part of the solution to the problem. This includes, but is not limited to the following:\n- unused macros\n- unused #define's\n- unused typedef's\n- automatically generated code\n- testing code\n- unused personal library code\n- comments not directly related to the solution\n\nThe following things are __excluded__ from the rule (They are not considered unused):\n- Library import statements (#include, imports, using, Imports)\n- Comments identifying plugins used\n- Comments directly related to the solution (explaining algorithms, etc.)\n\nIn ALL cases, Topcoder will make the final decision as to whether or not a code submission has an excessive amount of unused content. __If Topcoder determines that a submission violates this policy, the competitor will receive 20% of the point value of the problem for that submission__. No challenges will be overturned or nullified as a result of a violation in this policy. We encourage any Topcoder competitor to notify us in the event that you feel that a code submission during a rated event violates this policy.\n\nIn an effort to help competitors determine how much extra content can be contained in a submission and still not violate this policy, we provide the following general guideline: You may have a maximum of 300 non-space characters that are considered extra content or a maximum of 30% of your submission be considered extra, whichever is greater.\n\n##### I'm having issues during a rated event, how do I get immediate help?\nAt some point during your Topcoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a Topcoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with Topcoder administrators without leaving your assigned competition room. At any time while in the Topcoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The Topcoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the Topcoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without others in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n##### How is my score calculated for a rated match?\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The Topcoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\n\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/eqORIq5itfcgAr7KbDESv/948621a58e3c2afdf962cc15526c9817/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\n\nFor example: A coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n\n500(.3 + .760^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n##### I don't agree with the results, what should I do?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify Topcoder of your concerns. Please send an email to support@topcoder.com explaining in detail what you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n##### Oh no, I got disconnected from the Arena, what do I do?\nYou may get disconnected from the Internet for various reasons. If you get disconnected from Topcoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n##### What if I suspect someone cheating?\nCheating is taken seriously at Topcoder. There are a number of ways in which you could cheat, and have your account deactivated by Topcoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, Topcoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n##### Is this a good way to measure the relative merit of programmers?\nThe ability to quickly code solutions to a set of somewhat simple algorithmic problems does not completely define a \"top\" programmer. However, our attempt to make Topcoder tournaments as objective as possible has initially lead us in this direction. We continuously discuss ways in which we might introduce code elegance, style, reusability, and other less objectively ratable elements into our tournaments. We'd love to hear any suggestions on how this might be accomplished.\n\n##### Who owns the source code that I write during tournaments?\nThe coder. Our Terms of Use agreement specifies that the coder who submits any source code to Topcoder owns the code, but by submitting any source code the coder agrees to license to Topcoder the right to use and publish such code. You can read the complete [Terms of Use agreement](https://www.topcoder.com/community/how-it-works/terms/).\n\n##### How does the rating system work?\nEach tournament round is an elimination round. Contestants survive to subsequent rounds by being the fastest to write working programs that accurately answer the challenge question(s). Ratings will then be adjusted by comparing the competitor's record against the other members. The details of the rating formula can be found [here](https://www.topcoder.com/community/competitive-programming/how-to-compete/rating-system).\n\n##### I'm having a problem with font properties on Linux platforms.\nApparently, Sun has a problem with their font.properties file on the Linux platform that is causing errors with some fonts (Arial is one of them). The fix is to replace the font.properties file with the following: http://java.sun.com/j2se/1.3/font.properties\n\n##### How is my submission judged?\n__Java__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Java test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time. At most 64 megabytes of memory may be mapped.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nEach Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET test is performed in a separate thread. The process is forcibly terminated after consuming 2 seconds of System time.\n\nIf your method does return a value, that is the only basis for judging correctness.\n\n__C++__\nTopcoder submissions typically consist of a single class definition. For each test, one instance of the class is constructed; then the method described in the problem is called with the test arguments. Therefore, your method must be public, and your class must be instantiable: public default constructor, no abstract methods, etc.\n\nC++ submissions may also define other classes and global variables or functions. However, defining main() will prevent your submission from linking, and referring to library globals (stdout or cout for example) before your method is called is not guaranteed to work as expected. Each C++ test is performed in a separate process. The instance of your class used by the tester is not guaranteed to be destroyed. The process is forcibly terminated after consuming 2 seconds of CPU time. At most 64 megabytes of memory may be mapped. Stack space is limited to 8 megabytes (the Linux default). Most system calls are emulated or ignored. Note especially that fork() or use of threads (library or kernel) will fail, and use of temporary files is not permitted.\n\nIf your method does not return before the process exits (due to exceeding the time limit, an uncaught exception, segmentation fault, divide by zero, etc), it has failed the test.\n\nIf your method does return a value, that is the only basis for judging correctness. Anything printed to stdout or stderr is ignored, although you will see it when testing your own code. Output may even return an IO error, and takes extra time during testing; you are advised not to leave unnecessary IO in your final submission.\n\n##### What hardware does Topcoder use?\n__Java__\nWe use 6 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n__C++__\nWe use 2 2-way 3.6 Ghz Pentium IV Xeon systems.\n\n##### What software does Topcoder use?\n__Java__\nLinux 2.4, Java 5.0 (build 1.5.0_03).\n\n__Microsoft® Visual C#® .NET or Microsoft® Visual Basic® .NET__\nMicrosoft Windows 2000 5.00.2195 SP2, .NET Framework version 2.0.50727\n\n__C++__\nLinux 2.4.20-8smp, gcc 4.0.2 (Redhat 9), glibc-2.3.2, and libstdc++-3. pointers to appropriate docs for each http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ http://www.gnu.org/software/libc/ http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html\n\n#### Java - What options are set when starting up the VM?\n\n```\njava -client -Xmx64m <main class>\n```\n\n##### C# or VB - What do I need to import to use standard <k>VB.NET</k> functions?\nYou need to import \"Imports Microsoft.VisualBasic\"\n\n##### C# or VB - Why is my stack trace reporting strange/incorrect line numbers?\nBecause we compile with optimization on, the compiler will sometimes rearrange and optimize functions in such a way that line numbers no longer match the original source code. We recommend you add Console.WriteLine() statements to help debug the problem if necessary.\n\n##### C++ - What compiler options are used?\nThe compiler is invoked as: g++ -Wall -W -O2 -s -pipe Additional info on gcc 3.1 http://gcc.gnu.org/bugs.html#updating\n\n##### C++ - What libraries are available?\nOnly default libraries will be linked with your code. Math functions requiring libm on some platforms, eg cos(), are automatically linked if needed.\n\n##### C++ - How do i get 64-bit integers?\nInteger types on our platform: char - 8 bits (signed) short - 16 bits int - 32 bits long - 32 bits long long - 64 bits long long is not merely a gcc extension, but part of ISO C99. If you test locally with a compiler other than gcc, the preprocessor may be useful for hiding the differences. For example:\n```\n#ifdef __GNUC__\n#define int64 long long\n#else /* MSVC, say */\n#define int64 __int64\n#endif\n```\n\nIn this way, you can test the same code using 64 bit integers in our environment and on your system. The C++ standard libraries do not include support for arbitrary precision arithmetic.\n\n##### C++ - What STL types are available?\nAll of the standard value types and container types should be present. Some extensions are also present, including most of those from SGI's STL, such as rope, hashset, hashmap, tree, slist, etc.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"ygtVtuUwUsPmuo5pjV9Zf"}}],"upvotes":7,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3YeSXGR5CUPgq9NkzBGOdr","type":"Entry","createdAt":"2020-02-18T16:57:29.425Z","updatedAt":"2022-04-15T18:52:30.540Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1370,"revision":116,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How To Compete in SRMs","type":"Article","trackCategory":["Competitive Programming","Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["How-To"],"creationDate":"2020-02-18","readTime":"30 min read","content":"Algorithm competitions on Topcoder take the form of SRMs, or Single Round Matches. The matches last for around one and a half hours, with a 75 minute coding phase. There are usually three SRMs within a month.\n\nEach SRM will have a number associated with it, such as SRM 730. Topcoder SRMs are a lot of fun and quite exciting. This guide will walk you through the things you need to know to compete in an SRM and is a great reference for any other time you need it. Feel free to follow the written instructions below.\n\nYou can find the dates for the next SRMs from the [Event Calendar](https://www.topcoder.com/community/events), and practice on past problems in [the Arena](https://www.topcoder.com/community/arena).\n<style>.links-grid{display:grid;grid-template-columns:300px 1fr;gap:0;}@media (max-width:768px){.links-grid{grid-template-columns:1fr 1fr;}}</style>\nImportant links:\n<div class=\"links-grid\">[Arena info page](https://www.topcoder.com/community/arena)[Problem Archive](https://www.topcoder.com/tc?module=ProblemArchive)[Web Arena](https://arena.topcoder.com/)[Match Editorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=SRM%20Editorials)[Java Applet Arena](http://topcoder.com/contest/arena/ContestAppletProd7.2.jnlp)[SRM Statistics](https://www.topcoder.com/community/statistics)[Competitive Programming Tutorials](https://www.topcoder.com/thrive/tracks?track=Competitive%20Programming&tax=Tutorials)[Record Book](https://community.topcoder.com/tc?module=Static&d1=statistics&d2=recordbook_home)[Match Archive](https://www.topcoder.com/tc?module=MatchList)</div>\n\n<h3 id=\"0\">Overview</h3>\n\nAn SRM competition consists of three different problems of increasing difficulty. After the coding phase, there is a chance to \"challenge\" the code of other competitors for extra points by finding a test case where their solution fails.\n\nSpecifically, the phases associated with each competition are:\n* **Registration Phase**\nThis is when the competitors are able to register for the competition. Open until five minutes before the competition.\n* **Coding Phase**\nThe phase when the competitors are given the problems and write their solutions. The duration is 75 minutes.\n* **Intermission Phase**\nA short break - have a breather, get yourself a drink, prepare for the next phase. Duration: 5 minutes.\n* **Challenge Phase**\nCompetitors are given access to the solutions by other competitors within their room and can challenge each others' solutions. This phase lasts for 15 minutes.\n* **System Test Phase**\nThe final phase when extensive test sets are run against the solutions to fully determine which solutions pass for the problems.\n\nRead below for detailed instructions on each of these, but first, choose your arena!\n\n### Step by Step\n- <AnchorLink href=\"#1\">Choose Your Arena</AnchorLink>\n- <AnchorLink href=\"#2\">The Applet Arena</AnchorLink>\n- <AnchorLink href=\"#3\">Registering For An SRM</AnchorLink>\n- <AnchorLink href=\"#4\">Things To Know Before Competing</AnchorLink>\n- <AnchorLink href=\"#5\">Competing In The Match</AnchorLink>\n- <AnchorLink href=\"#6\">Competing In The Match - The Challenge Phase</AnchorLink>\n- <AnchorLink href=\"#7\">Competing In The Match - System Testing Phase</AnchorLink>\n- <AnchorLink href=\"#8\">After The Match</AnchorLink>\n\n<h3 id=\"1\">Choose Your Arena</h3>\n\nCurrently, there are two types of arenas that you can use to compete in Topcoder SRMs: the web arena and the applet arena. The applet arena has been around for 15+ years, has a richer functionality, and provides a better overall experience but it requires some extra setup.\n\nThe web [arena](https://arena.topcoder.com/) requires no special setup since it is just a regular web page. Its functionality is limited however as it doesn't support any editor plugins and it is still in beta mode at the time of writing. When successfully logged into the web arena, you should see something like this:\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/56OiB27RDqiOQMiok4au6i/8335969d0e8eebd3e8ce8f51d13728b2/1-CP.png)\n\nMost experienced competitors use the applet arena and it is also used at the Topcoder Open onsite finals.\n\n<h3 id=\"2\">The Applet Arena</h3>\n\nTo launch the applet arena, you need to make sure you have a Java runtime environment installed. You can get that [here](http://java.com/en/download/index.jsp).\n\nOnce you have completed that, you may click [here](http://community.topcoder.com/contest/arena/ContestAppletProd.jnlp) to download the Applet Arena.\n\nWhen the arena has finished downloading, you will get a security warning dialog and you will have to check the checkbox below before you can run the arena. Once it's checked, click the run button. [You may also follow the instructions on the arena info page to include an exception for Topcoder in your Java configuration.](https://www.topcoder.com/community/arena)\n\n![1-CP](https://images.ctfassets.net/b5f1djy59z3a/5uW6TiYe5yCUIQeOE6AQsu/1785462d8bbbe85ef9bd5acce9158cb9/1-CP.png)\n\nFinally, you'll get the arena login screen. Type in your Topcoder handle for the username and then type in your password to login. If you run into any problems, be sure to send an email to support@topcoder.com.\n\n__Note:__ *If you are behind a firewall or corporate proxy and cannot login using the \"Direct\" option, you can try changing the connection settings to HTTP Tunnel A, HTTP Tunnel B, etc. These don't always work, and in some cases it may be impossible to login to the arena when certain network restrictions are present.*\n\n*Please view \"__Local Firewall and Network Connections__\" in \"Extras\" below for more information.*\n\n![2-CP](https://images.ctfassets.net/b5f1djy59z3a/BVn29SST8yyiogyyq8Uak/cff643414922836297e7e2ea42a7afbb/2-CP.png)\n\nIf you are logged in successfully you will see the Arena home screen as seen below:\n\n![3-CP](https://images.ctfassets.net/b5f1djy59z3a/3PZSJSq6lOA0YMwgYWuSkY/a6faaed996f782e19662cd2ab8e4b163/3-CP.png)\n\n<h3 id=\"3\">Registering For An SRM</h3>\n\nIn order to compete in an SRM, the first thing you must do is register for it. Registration will typically begin 4 hours prior to the SRM start time and it will end 5 minutes before the SRM start time. If you are just one minute late you will not be able to register, so it is important to register on time.\n\nTo register for an SRM in the applet arena, go to the Active Contests dropdown, choose the SRM, and then select the Register button. If you do not see any active contests listed then make sure you have the correct date.\n\n![5-CP](https://images.ctfassets.net/b5f1djy59z3a/5TiZJT0aWsQqeQw6wo668C/71189fa147660e6c125bcb8b5f60efdc/5-CP.png)\n\n__Note:__ *The register option is disabled in this screenshot since the match is over, but in a real match it would be enabled*\n\nThe web arena is similar, and should have a register button after you login.\n\n![6-CP](https://images.ctfassets.net/b5f1djy59z3a/3hXgpCDmnuoECWMaeqkMi4/d2d4cdf38bea39ef0c813a2fa621ef83/6-CP.png)\n\nYou may get some additional dialogs asking you to agree to terms, etc., and you'll need to accept those in order to register for the match.\n\n<h3 id=\"4\">Things To Know Before Competing</h3>\n\n__How many are registered?__\nIf you want to view how many people are registered, you can go to Active Contents -> Registrants (if using the applet arena).\n\n__What do I need to know about divisions and ratings?__\nEach SRM has two divisions, and the 1st division is composed of competitors with a rating of 1200 or above. New competitors or those with ratings of 1199 and below compete in division 2. The divisions are designed to ensure that competitors get a proper problem set based on their current skill level. Each time you compete, your rating will usually go up or down depending on how you performed in the match. It can also stay the same.\n\n*Note that even if you register for a match but don't open any problems or issue any challenges, your rating will not change and it will calculate as if you hadn't competed in the match.*\n\n__I'm assigned to a room, what does that mean?__\nOnce registration closes, each competitor will be assigned to a \"room\". It's not really important to know your room number, as this is just a grouping that Topcoder uses to assign competitors. There will typically be 20 competitors assigned to a room. You can use the Active Contents->Enter menu (applet arena) to enter your room.\n\n*Note that the \"Enter\" option will be disabled until the room assignment algorithm completes, which usually takes about 1-2 minutes after registration closes.*\n\nFor the web arena, you will see an Enter button, and you can click that button to enter your room.\n\n![image029](https://images.ctfassets.net/b5f1djy59z3a/uHHqF8BWXmEgUkk8oq2yu/ba548224d7e4dc983868236d4cd1de66/image029.png)\n\nWhile you're waiting for the match to begin, it's a good idea to see what the point values are for the problems. An SRM will typically have 3 problems with varying degrees of difficulty. The point spread for the 3 problems is typically 250 points for the first problem, 500 points for the second problem, and 1000 points for the third problem. This point spread can be different however (depending on whether a problem is easier or harder) and often is. You can see the points for the three problems in the applet arena by clicking the dropdown shown below.\n\n![image035](https://images.ctfassets.net/b5f1djy59z3a/mAY2OlR8YKoWSuQm6CUaY/03ad1f5197a24e283cdb9d0cdf895e6f/image035.png)\n\nOnce the coding phase starts, you can use this same dropdown to open a problem. In the web arena, you won't have a dropdown, but will see the problems listed with their point values as shown below.\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/2ysaST7JaoyW4kEmIiIy4a/7e9ec0fffc1097596b31763a7ec17c30/8-CP.png)\n\n<h3 id=\"5\">Competing In The Match</h3>\n\nOnce you've entered your room, you can just wait for the contest to begin. There will be a competition status window that will show you how much time is left until the contest begins (applet arena). Once the coding phase starts, it will show how much time is left for coding, etc. You can use this window to know how much time is left in any phase.\n\nIn this screenshot, the contest is complete but in a live match it would show you how much time there is before the coding phase begins.\n\n![7-CP](https://images.ctfassets.net/b5f1djy59z3a/5frPVHkOVqY8A0gW0soW8m/07ed3d3f0e694161d28a55dbaf35692e/7-CP.png)\n\nThe Web Arena will have a countdown as well:\n\n![8-CP](https://images.ctfassets.net/b5f1djy59z3a/481NoUQMLSKW8iAcGq0q2I/bfb085dd7efa5f095a79fa8f5aa59e68/8-CP.png)\n\nOnce the coding phase begins, you'll get a popup saying the coding phase is beginning in the applet arena. In the web arena, you'll see links beside the problem that say \"Unopened\". You can click the Unopened link to open a problem.\n\nNote that Topcoder is all about speed and accuracy. It is important to be fast, but it is more important to be right. If your problem fails any of the test cases the problem writer has created or fails a challenge case from another competitor (more on this later), you get 0 points for that problem.\n\nOnce you open a problem, you will see the problem statement. At this time, the problem timer starts and the point value for the problem begins to decrease. So the longer it takes you to solve the problem, the less points you will receive.\n\n![11-CP](https://images.ctfassets.net/b5f1djy59z3a/8S43MbfC24gwQIGO8eIOa/19cb68ea99f54ac3fea9ab8fa94362fa/11-CP.png)\n\nPay close attention to the definition section of the problem statement, as this section will tell you how the class needs to be declared and the method name.\n\n![12-CP](https://images.ctfassets.net/b5f1djy59z3a/3tEWJTHrtCoU0EasY4muMg/0505399c80e4e836fd458657acb7eeda/12-CP.png)\n\nSo in this example, if we were coding in C++ we would declare something like what you see below.\n\n```\nclass RingLex {\n  public:\n\tstring getmin(string s) {\n  \tstring ret = \"\";\n  \t// code your solution for the problem here\n  \treturn ret;\n\t}\n}\n```\n\n*Note that our class name and method name match the definition values shown above, and case matters. It's very important to get this exactly right, otherwise, your solution will fail!*\n\nYou will also need to look at the constraints for the problem, which will tell you important information about the inputs, outputs, time limit for the problem, etc. For example, if N has a max value of 5,000,000,000, then you may have to code a very different solution than if N has a max value of 50.\n\n![13-CP](https://images.ctfassets.net/b5f1djy59z3a/3dpmZcxwvYMcCEgiGOiicm/49343039b31ce79f09130a1c489f049c/13-CP.png)\n\nIf you want to change the coding language, you can use the options at the top right of the coding window (applet arena). In the web arena, you can use the gear icon which will bring up a dropdown where you can choose the language.\n\nOnce you have coded your solution, you can use the compile button to make sure it compiles successfully. After you've compiled your solution successfully, you can test it against the example cases or you can also create your own test cases (highly recommended). Use the Test button (applet arena) or Test Panel (web arena) to test your solution. To test with one of the example cases, you can choose the test case in the drop down you want to test with. Below is a screenshot from the applet arena where we are testing example 0.\n\n![14-CP](https://images.ctfassets.net/b5f1djy59z3a/3jlLZJmzReyAUqU42GuYI0/3261d50dddfa2c027aa8f37201ead23b/14-CP.png)\n\nIf you want to use your own custom test case, then you can change the values in the test dialog. In the above example, we could enter in different values for variables n and k. Once you are satisfied with your solution, then you need to submit it, which you can do by clicking the submit button. Don't forget this step! If you fail to submit your problem, then you will receive 0 points for it.\n\n*Tip: Be sure to test your solution and make sure you are satisfied with it before you submit. You can submit again if you find a bug after your submit, but there is a 10% penalty in your points if you do this.*\n\n<h3 id=\"6\">Competing In The Match - The Challenge Phase</h3>\n\nOnce the coding phase is complete, there is usually a 5 minute intermission. Use this time to catch your breath, get something to drink, or even better - prepare challenge cases for the challenge phase.\n\nIf you found a particularly tricky corner case to a problem, this is a great time to put that test case to use as there is a chance that other competitors didn't think of it.\n\nIn the challenge phase, you can view other competitors' code. In the applet arena, click the Summary button to view a list of all the problems submitted in your room.\n\n![15-CP](https://images.ctfassets.net/b5f1djy59z3a/6SGDQnhY2IWuUkwoqMKaK4/8c8deaab486bfbeb638de3d996c27a32/15-CP.png)\n\nAfter you click __Summary__, you'll see a list of the problems and their point values for each competitor's submission.\n\n![16-CP](https://images.ctfassets.net/b5f1djy59z3a/3DUM2xy7AsqcAAUsSsuaMu/40e0899fb8e3c111659202fbd8276bda/16-CP.png)\n\nThe web arena is slightly different, but the same concept. In both the web arena and applet arena, you can click on the point value for a competitor's problem to open that problem\n\nIf you find what you think to be a bug with their code, then you can press the challenge button and try to challenge it. You enter the challenge case in the challenge window before pressing the challenge button.\n\n![17-CP](https://images.ctfassets.net/b5f1djy59z3a/6llTTNA70Qakm0Q0I0okIy/1e422954df7340c2cc9fa2d7fa80fd07/17-CP.png)\n\nOnce you submit your challenge, the system will tell you if your challenge was successful or unsuccessful.\n\nHere are some important points to remember about the challenge phase:\n- You cannot challenge a solution that has already been successfully challenged.\n- A successful challenge increases your score by 50 points.\n- An unsuccessful challenge decreases your score by 25 points.\n- As long as your score is non-negative, you can challenge (this means you can challenge even if you didn't submit a problems).\n- Once your score becomes negative, you can no longer challenge. So if you challenge with a 0 score and fail, your score will become -25 and you will no longer be able to challenge.\n\n<h3 id=\"7\">Competing In The Match - System Testing Phase</h3>\n\nOnce the challenge phase ends, then the system test begins. All solutions that have not been challenged successfully will be run against the system tests. If a given problem fails any of the system tests, then that competitor will receive 0 points for that problem. If all the system tests for a problem pass, then the competitor will receive the points for that problem and they will be added to their match total. You can view the results for the match by going to Active Contests->Division Summary.\n\nAs shown below, you can see which problems passed or failed system tests, and also which problems were challenged.\n\n![18-CP](https://images.ctfassets.net/b5f1djy59z3a/6CdBhDQM4oO282QUU2KiUG/80d29a4e48c5b6575ac11914ca23edcb/18-CP.png)\n\n<h3 id=\"8\">After The Match</h3>\n\nOnce the match is over (system testing phase is completed), your rating will be updated. This usually takes anywhere from 5-15 minutes after the system tests finish. To see your new rating, you need to log off and log back into the arena. The statistics in your profile on the Topcoder web site will also show the new rating, but this can take up to several hours.\n\nTo get to your rating graph, you can click My Profile on the web site. Click your handle in the upper right to get this list of buttons to display.\n\n![19-CP](https://images.ctfassets.net/b5f1djy59z3a/6GFgKfOPde2mwOegCGmIAW/852bdb0ee6555dd2b3fc4b3863253dc1/19-CP.png)\n\nYou can view your rating graph to see how you are doing over time, how many matches you've competed in, your percentile, and other statistics.\n\n![20-CP](https://images.ctfassets.net/b5f1djy59z3a/40H5Ve8caQwMsaOwQSuKK0/14305e0e55dc272ac11e73bb40e2e1fd/20-CP.png)\n\n<ThemedButton theme=\"tc-primary-green-lg\" to=\"https://www.topcoder.com/thrive/articles/How To Compete in SRMs: Extras and FAQs\">How To Compete in SRMs: Extras and FAQs</ThemedButton>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5EAFqYlQg1pHLvEHQ4yXFx","type":"Entry","createdAt":"2019-08-28T07:21:52.009Z","updatedAt":"2021-12-20T08:32:58.225Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":14,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Topcoder"}}],"upvotes":60,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"70YxrEsN7e5v9oDe58CoZA","circular":true}}]}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"70ppAv0WygqfWWlipllAZu","type":"Entry","createdAt":"2020-02-20T15:37:44.048Z","updatedAt":"2022-02-13T10:37:14.930Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":372,"revision":78,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Data Structures","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Data Structures","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505847)\n<br/>\nEven though computers can perform literally millions of mathematical computations per second, when a problem gets large and complicated, performance can nonetheless be an important consideration. One of the most crucial aspects to how quickly a problem can be solved is how the data is stored in memory.\n\\\nTo illustrate this point, consider going to the local library to find a book about a specific subject matter. Most likely, you will be able to use some kind of electronic reference or, in the worst case, a card catalog, to determine the title and author of the book you want. Since the books are typically shelved by category, and within each category sorted by author’s name, it is a fairly straightforward and painless process to then physically select your book from the shelves.\n\\\nNow, suppose instead you came to the library in search of a particular book, but instead of organized shelves, were greeted with large garbage bags lining both sides of the room, each arbitrarily filled with books that may or may not have anything to do with one another. It would take hours, or even days, to find the book you needed, a comparative eternity. This is how software runs when data is not stored in an efficient format appropriate to the application.\n<br/><br/>\n### Simple Data Structures\nThe simplest data structures are primitive variables. They hold a single value, and beyond that, are of limited use. When many related values need to be stored, an array is used. It is assumed that the reader of this article has a solid understanding of variables and arrays.\n\\\nA somewhat more difficult concept, though equally primitive, are pointers. Pointers, instead of holding an actual value, simply hold a memory address that, in theory, contains some useful piece of data. Most seasoned C++ coders have a solid understanding of how to use pointers, and many of the caveats, while fledgling programmers may find themselves a bit spoiled by more modern “managed” languages which, for better or worse, handle pointers implicitly. Either way, it should suffice to know that pointers “point” somewhere in memory, and do not actually store data themselves.\n\\\nA less abstract way to think about pointers is in how the human mind remembers (or cannot remember) certain things. Many times, a good engineer may not necessarily know a particular formula/constant/equation, but when asked, they could tell you exactly which reference to check.\n<br/><br/>\n### Arrays\nArrays are a very simple data structure, and may be thought of as a list of a fixed length. Arrays are nice because of their simplicity, and are well suited for situations where the number of data items is known (or can be programmatically determined). Suppose you need a piece of code to calculate the average of several numbers. An array is a perfect data structure to hold the individual values, since they have no specific order, and the required computations do not require any special handling other than to iterate through all of the values. The other big strength of arrays is that they can be accessed randomly, by index. For instance, if you have an array containing a list of names of students seated in a classroom, where each seat is numbered 1 through n, then studentName[i] is a trivial way to read or store the name of the student in seat i.\n\\\nAn array might also be thought of as a pre-bound pad of paper. It has a fixed number of pages, each page holds information, and is in a predefined location that never changes.\n<br/><br/>\n### Linked Lists\nA linked list is a data structure that can hold an arbitrary number of data items, and can easily change size to add or remove items. A linked list, at its simplest, is a pointer to a data node. Each data node is then composed of data (possibly a record with several data values), and a pointer to the next node. At the end of the list, the pointer is set to null.\n\\\nBy nature of its design, a linked list is great for storing data when the number of items is either unknown, or subject to change. However, it provides no way to access an arbitrary item from the list, short of starting at the beginning and traversing through every node until you reach the one you want. The same is true if you want to insert a new node at a specific location. It is not difficult to see the problem of inefficiency.\n\\\nA typical linked list implementation would have code that defines a node, and looks something like this:\n<br/>\n```\nclass ListNode {\nString data;\nListNode nextNode;\n}\nListNode firstNode;\n```\n\\\nYou could then write a method to add new nodes by inserting them at the beginning of the list:\n<br/>\n```\nListNode newNode = new ListNode();\nNewNode.nextNode = firstNode;\nfirstNode = newNode;\n```\n\\\nIterating through all of the items in the list is a simple task:\n<br/>\n```\nListNode curNode = firstNode;\nwhile (curNode != null) {\nProcessData(curNode);\ncurNode = curNode.nextNode;\n}\n```\n\\\nA related data structure, the doubly linked list, helps this problem somewhat. The difference from a typical linked list is that the root data structure stores a pointer to both the first and last nodes. Each individual node then has a link to both the previous and next node in the list. This creates a more flexible structure that allows travel in both directions. Even still, however, this is rather limited.\n<br/><br/>\n### Queues\nA queue is a data structure that is best described as “first in, first out”. A real world example of a queue is people waiting in line at the bank. As each person enters the bank, he or she is “enqueued” at the back of the line. When a teller becomes available, they are “dequeued” at the front of the line.\n\\\nPerhaps the most common use of a queue within a topcoder problem is to implement a Breadth First Search (BFS). BFS means to first explore all states that can be reached in one step, then all states that can be reached in two steps, etc. A queue assists in implementing this solution because it stores a list of all state spaces that have been visited.\n\\\nA common type of problem might be the shortest path through a maze. Starting with the point of origin, determine all possible locations that can be reached in a single step, and add them to the queue. Then, dequeue a position, and find all locations that can be reached in one more step, and enqueue those new positions. Continue this process until either a path is found, or the queue is empty (in which case there is no path). Whenever a “shortest path” or “least number of moves” is requested, there is a good chance that a BFS, using a queue, will lead to a successful solution.\n\\\nMost standard libraries, such the Java API, and the .NET framework, provide a Queue class that provides these two basic interfaces for adding and removing items from a queue.\n\\\nBFS type problems appear frequently on challenges; on some problems, successful identification of BFS is simple and immediately, other times it is not so obvious.\n\\\nA queue implementation may be as simple as an array, and a pointer to the current position within the array. For instance, if you know that you are trying to get from point A to point B on a 50×50 grid, and have determined that the direction you are facing (or any other details) are not relevant, then you know that there are no more than 2,500 “states” to visit. Thus, your queue is programmed like so:\n<br/>\n```\nclass StateNode {\nint xPos;\nint yPos;\nint moveCount;\n}\n\n\nclass MyQueue {\nStateNode[] queueData = new StateNode[2500];\nint queueFront = 0;\nint queueBack = 0;\n\n\nvoid Enqueue(StateNode node) {\nqueueData[queueBack] = node;\nqueueBack++;\n}\n\n\nStateNode Dequeue() {\nStateNode returnValue = null;\nif (queueBack > queueFront) {\nreturnValue = queueData[queueFront];\nQueueFront++;\n}\nreturn returnValue;\n}\n\n\nboolean isNotEmpty() {\nreturn (queueBack > queueFront);\n}\n}\n```\n\\\nThen, the main code of your solution looks something like this. (Note that if our queue runs out of possible states, and we still haven’t reached our destination, then it must be impossible to get there, hence we return the typical “-1” value.)\n<br/>\n```\nMyQueue queue = new MyQueue();\nqueue.Enqueue(initialState);\nwhile (queue.isNotEmpty()) {\nStateNode curState = queue.Dequeue();\nif (curState == destState)\nreturn curState.moveCount;\nfor (int dir = 0; dir < 3; dir++) {\nif (CanMove(curState, dir))\nqueue.Enqueue(MoveState(curState, dir));\n}\n}\n```\n<br/><br/>\n### Stacks\nStacks are, in a sense, the opposite of queues, in that they are described as “last in, first out”. The classic example is the pile of plates at the local buffet. The workers can continue to add clean plates to the stack indefinitely, but every time, a visitor will remove from the stack the top plate, which is the last one that was added.\n\\\nWhile it may seem that stacks are rarely implemented explicitly, a solid understanding of how they work, and how they are used implicitly, is worthwhile education. Those who have been programming for a while are intimately familiar with the way the stack is used every time a subroutine is called from within a program. Any parameters, and usually any local variables, are allocated out of space on the stack. Then, after the subroutine has finished, the local variables are removed, and the return address is “popped” from the stack, so that program execution can continue where it left off before calling the subroutine.\n\\\nAn understanding of what this implies becomes more important as functions call other functions, which in turn call other functions. Each function call increases the “nesting level” (the depth of function calls, if you will) of the execution, and uses increasingly more space on the stack. Of paramount importance is the case of a recursive function. When a recursive function continually calls itself, stack space is quickly used as the depth of recursion increases. Nearly every seasoned programmer has made the mistake of writing a recursive function that never properly returns, and calls itself until the system throws up an “out of stack space” type of error.\n\\\nNevertheless, all of this talk about the depth of recursion is important, because stacks, even when not used explicitly, are at the heart of a depth first search. A depth first search is typical when traversing through a tree, for instance looking for a particular node in an XML document. The stack is responsible for maintaining, in a sense, a trail of what path was taken to get to the current node, so that the program can “backtrack” (e.g. return from a recursive function call without having found the desired node) and proceed to the next adjacent node.\n\\\n[Soma](http://community.topcoder.com/stat?c=problem_statement&pm=2824&rd=5073) (SRM 198) is an excellent example of a problem solved with this type of approach.\n<br/><br/>\n### Trees\nTrees are a data structure consisting of one or more data nodes. The first node is called the “root”, and each node has zero or more “child nodes”. The maximum number of children of a single node, and the maximum depth of children are limited in some cases by the exact type of data represented by the tree.\n\\\nOne of the most common examples of a tree is an XML document. The top-level document element is the root node, and each tag found within that is a child. Each of those tags may have children, and so on. At each node, the type of tag, and any attributes, constitutes the data for that node. In such a tree, the hierarchy and order of the nodes is well defined, and an important part of the data itself. Another good example of a tree is a written outline. The entire outline itself is a root node containing each of the top-level bullet points, each of which may contain one or more sub-bullets, and so on. The file storage system on most disks is also a tree structure.\n\\\nCorporate structures also lend themselves well to trees. In a classical management hierarchy, a President may have one or more vice presidents, each of whom is in charge of several managers, each of whom presides over several employees.\n\\\n[PermissionTree](http://community.topcoder.com/stat?c=problem_statement&pm=3093&rd=5864) (SRM 218) provides an unusual problem on a common file system.\n\\\n[bloggoDocStructure](http://community.topcoder.com/stat?c=problem_statement&pm=3025&rd=5860) (SRM 214) is another good example of a problem using trees.\n<br/><br/>\n### Binary Trees\nA special type of tree is a binary tree. A binary tree also happens to be one of the most efficient ways to store and read a set of records that can be indexed by a key value in some way. The idea behind a binary tree is that each node has, at most, two children.\n\\\nIn the most typical implementations, the key value of the left node is less than that of its parent, and the key value of the right node is greater than that of its parent. Thus, the data stored in a binary tree is always indexed by a key value. When traversing a binary tree, it is simple to determine which child node to traverse when looking for a given key value.\n\\\nOne might ask why a binary tree is preferable to an array of values that has been sorted. In either case, finding a given key value (by traversing a binary tree, or by performing a binary search on a sorted array) carries a time complexity of O(log n). However, adding a new item to a binary tree is an equally simple operation. In contrast, adding an arbitrary item to a sorted array requires some time-consuming reorganization of the existing data in order to maintain the desired ordering.\n\\\nIf you have ever used a field guide to attempt to identify a leaf that you find in the wild, then this is a good way to understand how data is found in a binary tree. To use a field guide, you start at the beginning, and answer a series of questions like “is the leaf jagged, or smooth?” that have only two possible answers. Based upon your answer, you are directed to another page, which asks another question, and so on. After several questions have sufficiently narrowed down the details, you are presented with the name, and perhaps some further information about your leaf. If one were the editor of such a field guide, newly cataloged species could be added to field guide in much the same manner, by traversing through the questions, and finally at the end, inserting a new question that differentiates the new leaf from any other similar leaves. In the case of a computer, the question asked at each node is simply “are you less than or greater than X?”\n<br/><br/>\n### Priority Queues\nIn a typical breadth first search (BFS) algorithm, a simple queue works great for keeping track of what states have been visited. Since each new state is one more operational step than the current state, adding new locations to the end of the queue is sufficient to insure that the quickest path is found first. However, the assumption here is that each operation from one state to the next is a single step.\n\\\nLet us consider another example where you are driving a car, and wish to get to your destination as quickly as possible. A typical problem statement might say that you can move one block up/down/left/right in one minute. In such a case, a simple queue-based BFS works perfectly, and is guaranteed to provide a correct result.\n\\\nBut what happens if we say that the car can move forward one block in two minute, but requires three minutes to make a turn and then move one block (in a direction different from how the car was originally facing)? Depending on what type of move operation we attempt, a new state is not simply one “step” from the current state, and the “in order” nature of a simple queue is lost.\n\\\nThis is where priority queues come in. Simply put, a priority queue accepts states, and internally stores them in a method such that it can quickly pull out the state that has the least cost. (Since, by the nature of a “shortest time/path” type of problem, we always want to explore the states of least cost first.)\n\\\nA real world example of a priority queue might be waiting to board an airplane. Individuals arriving at their gate earlier will tend to sit closest to the door, so that they can get in line as soon as they are called. However, those individuals with a “gold card”, or who travel first class, will always be called first, regardless of when they actually arrived.\n\\\nOne very simple implementation of a priority queue is just an array that searches (one by one) for the lowest cost state contained within, and appends new elements to the end. Such an implementation has a trivial time-complexity for insertions, but is painfully slow to pull objects out again.\n\\\nA special type of binary tree called a heap is typically used for priority queues. In a heap, the root node is always less than (or greater than, depending on how your value of “priority” is implemented) either of its children. Furthermore, this tree is a “complete tree” from the left. A very simple definition of a complete tree is one where no branch is n + 1 levels deep until all other branches are n levels deep. Furthermore, it is always the leftmost node(s) that are filled first.\n\\\nTo extract a value from a heap, the root node (with the lowest cost or highest priority) is pulled. The deepest, rightmost leaf then becomes the new root node. If the new root node is larger than at at least one of its children, then the root is swapped with its smallest child, in order to maintain the property that the root is always less than its children. This continues downward as far as necessary. Adding a value to the heap is the reverse. The new value is added as the next leaf, and swapped upward as many times as necessary to maintain the heap property.\n\\\nA convenient property of trees that are complete from the left is that they can be stored very efficiently in a flat array. In general, element 0 of the array is the root, and elements 2k + 1 and 2k + 2 are the children of element k. The effect here is that adding the next leaf simply means appending to the array.\n<br/><br/>\n### Hash Tables\nHash tables are a unique data structure, and are typically used to implement a “dictionary” interface, whereby a set of keys each has an associated value. The key is used as an index to locate the associated values. This is not unlike a classical dictionary, where someone can find a definition (value) of a given word (key).\n\\\nUnfortunately, not every type of data is quite as easy to sort as a simple dictionary word, and this is where the “hash” comes into play. Hashing is the process of generating a key value (in this case, typically a 32 or 64 bit integer) from a piece of data. This hash value then becomes a basis for organizing and sorting the data. The hash value might be the first n bits of data, the last n bits of data, a modulus of the value, or in some cases, a more complicated function. Using the hash value, different “hash buckets” can be set up to store data. If the hash values are distributed evenly (which is the case for an ideal hash algorithm), then the buckets will tend to fill up evenly, and in many cases, most buckets will have no more than one or only a few objects in them. This makes the search even faster.\n\\\nA hash bucket containing more than one value is known as a “collision”. The exact nature of collision handling is implementation specific, and is crucial to the performance of the hash table. One of the simplest methods is to implement a structure like a linked list at the hash bucket level, so that elements with the same hash value can be chained together at the proper location. Other, more complicated schemes may involve utilizing adjacent, unused locations in the table, or re-hashing the hash value to obtain a new value. As always, there are good and bad performance considerations (regarding time, size, and complexity) with any approach.\n\\\nAnother good example of a hash table is the Dewey decimal system, used in many libraries. Every book is assigned a number, based upon its subject matterï¿½ the 500′s are all science books, the 700′s are all the arts, etc. Much like a real hash table, the speed at which a person could find a given book is based upon how well the hash buckets are evenly dividedï¿½ It will take longer to find a book about frogs in a library with many science materials than in a library consisting mostly of classical literature.\n\\\nIn applications development, hash tables are a convenient place to store reference data, like state abbreviations that link to full state names. In problem solving, hash tables are useful for implementing a divide-and-conquer approach to knapsack-type problems. In LongPipes, we are asked to find the minimum number of pipes needed to construct a single pipe of a given length, and we have up to 38 pieces of pipe. By dividing this into two sets of 19, and calculating all possible lengths from each set, we create hash tables linking the length of the pipe to the fewest number of segments used. Then, for each constructed pipe in one set, we can easily look up, whether or not we constructed a pipe of corresponding length in the other set, such that the two join to form a complete pipe of the desired length.\n<br/><br/>\n### Conclusion\nThe larger picture to be seen from all of this is that data structures are just another set of tools that should be in the kit of a seasoned programmer. Comprehensive libraries and frameworks available with most languages nowadays preempt the need for a full understanding of how to implement each of these tools. The result is that developers are able to quickly produce quality solutions that take advantage of powerful ideas. The challenge lies in knowing which one to select.\n\\\nNonetheless, knowing a little about how these tools work should help to make the choices easier. And, when the need arises, perhaps leave the programmer better equipped to think up a new solution to a new problemï¿½ if not while on the job doing work for a client, then perhaps while contemplating the 1000 point problem 45 minutes into the coding phase of the next SRM.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"5rg0EyMG9aQUeBU99KbVPd"}}],"upvotes":34,"downvotes":3,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"28xML395bHNDwAhdOKvY9R"}},{"sys":{"type":"Link","linkType":"Entry","id":"3RUcXHuc3tXWkmdesAkmr7"}},{"sys":{"type":"Link","linkType":"Entry","id":"6qQ5n5nHfLRZ0DyCdK5Zfg"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7Emo2c6hFbIUfF9cBScXj3","type":"Entry","createdAt":"2020-02-20T09:27:12.700Z","updatedAt":"2021-11-06T03:24:31.062Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":418,"revision":56,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Introduction to Graphs and Their Data Structures part 1: Recognizing and Representing a Graph","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Graph","Data structure","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505841)\n<br/>\n<a href=\"#Introduction\">Introduction</a>\n<a href=\"#Recognizinggraphproblem\">Recognizing a graph problem</a>\n<a href=\"#Representinggraphandkeyconcepts\">Representing a graph and key concepts</a>\n<a href=\"#Singlylinkedlists\">Singly linked lists</a>\n<a href=\"#Trees\">Trees</a>\n<a href=\"#Graphs\">Graphs</a>\n<a href=\"#Arrayrepresentation\">Array representation</a>\n\\\n\\\n<a name=\"introduction\" id=\"introduction\"></a>\n### Introduction\nGraphs are a fundamental data structure in the world of programming, and this is no less so on topcoder. Usually appearing as the hard problem in Division 2, or the medium or hard problem in Division 1, there are many different forms solving a graph problem can take. They can range in difficulty from finding a path on a 2D grid from a start location to an end location, to something as hard as finding the maximum amount of water that you can route through a set of pipes, each of which has a maximum capacity (also known as the maximum-flow minimum-cut problem – which we will discuss later). Knowing the correct data structures to use with graph problems is critical. A problem that appears intractable may prove to be a few lines with the proper data structure, and luckily for us the standard libraries of the languages used by topcoder help us a great deal here!\n<br/><br/>\n<a name=\"Recognizinggraphproblem\" id=\"Recognizinggraphproblem\"></a>\n### Recognizing a graph problem\nThe first key to solving a graph related problem is recognizing that it is a graph problem. This can be more difficult than it sounds, because the problem writers don’t usually spell it out for you. Nearly all graph problems will somehow use a grid or network in the problem, but sometimes these will be well disguised. Secondly, if you are required to find a path of any sort, it is usually a graph problem as well. Some common keywords associated with graph problems are: vertices, nodes, edges, connections, connectivity, paths, cycles and direction. An example of a description of a simple problem that exhibits some of these characteristics is:\n\\\n\"Bob has become lost in his neighborhood. He needs to get from his current position back to his home. Bob’s neighborhood is a 2 dimensional grid, that starts at (0, 0) and (width – 1, height – 1). There are empty spaces upon which bob can walk with no difficulty, and houses, which Bob cannot pass through. Bob may only move horizontally or vertically by one square at a time.\n\\\nBob’s initial position will be represented by a ‘B’ and the house location will be represented by an ‘H’. Empty squares on the grid are represented by ‘.’ and houses are represented by ‘X’. Find the minimum number of steps it takes Bob to get back home, but if it is not possible for Bob to return home, return -1.\n\\\nAn example of a neighborhood of width 7 and height 5:\n<br/>\n```\n\n.X.X.XX\n.H…\n…X…\n…X.\"\n```\n\\\nOnce you have recognized that the problem is a graph problem it is time to start building up your representation of the graph in memory.\n<br/><br/>\n<a name=\"Representinggraphandkeyconcepts\" id=\"Representinggraphandkeyconcepts\"></a>\n### Representing a graph and key concepts\nGraphs can represent many different types of systems, from a two-dimensional grid (as in the problem above) to a map of the internet that shows how long it takes data to move from computer A to computer B. We first need to define what components a graph consists of. In fact there are only two, nodes and edges. A node (or vertex) is a discrete position in the graph. An edge (or connection) is a link between two vertices that can be either directed or undirected and may have a cost associated with it. An undirected edge means that there is no restriction on the direction you can travel along the edge. So for example, if there were an undirected edge from A to B you could move from A to B or from B to A. A directed edge only allows travel in one direction, so if there were a directed edge from A to B you could travel from A to B, but not from B to A. An easy way to think about edges and vertices is that edges are a function of two vertices that returns a cost. We will see an example of this methodology in a second.\n\\\nFor those that are used to the mathematical description of graphs, a graph G = {V, E} is defined as a set of vertices, V, and a collection of edges (which is not necessarily a set), E. An edge can then be defined as (u, v) where u and v are elements of V. There are a few technical terms that it would be useful to discuss at this point as well:\n\\\nOrder – The number of vertices in a graph\n\\\nSize – The number of edges in a graph\n<br/><br/>\n<a name=\"Singlylinkedlists\" id=\"Singlylinkedlists\"></a>\n### Singly linked lists\nAn example of one of the simplest types of graphs is a singly linked list! Now we can start to see the power of the graph data structure, as it can represent very complicated relationships, but also something as simple as a list.\n\\\nA singly linked list has one “head” node, and each node has a link to the next node. So the structure looks like this:\n<br/>\n```\nstructure node\n[node] link;\n[data]\nend\n\nnode head;\n```\n\\\nA simple example would be:\n<br/>\n```\nnode B, C;\nhead.next = B;\nB.next = C;\nC.next = null;\n```\n\\\nThis would be represented graphically as head -> B -> C -> null. I’ve used null here to represent the end of a list.\n\\\nGetting back to the concept of a cost function, our cost function would look as follows:\n<br/>\n```\ncost(X, Y) := if (X.link = Y) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nThis cost function represents the fact that we can only move directly to the link node from our current node. Get used to seeing cost functions because anytime that you encounter a graph problem you will be dealing with them in some form or another! A question that you may be asking at this point is “Wait a second, the cost from A to C would return not possible, but I can get to C from A by stepping through B!” This is a very valid point, but the cost function simply encodes the direct cost from a node to another. We will cover how to find distances in generic graphs later on.\n\\\nNow that we have seen an example of the one of the simplest types of graphs, we will move to a more complicated example.\n<br/><br/>\n<a name=\"Trees\" id=\"Trees\"></a>\n### Trees\nThere will be a whole section written on trees. We are going to cover them very briefly as a stepping-stone along the way to a full-fledged graph. In our list example above we are somewhat limited in the type of data we can represent. For example, if you wanted to start a family tree (a hierarchal organization of children to parents, starting from one child) you would not be able to store more than one parent per child. So we obviously need a new type of data structure. Our new node structure will look something like this:\n<br/>\n```\nstructure node\n[node] mother, father;\n[string] name\nend\n\nnode originalChild;\n```\n\\\nWith a cost function of:\n<br/>\n```\ncost(X, Y) := if ((X.mother = Y) or (X.father = Y)) return 1;\nelse if (X = Y) return 0;\nelse “Not possible”\n```\n\\\nHere we can see that every node has a mother and father. And since node is a recursive structure definition, every mother has mother and father, and every father has a mother and father, and so on. One of the problems here is that it might be possible to form a loop if you actually represented this data structure on a computer. And a tree clearly cannot have a loop. A little mind exercise will make this clear: a father of a child is also the son of that child? It’s starting to make my head hurt already. So you have to be very careful when constructing a tree to make sure that it is truly a tree structure, and not a more general graph. A more formal definition of a tree is that it is a connected acyclic graph. This simply means that there are no cycles in the graph and every node is connected to at least one other node in the graph.\n\\\nAnother thing to note is that we could imagine a situation easily where the tree requires more than two node references, for example in an organizational hierarchy, you can have a manager who manages many people then the CEO manages many managers. Our example above was what is known as a binary tree, since it only has two node references. Next we will move onto constructing a data structure that can represent a general graph!\n<br/><br/>\n<a name=\"Graphs\" id=\"Graphs\"></a>\n### Graphs\nA tree only allows a node to have children, and there cannot be any loops in the tree, with a more general graph we can represent many different situations. A very common example used is flight paths between cities. If there is a flight between city A and city B there is an edge between the cities. The cost of the edge can be the length of time that it takes for the flight, or perhaps the amount of fuel used.\n\\\nThe way that we will represent this is to have a concept of a node (or vertex) that contains links to other nodes, and the data associated with that node. So for our flight path example we might have the name of the airport as the node data, and for every flight leaving that city we have an element in neighbors that points to the destination.\n<br/>\n```\nstructure node\n[list of nodes] neighbors\n[data]\nend\n\ncost(X, Y) := if (X.neighbors contains Y) return X.neighbors[Y];\nelse “Not possible”\n\nlist nodes;\n```\n\\\nThis is a very general way to represent a graph. It allows us to have multiple edges from one node to another and it is a very compact representation of a graph as well. However the downside is that it is usually more difficult to work with than other representations (such as the array method discussed below).\n<br/><br/>\n<a name=\"Arrayrepresentation\" id=\"Arrayrepresentation\"></a>\n### Array representation\nRepresenting a graph as a list of nodes is a very flexible method. But usually on topcoder we have limits on the problems that attempt to make life easier for us. Normally our graphs are relatively small, with a small number of nodes and edges. When this is the case we can use a different type of data structure that is easier to work with.\n\\\nThe basic concept is to have a 2 dimensional array of integers, where the element in row i, at column j represents the edge cost from node i to j. If the connection from i to j is not possible, we use some sort of sentinel value (usually a very large or small value, like -1 or the maximum integer). Another nice thing about this type of structure is that we can represent directed or undirected edges very easily.\n\\\nSo for example, the following connection matrix:\n<br/>\n```\nA B C\nA 0 1 5\nB -1 0 1\nC -1 -1 0\n```\n\\\nWould mean that node A has a 0 weight connection to itself, a 1 weight connection to node B and 5 weight connection to node C. Node B on the other hand has no connection to node A, a 0 weight connection to itself, and a 1 weight connection to C. Node C is connected to nobody. This graph would look like this if you were to draw it:\n<br/><div style=\"text-align:center;\">\n![graph](//images.ctfassets.net/piwi0eufbb2g/39urFkSmHSQE5Y9thpTSbl/89c592184413c140e1b8706429dff7d1/graph.gif)\n</div>\nThis representation is very convenient for graphs that do not have multiple edges between each node, and allows us to simplify working with the graph.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Introduction%20to%20Graphs%20and%20Their%20Data%20Structures%20part%202:%20Searching%20a%20Graph)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"7dpViJNiGS7Fflpf8x767t"}}],"upvotes":19,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}},{"sys":{"type":"Link","linkType":"Entry","id":"ypU3M6AxrYYmErQqodsVr"}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"1zNmLfct0Kwzl4TgJH7r9p"}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7L8jqW1gCl6glwSnV8LKTN","type":"Entry","createdAt":"2020-04-20T12:42:14.078Z","updatedAt":"2020-04-20T12:42:14.078Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"square1001","tcHandle":"square1001"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7LceTr6NvYiCX81vrsy31I","type":"Entry","createdAt":"2020-02-22T14:18:54.241Z","updatedAt":"2020-02-22T14:18:54.241Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"TheLlama"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7M4Mi2lee2fNvwwkdUle1b","type":"Entry","createdAt":"2020-04-20T12:41:39.297Z","updatedAt":"2020-04-20T12:41:39.297Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Aditya","tcHandle":"Aditya"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7fJQUX22AQzwU0enuvpLIf","type":"Entry","createdAt":"2022-02-17T19:04:28.824Z","updatedAt":"2022-02-21T14:19:06.073Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":30,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Layering GraphQL over REST","slug":"layering-graphql-over-rest","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}}],"tags":["GraphQL","REST"],"creationDate":"2022-02-17","readTime":"9min","content":"GraphQL is quickly supplanting REST as the standard for which data is changed, brought, and queried between the server-end and frontend. Technical developers are seeking to analyze and procure its advantages in their brown-field ventures.\n\nThere are many advantages of GraphQL, here are just a few:\n\n1.  Querying numerous assets or resources and fetching the precise information and data you need in one request. Conversely, if we do the exact thing using REST it costs us multiple requests to filter the data.\n\n2.  A modern era of ergonomic dev tools from API to the frontend with famous platforms like Apollo Engine, Client, and Server.\n\n3.  Enhanced performance, particularly on gadgets with moderate internet connections, through the diminished size of the payload and fewer round trips to the backend.\n\nThe most perfect way to integrate product architecture with GraphQl is to deploy it as a layer between existing APIs and applications.\n\n<picture><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3pmPJlnJ4iLwUZEAjtCjdC/7a558aaf4ffd873f171bf62c5ebcc502/image.png?fm=webp\" type=\"image/webp\" media=\"(min-width: 769px)\" /><source srcset=\"//images.ctfassets.net/piwi0eufbb2g/3pmPJlnJ4iLwUZEAjtCjdC/7a558aaf4ffd873f171bf62c5ebcc502/image.png?fm=webp&w=768\" type=\"image/webp\" media=\"(max-width: 768px)\" /><img src=\"//images.ctfassets.net/piwi0eufbb2g/3pmPJlnJ4iLwUZEAjtCjdC/7a558aaf4ffd873f171bf62c5ebcc502/image.png\" alt=\"image\" loading=\"lazy\"></picture>\n\n### Layering GraphQL on Top of MVRP API\nTo layer GraphQL over our existing API we'll utilize Apollo Server. It has built-in features and support for GraphQL environment, schema sewing, effective error handling tools, data uploads, schema mandates, and simply observing integration. Let’s jump into building our schema!\n\nIn this, we use the schema first development approach. This is an advanced approach for planning and building cutting edge user interfaces that includes the frontend/client-side and backend/server-side groups concurring on a schema to begin with, which serves as a contract between the frontend and the backend ahead of any API building process. Let’s build a basic GraphQL scheme that portrays the shape of the information from the REST API.\n\nOnce we begin to build our GraphQL schema there’s a gigantic allure to form literal mappings over REST API or existing database collections data response fields. Whereas this mapping may be a quick way to urge up and running, we unequivocally recommend building the schema based on how the GraphQL API will be utilized by the client-end. This way, we'll plan a schema that reflects how client-side developers are fetching it, without compelling ourselves to the precise shape of the information returned by our existing APIs.\n\nThe schema underneath builds up a contract that depicts precisely how we ought to bring information into our user interface or frontend. Commendable of note are the two fields of schema, “manufactureYear”, and “vehicleStatus”, named differently from the attributes: “productionYear” and “status”, returned as a response from the REST API.\n\n```js\nimport { gql, AppoloServer } from 'apollo-server';\n\nconst typeDefs = gql`\ntype Car {\n    id: Int!\n    model: String!\n    color: String!\n    plateNumber: String!\n    chasisNumber: String!\n    manufactureYear: Int!\n    vehicleStatus: String!\n    expiryDate: String!\n    issueDate: String!\n}\ntype Query {\n    cars: [Car]\n    car(plateNumber: String!): Car\n}\n`;\n```\n\nOur GraphQL schema depicts how it’s utilized on the client-side user interface. Now, check out the Query block:\ncars: \\[Car\\] - this query returns full details of all cars present in the database.\ncar(plateNumber: String!): Car - this query returns details of only one car matching with plateNumber argument.\n\n### Data Sources\nWhen conveying GraphQL as a layer between existing APIs, services, and our applications, “Apollo Data Sources” give the finest involvement for caching and fetching information from REST endpoints. It’s a modern pattern for stacking information from a specific service, with built-in support for deduplication, error handling, and caching. To ship the data sources out of the box “Apollo Server” is used as the GraphQL layer.\nNow, we have to install apollo-datasource-rest.\n\n`npm install apollo-datasource-rest`\n\nWe create a file named dataSource.js with a class named MVRP (it can be anything) and extend RESTDataSource class as given below-\n\n```js\nimport { RESTDataSource } from 'apollo-datasource-rest';\n\nexport class MVRP extends RESTDataSource {\n    constructor() {\n        super();\n        this.base_url = 'https://mvrp.herokuapp.com/api/';\n    }\n\n    async fetchAllCars() {\n        return this.get('cars');\n    }\n\n    async fetchCar(plateNumber) {\n        const result = await this.get('car', {\n        plateNumber\n        });\n\n        return result[0];\n    }};\n```\n\nHere, base_url is allotted to the root domain of the API within the constructor of our DataSource class. fetchCar(plateNumber)and fetchAllCars() functions get data from the /car and /car?plateNumber endpoints respectively, and both functions invoke the HTTP GET request.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7fSG7idnmJAPzpmeZ44SrX","type":"Asset","createdAt":"2022-02-17T19:02:55.677Z","updatedAt":"2023-09-21T14:44:33.218Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":2,"locale":"en-US"},"fields":{"title":"GraphQL article banner image","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7fSG7idnmJAPzpmeZ44SrX/f9cbaaa4f13d2e583c9a314218943c16/Banner_Thrive__1_.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive (1).png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2b56J83mO6xWOJwhZJ5uuC","type":"Entry","createdAt":"2021-10-18T06:57:25.136Z","updatedAt":"2021-10-18T06:57:25.136Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kunal Jain","tcHandle":"kunalkj_"}}],"upvotes":1,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"4CmGkGPOwKztbCNNqDWLmm"}},{"sys":{"type":"Link","linkType":"Entry","id":"3K3D6N5OeawF9nZwr07MGt"}},{"sys":{"type":"Link","linkType":"Entry","id":"7o6p5UjHg80yvob06jXFz0"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7grGsA4QB6NKhy18BmMCHX","type":"Entry","createdAt":"2020-02-19T13:03:26.091Z","updatedAt":"2020-02-19T13:03:26.091Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"leadhyena_inran","tcHandle":"leadhyena_inran"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7irvPmUqeUZHDFMgz0piRj","type":"Entry","createdAt":"2020-02-21T10:26:10.811Z","updatedAt":"2020-02-21T10:26:10.811Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"bmerry"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7jXzj0Re46Izgnuy04I5X8","type":"Entry","createdAt":"2022-07-15T15:51:22.672Z","updatedAt":"2022-07-25T02:36:55.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":122,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","slug":"python-data-structures-strings","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"1XKgff9ovQ0Qb7cPbG37Un"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Python","Data Structures"],"creationDate":"2022-07-07","readTime":"10min","content":"Data structures are used to store and organize data efficiently. They allow you to quickly access and manipulate the data. Python includes many built-in data structures for easy data management.\nIn this article we will learn about one of Python's most important data structures: Strings. \n\nWorking on real-world projects will make you realize how significant strings are as a data type in Python. Since working with strings seems simple but solving problems is complex, the majority of problem statements in interviews and written examinations are based on string manipulation.\nIn this article we cover everything about strings.\n\n### Brief Overview of Python String Data Type\n\nStrings are a collection of Unicode characters that are used specifically in Python. A string is the language or text we use to communicate. However, machines can only read binary, they cannot comprehend text. As a result, ASCII numbers are initially generated from characters before being transformed to binary representation. However, ASCII is exclusively used for the English language, and when programming languages are used in other nations, they are translated to 16-bit characters known as Unicode.\n\n##### Creating Strings\n\nPython offers several methods for creating strings, including single, double, and triple quotes. When constructing a string, if the string contains any kind of quote, you should use a separate kind of quote in the declaration to prevent an error. Try the example below in any Python IDE or code editor for a better understanding.\n\n```python\ns = 'Good Morning' #single quotes\ns = 'It's been a great day' #syntax error (It confuses where string starts and ends)\ns = \"It's been a great day\" #correct way\ns = '''Good Morning''' #multi-line strings\n```\n\nWhen declaring or referencing a lengthy paragraph use triple quotes. Any other data type can be declared as a string or converted using an internal function.\n\n```python\na = 99 #int\nprint(str(a)) #int to str\n```\n\n##### Accessing Substring from String\n\nTo address a specific use case, it may occasionally be essential to access portions of a string. We shall discuss indexing and slicing, which enable us to extract a specific section of the text as output.\n\n#### Indexing\n\nIndexing a string with zeros is the same as indexing an array. Simply put, the zero indexes in a string represent the first character, and as the index rises, the string advances. Positive and negative indexing are the two categories of indexing in Python.\n\n##### Positive Indexing\n\nPositive indexing is moving from zero to the end length of a string. It is also known as zero-based indexing.\n\n```python\ns = 'GoodMorning' \nprint(s[0])  \nprint(s[2])  \nprint(s[4])  \nprint(s[len(s)-1]) \nprint(len(s))\n```\n\n__output:__\n```python\nG\no\nM\ng\n11\n```\n\n__Note__: If access s(11), program returns a Index error\n\n##### Negative Indexing\n\nAccessing string elements using a negative index means going backward in time. It usually  takes a long time to access the last character in a string if we use positive indexing since we have to calculate the length of the string and then take one off of it. In this situation, we can just use the negative indexing.\n\n```python\ns = 'GoodMorning' \nprint(s[-1])  \nprint(s[-2])\n```\n__output:__\n```python\ng\nn\n```\n\n##### Slicing\nThe concept of slicing, which is accomplished using the colon operator, comes into play when we have long strings, such as sentences or paragraphs, and we want to access specific pieces, like whole words, but we cannot do so merely using indexing. To ensure that the output is a portion of the string from a start index to an end index less one, we must specify the starting index and end index in square brackets that are separated by colons.\n\n```python\ns = 'Good Morning' \nprint(s[1:4])\n```\n\n__output:__\n```python\nood\n```\n\nStart with the first index in the example above and retrieve the character all the way to the third index. Now that there are various slicing variations, let's examine them practically using the code sample below.\n\n```python\ns = 'GoodMorning' \nprint(s[1:])  \nprint(s[:4])\nprint(s[:])\nprint(s[0:8:3])\nprint(s[::-1])\n```\n\n__output:__\n```python\noodMorning\t\t#It will print the entire string starting from index 1\nGood\t\t\t#It will print the entire string starting from index 0 to 3\nGoodMorning\t\t#It will print the entire string \nGdr\t\t\t\t#It will print zero index and skip two index and take third index till eighth index\ngninroMdooG #It will print the string in reverse order\n```\n\n### Editing and Deleting Python Strings\n\nSince strings in Python are immutable data types, attempting to change one will result in a type error. The existing string cannot be changed or added to, but it can be assigned to a separate variable to produce a new string. Let's examine the practical effects of deleting and altering strings to see whether we experience any errors.\n\nSince strings are immutable, we cannot directly reassign the value of the particular string in the below snippet.\n\n```python\ns = 'GoodMorning' \ns[0] = \"M\" \t\t #This operation is not allowed and it will return not support Item assignment error\n\n```\n\nInstead, the below combination will work\n\n```python\ns = 'GoodMorning' \na = \"M\" + s[1:]\t \nprint(a) \n```\n\n__output:__\n```python\nMoodMorning\n```\n\nDeleting the strings won't work well and the below statements will generate errors saying we can't delete the string.\n\n```python\ndel s[0]    \ndel s[:3:2] \n```\n\nIt is crucial to comprehend that strings cannot be changed; nothing can be added or removed from an existing string.\n\n### Operations on Python String\n\n#### Arithmetic Operations\n\n##### Addition(+)\n\nConcatenation, as it is also known, allows us to link any amount of strings by using the addition operator.\n\n```python\ns = \"Good\" + \"-\" + \"Morning\"\nprint(s) \n```\n__output:__\n```python\nGood-Morning\n```\n\n##### Multiplication(*)\n\nTo repeat a certain string before the multiplication operator any number of times is known as string repetition. When we want a pattern, we use it.\n\n```python\ns = \"Good\" \nprint(s*3) \n```\n__output:__\n```python\nGoodGoodGood\n```\n\n#### Relational Operations \n\nRelational operators display the relationship between two terms and determine whether a particular condition is true or false, producing a boolean result.\n```python\nprint(\"Hello\" == \"World\")  \nprint(\"Hello\" != \"World\")  \n```\n__output:__\n```python\nFalse\nTrue\n```\n\nWhen we apply the larger than and less than operators the situation becomes more intriguing.\n```python\nprint(\"Mumbai\" > \"Pune\")  \nprint(\"Goa\" < \"Indore\") \n```\n\n__output:__\n```python\nFalse\nTrue\n````\n\nYou might be wondering how it compares two strings. As a result, it lexicographically compares a string. As P follows M in the alphabetical order in the first case, the statement is false. Lowercase characters are placed after uppercase because occasionally people mistake the two case types.\n\n#### Logical Operations\nWhen you use the AND, OR, and NOT logical operators on strings, Python returns false for empty strings and true for non-empty strings.\n\n```python\nprint(\"Hello\" and \"World\") #True and True -> True (O/P -> World)\nprint(\"\" and \"World\") #False and True -> False (O/P -> \"\")\nprint(\"\" or \"World\") #False OR True -> True (O/P -> \"World\")\nprint(not \"Hello\") #opposite of True -> False\nprint(not \"\") #True\n```\n\n##### Loops\nSlicing allows us to loop over strings starting at any index. To access distinct characters or create a pattern in a string, we can use both a where and a for loop.\n\n```python\ns = 'GoodMorning' \nfor i in s:\n\tprint(i)\n```\n\n__output:__\n```python\nG\no\no\nd\nM\no\nr\nn\ni\nn\ng\n```\n\n#### Membership Operators\nPython's in and NOT in membership operators are used to determine whether any element is present in any sequence data structure.\n\n```python\ns = 'GoodMorning' \nif 'M' in s:\n\tprint('true')\n```\n__output:__\n```python\ntrue\n```\n\n### Python String Functions\nThe most important parts of a string are string functions which you use everywhere whenever you build any project. Now we will study all-important string functions which are frequently used.\nCommon Functions:\n\nThese are the same functions that are available for all other iterator data types, including list, tuple, set, and string.\n\n1. length - It provides the string's length.\n2. minimum - This function returns the smallest character in a string, as determined by ASCII.\n3. maximum - The largest character found in the string, as determined by ASCII, is provided by the third option, maximum.\n4. sorted - The string is sorted in either ascending or descending order using the ASCII character sequence. This function always returns a list of characters as its result.\n\n```python\ns = 'GoodMorning' \nprint(len(s))\nprint(min(s))\nprint(max(s))\nprint(sorted(s))\nprint(sorted(s,reverse=True))\n```\n\n__output:__\n```python\n11\nG\nr\n['G', 'M', 'd', 'g', 'i', 'n', 'n', 'o', 'o', 'o', 'r']\n['r', 'o', 'o', 'o', 'n', 'n', 'i', 'g', 'd', 'M', 'G']\n```\n\n#### Some Specific Purpose Functions in Strings\nThe functions we'll look at here only work with strings.\n\n##### Title or capitalize\nThe title function capitalizes the first letter of each word, whereas the capitalize function capitalizes the first letter of a string.\n```python\ns = \"its raining outside\"\nprint(s.capitalize()) #O/P -> Its raining outside\nprint(s.title()) \t #O/P -> Its Raining Outside\n```\n\n##### Upper / lower / swap case\nIn string each character is converted in the upper function to lowercase characters. Swap case changes an upper to a lower case character, and vice versa.\n```python\ns = \"Its Raining Outside\"\nprint(s.upper()) #O/P -> ITS RAINING OUTSIDE\nprint(s.lower()) #O/P -> its raining outside\nprint(s.swapcase()) #O/P -> iTS rAINING oUTSIDE\n```\n\n##### Count\nIt provides the number of any substrings that are present in a string. It outputs 0 if the substring is missing from the string. It is used to determine how often a given substring occurs in a string.\n```python\ns = \"Its Raining Outside\"\nprint(s.count(\"i\")) #3\nprint(s.count(\"ing\")) #1\n```\n\n###### Find / Index\nBoth functions operate in exactly the same manner. Both locate the position of a substring within a string. The sole distinction between the two functions is that while index gives an error when the substring is absent, string find produces a negative value when this occurs.\n```python\ns = \"Its Raining Outside\"\nprint(s.find(\"ing\")) #8\nprint(s.index(\"ing\")) #8\nprint(s.find(\"down\")) #-1\nprint(s.index(\"down\")) #error\n```\n\n### Conclusion\nIn this article we have learned about string literals in Python. We have started by getting ideas about string and covered how to use, create, and play with string and string functions. Hope you enjoyed it. \n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3NYB2aT7Gq3kJRqScz4IPw","type":"Asset","createdAt":"2022-07-08T03:28:13.117Z","updatedAt":"2023-09-14T11:30:09.820Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3NYB2aT7Gq3kJRqScz4IPw/7478abbc77e49c6af713855f234d3e34/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"73rulPE4jzRwGORwhZwHJm"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"34zIQNVTXVHI5WguauMsWx","type":"Entry","createdAt":"2020-12-18T08:52:04.288Z","updatedAt":"2024-07-15T11:27:39.055Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":116,"revision":26,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Getting Started with Python","slug":"getting-started-with-python","type":"Article","trackCategory":["Development"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"30UkO2IVfmjXjUJZ9QkWfc"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2eDAdwu27lVDlelkLei6HA","type":"Entry","createdAt":"2020-02-19T00:33:39.963Z","updatedAt":"2020-02-19T00:33:39.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Development","description":"Correct Version"}},{"sys":{"type":"Link","linkType":"Entry","id":"Caw9t2fdYN3diW6ITAg20"}}],"tags":["Python"],"creationDate":"2020-12-18","readTime":"15min","content":"This article will cover almost everything you need to get started with Python. Python has become one of the most popular programming languages and is used every day by programmers to do cool things like automate, build applications and websites like Instagram, and it is used in Artificial Intelligence (AI). \nNo one is too old or too young to learn Python. Python is very easy to learn.\n\n### Installing Python:\n1. Download Python from this link -> https://www.python.org/downloads/.\n2. Install after downloading the latest Python from the above link.\n3. Don't forget to click on check Add Python 3.x to PATH.\n\n### About IDEs:\n\nIDE stands for Integrated Development Environment. It enables programmers to combine different aspects of writing code. IDEs increase programmer’s productivity by simplifying common activities in a single application like editing source code, debugging and building executables. There are different IDEs available like PyCharm, VS Code, Sublime text, and IDLE (default).\n\n#### Why PyCharm and why it is better than other IDEs?\n\n1. The intelligent code editor provided by PyCharm enables programmers to write a high quality Python code.\n2. The editor enables programmers to read code easily through color schemes, and auto indents on new lines automatically.\n3.The smart code navigation option provided by PyCharm helps programmers to edit and improve the code quality without putting in extra time. It makes both local and global changes very quickly and efficiently.\n4. PyCharm comes with a local terminal which enables the programmers to continue coding and testing without leaving the IDE.\n\n### Setting up IDE for Python:\n1. Download [PyCharm from this link](https://www.jetbrains.com/pycharm/download/#section=windows).\n2. Install Pycharm.\n3. Click on the new Project.\n4. Make sure in Project Interpreter, the base interpreter is set to your installed python version.\n\n![Screenshot 2020-12-18 10:34:50](//images.ctfassets.net/piwi0eufbb2g/1wV1DfEV8hT5wDDyZj2DTV/4da57cec5900cac1f30d4f2151ea9378/Screenshot_2020-12-18_10_34_50.png)\n\nWriting First Python Program\n\n1. Right-click on the new project created.\n2. New -> Python File\n3. Give `<Filename>.py`\n4. Type print(‘This is my first python program’)\n5. Click on run\n\n![Screenshot 2020-12-18 10:35:51](//images.ctfassets.net/piwi0eufbb2g/1Dyo4GsyUZhRip5edJY73y/23cfe00eaccf612469264ab2904ab6f2/Screenshot_2020-12-18_10_35_51.png)\n\nPython executes the program line by line.\n\nFor reference,users can read documentation at: [Read Docs](https://docs.python.org/release/3.7.9/tutorial/index.html) and can also read sample codes here: [Samples](https://www.programiz.com/python-programming/examples)\n\n### Python Variables:\n\nVariables are used in programming languages to temporarily store data in a computer's memory.\nFor example:\n\n![Screenshot 2020-12-18 10:37:01](//images.ctfassets.net/piwi0eufbb2g/353KBMKnGCzDjuktxdkmx3/454676aeddbc4853c1583473aa3de5f2/Screenshot_2020-12-18_10_37_01.png)\n\nWhen Python interpreter executes this code, it will allocate some memory and thenstore the number 29 in the memory and attach 29 to the label age. \n\nInteger, float, string, and Boolean are the data types in Python.\n\n![Screenshot 2020-12-18 10:37:48](//images.ctfassets.net/piwi0eufbb2g/nFeimIQyg8S3JJYPhgVEJ/ef1843ecbc96877d6add45be82d67c10/Screenshot_2020-12-18_10_37_48.png)\n\n### PYTHON STRINGS:\nA string is a sequence of characters. To make a string, we may enclose a sequence of characters between single, double, or triple quotes. \nThus, 'Hello world', ' \"Hello \" ', \"what's \", '''today's \"action\" plan?''' are the examples of strings.\n\n```\nprint('Hello world')\nprint(\"What’s \")\nprint('''today's plan?''' )\n```\n\n![Screenshot 2020-12-18 10:38:40](//images.ctfassets.net/piwi0eufbb2g/7d4mD9wE1aKcFpbBtCUATb/e61ddd9a765d34a00eb9c149c71ed5b0/Screenshot_2020-12-18_10_38_40.png)\n\n### OPERATORS IN PYTHON\n#### RELATION OPERATORS\nThese operators are used to compare two expressions and returns either true or false. These are greater than (>), less than (<), equals to (==), greater than equal to (>=), less than equal to (<=), not equal to (! =), they can be used for any data types.\n\n![Screenshot 2020-12-18 10:39:32](//images.ctfassets.net/piwi0eufbb2g/407HxnRem5pjDqpWAZFlln/27be9c3a569080cfa0a6e4c83f86f0d1/Screenshot_2020-12-18_10_39_32.png)\n\n#### LOGICAL OPERATORS:\n\nThe logical operators not, and, and or are applied to logical operands true and false, also called Boolean values, and yield either true or false. Not is an unary operator it requires only one operand.\n\n*and operator – It returns true only when both the expressions are true else false.\n* or operator – It returns true if any one of the expressions is true else false.\n* not operator – It returns the opposite of the expression.\n\n![Screenshot 2020-12-18 10:40:22](//images.ctfassets.net/piwi0eufbb2g/6d5P3wcGfvG6bL2Quq3Svn/8dae71553bf9f529112a74f43e53dd67/Screenshot_2020-12-18_10_40_22.png)\n\n#### BITWISE OPERATORS\n\nBitwise operators are the operators that operate on integers interpreted as strings of binary digits 0 and 1, also called bits. \n\n- Bitwise and (&)\n- Bitwise or (|)\n- Bitwise complement (~)\n- Bitwise Exclusive to (^)\n- Left Shift (<<)\n- Right Shift (>>)\n\n### BUILT-IN FUNCTIONS\nBuilt-in functions are the predefined functions that are already available in Python.\n#### input() function:\n\nThe function input enables us to accept an input string from the user without evaluating its value. The function input continues to read input text from the user until it encounters a new line, for example:\n\n![Screenshot 2020-12-18 10:41:45](//images.ctfassets.net/piwi0eufbb2g/1PW2GbdDTIrH8AfZvB0jPz/561a646839d771020b204a4268d79d60/Screenshot_2020-12-18_10_41_45.png)\n\n#### eval() function:\nThis function is used to evaluate the value of the string.\n\n![Screenshot 2020-12-18 10:42:24](//images.ctfassets.net/piwi0eufbb2g/1nFikLmcT7D536zYKGlMJQ/2d0bdbe70974f0c2e87ca9d3d91ca744/Screenshot_2020-12-18_10_42_24.png)\n\n#### print() Function:\n\nprint() function enables us to produce output in Python. Print function can also have an escape sequence which can print different types of data at a time separating the values with a comma.\n\n![Screenshot 2020-12-18 10:42:59](//images.ctfassets.net/piwi0eufbb2g/2Hr4yvbGcRptANb9Bg0pq9/39db8912b78a16c7edfe309a976fc3b6/Screenshot_2020-12-18_10_42_59.png)\n\n#### Other functions:\n__type() Function:__ It returns the data type of the parameter.\n\n![Screenshot 2020-12-18 10:43:37](//images.ctfassets.net/piwi0eufbb2g/21w2aN0Mjnw17PjcJVBiuy/29709a67ace01dcf3905f830074eb4a4/Screenshot_2020-12-18_10_43_37.png)\n\n__max(), min() Function:__ It returns the maximum and minimum value of the data given.\n\n![Screenshot 2020-12-18 10:44:31](//images.ctfassets.net/piwi0eufbb2g/7HRLB4ZcZw0dpg8nDeBQy3/e4e652dbd0e8fc6d6241c013ec452759/Screenshot_2020-12-18_10_44_31.png)\n\n__round() Function:__ It rounds the value of the parameter and returns the  rounded value.\n\n![Screenshot 2020-12-18 10:45:21](//images.ctfassets.net/piwi0eufbb2g/63GkyF8v9j8Xb6o0GV9Ujq/d74a747800523ac66c1acd8d3187bb77/Screenshot_2020-12-18_10_45_21.png)\n\n__pow() Function:__ It takes two values, number and exponent, and returns number to the power of exponent.\n\n![Screenshot 2020-12-18 10:46:49](//images.ctfassets.net/piwi0eufbb2g/7iu4RXIjHDf0HBCbkFGQnH/9c013dac26c084558cd3399947a1a109/Screenshot_2020-12-18_10_46_49.png)\n\n[HERE IS A LIST OF OTHER BUILT-IN FUNCTIONS](https://docs.python.org/3/library/functions.html#float)\n\nTry it yourself:\n1. Create a variable name which will take the input from the user and print it.\n2. Print the maximum and minimum values out of four values.\n3. Input five values and print their respective data types.\n4. Input two numbers x and y and print x raised to power y.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"3kNHPHf18iXXpDrqcCvljE"}}],"upvotes":25,"downvotes":0}},{"sys":{"type":"Link","linkType":"Entry","id":"79Q3wxU7N1THUOilI7RUtq"}},{"sys":{"type":"Link","linkType":"Entry","id":"6GBXhy7l8ghq5l4eIZSLDp"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7mQBfgaWnYKbVjOp2MeCxm","type":"Entry","createdAt":"2020-02-20T12:38:10.637Z","updatedAt":"2024-07-12T17:27:18.329Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":727,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part two","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[…read Section 1](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20one)\n<br/>\nIn this part of the article we will focus on estimating the time complexity for recursive programs. In essence, this will lead to finding the order of growth for solutions of recurrence equations. Don’t worry if you don’t understand what exactly is a recurrence solution, we will explain it in the right place at the right time. But first we will consider a simpler case – programs without recursion.\n\\\nNested loops\n\\\nFirst of all let’s consider simple programs that contain no function calls. The rule of thumb to find an upper bound on the time complexity of such a program is:\n- estimate the maximum number of times each loop can be executed,\n- add these bounds for cycles following each other.\n- multiply these bounds for nested cycles/parts of code,\n\n<br/>__Example 1.__ Estimating the time complexity of a random piece of code.\n<br/>\n```\nint result=0;                           //  1\nfor (int i=0; i<N; i++)                 //  2\nfor (int j=i; j<N; j++) {             //  3\nfor (int k=0; k<M; k++) {           //  4\nint x=0;                          //  5\nwhile (x<N) { result++; x+=3; }   //  6\n}                                   //  7\nfor (int k=0; k<2*M; k++)           //  8\nif (k%7 == 4) result++;           //  9\n}                                     // 10\n```\n\\\nThe time complexity of the while-cycle in line 6 is clearly O(N) – it is executed no more than N/3 + 1 times.\n\\\nNow consider the for-cycle in lines 4-7. The variable k is clearly incremented O(M) times. Each time the whole while-cycle in line 6 is executed. Thus the total time complexity of the lines 4-7 can be bounded by O(MN).\n\\\nThe time complexity of the for-cycle in lines 8-9 is O(M). Thus the execution time of lines 4-9 is O(MN + M) = O(MN).\n\\\nThis inner part is executed O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) times – once for each possible combination of i and j. (Note that there are only N(N + 1)/2 possible values for [i, j]. Still, O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) is a correct upper bound.)\n\\\nFrom the facts above follows that the total time complexity of the algorithm in Example 1 is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.MN) = O(MN<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>).\n\\\nFrom now on we will assume that the reader is able to estimate the time complexity of simple parts of code using the method demonstrated above. We will now consider programs using recursion (i.e. a function occasionally calling itself with different parameters) and try to analyze the impact of these recursive calls on their time complexity.\n\\\nUsing recursion to generate combinatorial objects\n\\\nOne common use of recursion is to implement a backtracking algorithm to generate all possible solutions of a problem. The general idea is to generate the solution incrementally and to step back and try another way once all solutions for the current branch have been exhausted.\n\\\nThis approach is not absolutely universal, there may be problems where it is impossible to generate the solution incrementally. However, very often the set of all possible solutions of a problem corresponds to the set of all combinatorial objects of some kind. Most often it is the set of all permutations (of a given size), but other objects (combinations, partitions, etc.) can be seen from time to time.\n\\\nAs a side note, it is always possible to generate all strings of zeroes and ones, check each of them (i.e. check whether it corresponds to a valid solution) and keep the best found so far. If we can find an upper bound on the size of the best solution, this approach is finite. However, this approach is everything but fast. Don’t use it if there is __any__ other way.\n\\\n__Example 2.__ A trivial algorithm to generate all permutations of numbers 0 to N – 1.\n<br/>\n```\nvector permutation(N);\nvector used(N,0);\n\nvoid try(int which, int what) {\n// try taking the number “what” as the “which”-th element\npermutation[which] = what;\nused[what] = 1; \n\nif (which == N-1)\noutputPermutation();\nelse\n// try all possibilities for the next element\nfor (int next=0; next<N; next++)\nif (!used[next])\ntry(which+1, next); \n\nused[what] = 0;\n} \n\nint main() {\n// try all possibilities for the first element\nfor (int first=0; first<N; first++)\ntry(0,first);\n}\n```\n\\\nIn this case a trivial __lower__ bound on the time complexity is the number of possible solutions. Backtracking algorithms are usually used to solve hard problems – i.e. such that we don’t know whether a significantly more efficient solution exists. Usually the solution space is quite large and uniform and the algorithm can be implemented so that its time complexity is close to the theoretical lower bound. To get an upper bound it should be enough to check how much additional (i.e. unnecessary) work the algorithm does.\n\\\nThe number of possible solutions, and thus the time complexity of such algorithms, is usually exponential – or worse.\n\\\nDivide&conquer using recursion\n\\\nFrom the previous example we could get the feeling that recursion is evil and leads to horribly slow programs. The contrary is true. Recursion can be a very powerful tool in the design of effective algorithms. The usual way to create an effective recursive algorithm is to apply the divide & conquer paradigm – try to split the problem into several parts, solve each part separately and in the end combine the results to obtain the result for the original problem. Needless to say, the “solve each part separately” is usually implemented using recursion – and thus applying the same method again and again, until the problem is sufficiently small to be solved by brute force.\n\\\n__Example 3.__ The sorting algorithm MergeSort described in pseudocode.\n<br/>\n```\nMergeSort(sequence S) {\nif (size of S <= 1) return S;\nsplit S into S_1 and S_2 of roughly the same size;\nMergeSort(S_1);\nMergeSort(S_2);\ncombine sorted S_1 and sorted S_2 to obtain sorted S;\nreturn sorted S;\n}\n```\n\\\nClearly O(N) time is enough to split a sequence with N elements into two parts (Depending on the implementation this may be even possible in constant time.) Combining the shorter sorted sequences can be done in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N): Start with an empty S. At each moment the smallest element not yet in S is either at the beginning of S<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">1</sub> or at the beginning of S<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>. Move this element to the end of S and continue.\n\\\nThus the total time to MergeSort a sequence with N elements is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) plus the time needed to make the two recursive calls.\n\\\nLet f (N) be the time complexity of MergeSort as defined in the previous part of our article. The discussion above leads us to the following equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_2](https://images.ctfassets.net/b5f1djy59z3a/wIFnLTP3tQAICqeQk4a04/5990cf2cef5f288cef54994219575d62/Computational_Complexity_2.png)</div>\nwhere p is a linear function representing the amount of work spent on splitting the sequence and merging the results.\n\\\nBasically, this is just a recurrence equation. If you don’t know this term, please don’t be afraid. The word “recurrence” stems from the latin phrase for “to run back”. Thus the name just says that the next values of f are defined using the previous (i.e. smaller) values of f.\n\\\nWell, to be really formal, for the equation to be complete we should specify some initial values – in this case, f (1). This (and knowing the implementation-specific function p) would enable us to compute the exact values of f.\n\\\nBut as you hopefully understand by now, this is not necessarily our goal. While it is theoretically possible to compute a closed-form formula for f (N), this formula would most probably be really ugly… and we don’t really need it. We only want to find a <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">-bound (and sometimes only an O-bound) on the growth of f. Luckily, this can often be done quite easily, if you know some tricks of the trade.\n\\\nAs a consequence, we won’t be interested in the exact form of p, all we need to know is that p(N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N). Also, we don’t need to specify the initial values for the equation. We simply assume that all problem instances with small N can be solved in constant time.\n\\\nThe rationale behind the last simplification: While changing the initial values does change the solution to the recurrence equation, it usually doesn’t change its asymptotic order of growth. (If your intuition fails you here, try playing with the equation above. For example fix p and try to compute f (8), f (16) and f (32) for different values of f (1).)\n\\\nIf this would be a formal textbook, at this point we would probably have to develop some theory that would allow us to deal with the floor and ceiling functions in our equations. Instead we will simply neglect them from now on. (E.g. we can assume that each division will be integer division, rounded down.)\n\\\nA reader skilled in math is encouraged to prove that if p is a polynomial (with non-negative values on N) and q(n) = p(n + 1) then q(n) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(n)). Using this observation we may formally prove that (assuming the f we seek is polynomially-bounded) the right side of each such equation remains asymptotically the same if we replace each ceiling function by a floor function.\n\\\nThe observations we made allow us to rewrite our example equation in a more simple way:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_3](https://images.ctfassets.net/b5f1djy59z3a/1PYsoE2tQMq6IIAIokIwyk/f12615b10713f1a5bb3f2c5e3228fe8c/Computational_Complexity_3.png)\n  <p>(1)</p></div>\nNote that this is not an equation in the classical sense. As in the examples in the first part of this article, the equals sign now reads “is asymptotically equal to”. Usually there are lots of different functions that satisfy such an equation. But usually all of them will have the same order of growth – and this is exactly what we want to determine. Or, more generally, we want to find the smallest upper bound on the growth of __all possible__ functions that satisfy the given equation.\n\\\nIn the last sections of this article we will discuss various methods of solving these “equations”. But before we can do that, we need to know a bit more about logarithms.\n\\\nNotes on logarithms\n\\\nBy now, you may have already asked one of the following questions: If the author writes that some complexity is e.g. O(N log N), what is the base of the logarithm? In some cases, wouldn’t O(N log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>N) be a better bound?\n\\\nThe answer: The base of the logarithm does not matter, all logarithmic functions (with base > 1) are asymptotically equal. This is due to the well-known equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_4](https://images.ctfassets.net/b5f1djy59z3a/4MgqQ4AXx6wEUE6Iy6QE2i/f23cf25e2c3da6b8ad786f00feedcf7d/Computational_Complexity_4.png)<p>(2)</p></div>\nNote that given two bases a, b, the number 1/log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>a is just a constant, and thus the function logaN is just a constant multiple of log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>N.\n\\\nTo obtain more clean and readable expressions, we always use the notation log N inside big-Oh expressions, even if logarithms with a different base were used in the computation of the bound.\n\\\nBy the way, sadly the meaning of log N differs from country to country. To avoid ambiguity where it may occur: I use log N to denote the decadic (i.e. base-10) logarithm, ln N for the natural (i.e. base-e) logarithm, lg N for the binary logarithm and log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">b</sub>N for the general case.\n\\\nNow we will show some useful tricks involving logarithms, we will need them later. Suppose a, b are given constants such that a, b > 1.\n\\\nFrom (2) we get:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_5](https://images.ctfassets.net/b5f1djy59z3a/2JQOSNo87Y6O4IYE4m6iUk/bae14f9aba4c8ae910ef544c0e04d482/Computational_Complexity_5.png)</div>\nUsing this knowledge, we can simplify the term ![new47](//images.ctfassets.net/piwi0eufbb2g/64l938UvNmbNHGd0zrr1gY/84fc017979b0aeaec5d4b2d334d19958/new47.png)\n<br/><div style=\"text-align:center;\">![new48](//images.ctfassets.net/piwi0eufbb2g/2GTJRokW8hwUUuNsVpIP0w/eeef30852f48b2905333f84a3b353085/new48.png)<p>(3)</p></div>\nThe substitution method\n\\\nThis method can be summarized in one sentence: Guess an asymptotic upper bound on f and (try to) prove it by induction.\n\\\nAs an example, we will prove that if f satisfies the equation (1) then f (N) = O(N log N).\n\\\nFrom (1) we know that:\n<br/><div style=\"text-align:center;\">![new52](//images.ctfassets.net/piwi0eufbb2g/64F3kJwlYijHjxwZtMGLlO/0d2085183ebbd4b94a35294c5843142b/new52.png)</div>\nfor some c. Now we will prove that if we take a large enough (but constant) d then for almost all N we have f (N) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> dN lg N. We will start by proving the induction step.\n\\\nAssume that f (N/2) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> d (N/2)lg(N/2). Then\n<br/><div style=\"text-align:center;\">![new57](//images.ctfassets.net/piwi0eufbb2g/5UH5U0XZkXHghwJT7ZIuqI/b77447ab9d64755777bbe264a5e1ee0e/new57.png)</div>\nIn other words, the induction step will hold as long as d > c. We are always able to choose such d.\n\\\nWe are only left with proving the inequality for some initial value N. This gets quite ugly when done formally. The general idea is that if the d we found so far is not large enough, we can always increase it to cover the initial cases.\n\\\nNote that for our example equation we won’t be able to prove it for N = 1, because lg 1 = 0. However, by taking f (N) <img src=\"https://images.ctfassets.net/piwi0eufbb2g/16tRqsa8M41CNzRCIJYy8V/6bae96234bdb0983401a97d62a180e59/img15.png\" style=\"position:relative; top:15px\"> dN lg N, where d is some fixed constant. Conclusion: from (1) it follows that f (N) = O(N lg N).\n\\\nThe recursion tree\n\\\nTo a beginner, the previous method won’t be very useful. To use it successfully we need to make a good guess – and to make a good guess we need some insight. The question is, how to gain this insight? Let’s take a closer look at what’s happening, when we try to evaluate the recurrence (or equivalently, when we run the corresponding recursive program).\n\\\nWe may describe the execution of a recursive program on a given input by a rooted tree. Each node will correspond to some instance of the problem the program solves. Consider an arbitrary vertex in our tree. If solving its instance requires recursive calls, this vertex will have children corresponding to the smaller subproblems we solve recursively. The root node of the tree is the input of the program, leaves represent small problems that are solved by brute force.\n\\\nNow suppose we label each vertex by the amount of work spent solving the corresponding problem (excluding the recursive calls). Clearly the runtime is exactly the sum of all labels.\n\\\nAs always, we only want an asymptotic bound. To achieve this, we may “round” the labels to make the summation easier. Again, we will demonstrate this method on examples.\n\\\n__Example 4.__ The recursion tree for MergeSort on 5 elements.\n<br/><div style=\"text-align:center;\">![tree1](//images.ctfassets.net/piwi0eufbb2g/2vEZy2el9aDX9tbgXjLJAk/b030404573d5657cbb86750fe3a08baa/tree1.png)</div>\nThe recursion tree for the corresponding recurrence equation. This time, the number inside each vertex represents the number of steps the algorithm makes there.\n<br/><div style=\"text-align:center;\">![tree2](//images.ctfassets.net/piwi0eufbb2g/6WGTZYJ4ZAPZk4uINWognb/5d1fd8d1e6253ff3faff81d01c7a737c/tree2.png)</div>\nNote that in a similar way we may sketch the general form of the recursion tree for any recurrence. Consider our old friend, the equation (1). Here we know that there is a number c such that the number of operations in each node can be bound by (c times the current value of N). Thus the tree in the example below is indeed the worst possible case.\n\\\n__Example 5.__ A worst-case tree for the general case of the recurrence equation (1).\n<br/><div style=\"text-align:center;\">![tree3](//images.ctfassets.net/piwi0eufbb2g/6yuqtsqtBEBNfwqltHQvYD/cdb2212e850d26c840f29ec08f4f5ea1/tree3.png)</div>\nNow, the classical trick from combinatorics is to sum the elements in an order different from the order in which they were created. In this case, consider an arbitrary level of the tree (i.e. a set of vertices with the same depth). It is not hard to see that the total work on each of the levels is cN.\n\\\nNow comes the second question: What is the number of levels? Clearly, the leaves correspond to the trivial cases of the algorithm. Note that the size of the problem is halved in each step. Clearly after lg N steps we are left with a trivial problem of size 1, thus the number of levels is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N).\n\\\nCombining both observations we get the final result: The total amount of work done here is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(cN x log N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n\\\nA side note. If the reader doesn’t trust the simplifications we made when using this method, he is invited to treat this method as a “way of making a good guess” and then to prove the result using the substitution method. However, with a little effort the application of this method could also be upgraded to a full formal proof.\n\\\nMore recursion trees\n\\\nBy now you should be asking: Was it really only a coincidence that the total amount of work on each of the levels in Example 5 was the same?\n\\\nThe answer: No and yes. No, there’s a simple reason why this happened, we’ll discover it later. Yes, because this is not always the case – as we’ll see in the following two examples.\n\\\n__Example 6.__ Let’s try to apply our new “recursion tree” method to solve the following recurrence equation:\n<br/><div style=\"text-align:center;\">![new72](//images.ctfassets.net/piwi0eufbb2g/ogXKwD5HVzKuddBLbSXBo/8fb141a9199787a0d2697dab5ff95fc6/new72.png)</div>\n\\\nThe recursion tree will look as follows:\n<br/><div style=\"text-align:center;\">![tree5](//images.ctfassets.net/piwi0eufbb2g/3VSFRdCsKVE7i4o9nQu2es/82fd95adec8a5b0c4246eae5cc07eb29/tree5.png)</div>\nLet’s try computing the total work for each of the first few levels. Our results:\n<br/><br/>\n| level | 1   | 2   | 3   | … |\n|-------|-----|-----|-----|---|\n| <div style=\"position:relative;top:-15px\">work</div>  | <div style=\"position:relative;top:-15px\">cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img16](//images.ctfassets.net/piwi0eufbb2g/5SEkV4yJ3iaFb6r14yaFaR/2e6260b520c7b8eaa122444a08f89458/img16.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img17](//images.ctfassets.net/piwi0eufbb2g/DXuNYbKPMbilIdFTcBwGy/a20e3ae785add765324a40219ec21e0a/img17.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"position:relative;top:-15px\">…</div> |\n<br/>\nClearly as we go deeper in the tree, the total amount of work on the current level decreases. The question is, how fast does it decrease? As we move one level lower, there will be three times that many subproblems. However, their size gets divided by 2, and thus the time to process each of them decreases to one eighth of the original time. Thus the amount of work is decreased by the factor 3/8.\n\\\nBut this means that the entries in the table above form a geometric progression. For a while assume that this progression is infinite. Then its sum would be\n<br/><div style=\"text-align:center;\">![new77](//images.ctfassets.net/piwi0eufbb2g/75cy2reJFkT2KE2vKqsoOy/31a1ec1d2eb01a571b2a03e7069681d0/new77.png)</div>\nThus the total amount of work in our tree is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) (summing the infinite sequence gives us an upper bound). But already the first element of our progression is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>). It follows that the total amount of work in our tree is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) and we are done.\n\\\nThe important generalization of this example: If the amounts of work at subsequent levels of the recursion tree form a __decreasing geometric progression__, the total amount of work is asymptotically the same as the amount of work done in the root node.\n\\\nFrom this result we can deduce an interesting fact about the (hypothetical) algorithm behind this recurrence equation: The recursive calls didn’t take much time in this case, the most time consuming part was preparing the recursive calls and/or processing the results. (I.e. this is the part that should be improved if we need a faster algorithm.)\n\\\n__Example 7.__ Now let’s try to apply our new “recursion tree” method to solve the following recurrence equation:\n<br/><div style=\"text-align:center;\">![new80](//images.ctfassets.net/piwi0eufbb2g/5Wyw3RJnFzgqlA1hK4sUzc/2198e3c1fae6addeb2d98acfb81ff3ef/new80.png)</div>\nThe recursion tree will look as follows:\n<br/><div style=\"text-align:center;\">![tree4](//images.ctfassets.net/piwi0eufbb2g/7MI5X0xGKmQU6RR8oeYVQH/3732983f075cf331bbfb7a82d7adc98d/tree4.png)</div>\nAgain, let’s try computing the total work for each of the first few levels. We get:\n<br/><br/>\n| level | 1   | 2   | 3   | … |\n|-------|-----|-----|-----|---|\n| <div style=\"position:relative;top:-15px\">work</div>  | <div style=\"position:relative;top:-15px\">cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img21](//images.ctfassets.net/piwi0eufbb2g/5CgK58HEHtfnfntlZYPcEc/98c4c0da9d0db3a545b389c4722a446c/img21.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"display:flex;\">![img22](//images.ctfassets.net/piwi0eufbb2g/7Gg1ALwlj3TsB3QpIHl0Wz/2512294d503f347bd15d6441c3004835/img22.png)cN<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub></div> | <div style=\"position:relative;top:-15px\">…</div> |\n<br/>\nThis time we have the opposite situation: As we go deeper in the tree, the total amount of work on the current level increases. As we move one level lower, there will be five times that many subproblems, each of them one third of the previous size, the processing time is linear in problem size. Thus the amount of work increased by the factor 5/3.\n\\\nAgain, we want to compute the total amount of work. This time it won’t be that easy, because the most work is done on the lowest level of the tree. We need to know its depth.\n\\\nThe lowest level corresponds to problems of size 1. The size of a problem on level k is N/3<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>. Solving the equation 1 = N/3<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub> we get k = log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>N. Note that this time we explicitly state the base of the logarithm, as this time it will be important.\n\\\nOur recursion tree has log<sub style=\"font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>N levels. Each of the levels has five times more vertices than the previous one, thus the last level has ![new89](//images.ctfassets.net/piwi0eufbb2g/1SmukeDxdG1GuSarDmDkkl/10685198c4e0867b475b048d8fd00f70/new89.png) levels. The total work done on this level is then ![new90](//images.ctfassets.net/piwi0eufbb2g/1FRsvs2MIA65AdRcG5ydDy/9bc604ebdc3fa85864d4ea5172d079f4/new90.png).\n\\\nNote that using the trick (3) we may rewrite this as ![new91](//images.ctfassets.net/piwi0eufbb2g/t6ZL1kGPMuG1y0xkuKzMK/5c054ba80b76172fc8f026c7b78f8619/new91.png).\n\\\nNow we want to sum the work done on all levels of the tree. Again, this is a geometric progression. But instead of explicitly computing the sum, we now __reverse__ it. Now we have a __decreasing__ geometric progression…and we are already in the same situation as in the previous example. Using the same reasoning we can show that the sum is asymptotically equal to the largest element.\n\\\nIt follows that the total amount of work in our tree is ![new92](//images.ctfassets.net/piwi0eufbb2g/2L64R8CZ5vytan2FAbZi5o/0ed5a6a567481f00051246d880a4f470/new92.png) and we are done.\n\\\nNote that the base-3 logarithm ends in the exponent, that’s why the base is important. If the base was different, also the result would be asymptotically different.\n\\\nThe Master Theorem\n\\\nWe already started to see a pattern here. Given a recurrence equation, take the corresponding recurrence tree and compute the amounts of work done on each level of the tree. You will get a geometric sequence. If it decreases, the total work is proportional to work done in the root node. If it increases, the total work is proportional to the number of leaves. If it remains the same, the total work is (the work done on one level) times (the number of levels).\n\\\nActually, there are a few ugly cases, but almost often one of these three cases occurs. Moreover, it is possible to prove the statements from the previous paragraph formally. The formal version of this theorem is known under the name Master Theorem.\n\\\nFor reference, we give the full formal statement of this theorem. (Note that knowing the formal proof is not necessary to __apply__ this theorem on a given recurrence equation.)\n\\\nLet a <img src=\"https://images.ctfassets.net/piwi0eufbb2g/48JqWlli2r8Wq9kJYPgGrf/7936cc3cc0cf229c233fa6da8bc6efb4/img24.png\" style=\"position:relative; top: 15px;\"> 1 and b > 1 be integer constants. Let p be a non-negative non-decreasing function. Let f be any solution of the recurrence equation\n<br/><div style=\"text-align:center;\">![new95](//images.ctfassets.net/piwi0eufbb2g/3H3wLzjQSunZVkqx9Lt9qy/f352b06489eb0d1ec164a07875e3d718/new95.png)</div>\nThen\n<br/>\n1. If ![new96](//images.ctfassets.net/piwi0eufbb2g/M0Qqw1L1K8QxwyexHNCYL/36666284053af8cd8eed43569a0c35b6/new96.png) for some ![img26](//images.ctfassets.net/piwi0eufbb2g/7b4QExfhi9RQajtgPtSS7h/6d8083fdd1327d53a2a9646cc8b8a25b/img26.png) > 0 then ![new98](//images.ctfassets.net/piwi0eufbb2g/5gBXAJoTWJB3GafLfx8mAR/1e6574f91620b3cd6497a10b91736270/new98.png)\n2. If , then f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(N)log N).\n3. If  for some  > 0, and if ap(N/b)  cp(N) for some c < 1 and for almost all N, then f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(p(N)).\n\n<br/>Case 1 corresponds to our Example 7. Most of the time is spent making the recursive calls and it’s the number of these calls that counts.\n\\\nCase 2 corresponds to our Example 5. The time spent making the calls is roughly equal to the time to prepare the calls and process the results. On all levels of the recursion tree we do roughly the same amount of work, the depth of the tree is always logarithmic.\n\\\nCase 3 corresponds to our Example 6. Most of the time is spent on preparing the recursive calls and processing the results. Usually the result will be asymptotically equal to the time spent in the root node.\n\\\nNote the word “usually” and the extra condition in Case 3. For this result to hold we need p to be somehow “regular” – in the sense that for each node in the recursion tree the time spent in the node must be greater than the time spent in its chidren (excluding further recursive calls). This is nothing to worry about too much, most probably all functions p you will encounter in practice will satisfy this condition (if they satisfy the first condition of Case 3).\n\\\n__Example 8.__ Let f (N) be the time Strassen’s fast matrix multiplication algorithm needs to multiply two N x N square matrices. This is a recursive algorithm, that makes 7 recursive calls, each time multiplying two (N/2) x (N/2) square matrices, and then computes the answer in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) time.\n\\\nThis leads us to the following recurrence equation:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_3](https://images.ctfassets.net/b5f1djy59z3a/1PYsoE2tQMq6IIAIokIwyk/f12615b10713f1a5bb3f2c5e3228fe8c/Computational_Complexity_3.png)</div>\nUsing the Master Theorem, we see that Case 1 applies. Thus the time complexity of Strassen’s algorithm is . Note that by implementing the definition of matrix multiplication we get only a <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>) algorithm.\n\\\n__Example 9.__ Occasionally we may encounter the situation when the problems in the recursive calls are not of the same size. An example may be the “median-of-five” algorithm to find the k-th element of an array. It can be shown that its time complexity satisfies the recurrence equation:\n<br/><div style=\"text-align:center;\">![new110](//images.ctfassets.net/piwi0eufbb2g/74WaKVRGFyA7jAPbFrEArc/5aadd01ab15764bf5c1ed78a6f029b88/new110.png)</div>\nHow to solve it? Can the recursion tree be applied also in such asymmetric cases? Is there a more general version of Master Theorem that handles also these cases? And what should I do with the recurrence f (N) = 4f (N/4) + <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N), where the Master Theorem doesn’t apply?\n\\\nWe won’t answer these questions here. This article doesn’t claim to be the one and only reference to computational complexity. If you are already asking these questions, you understand the basics you need for programming challenges – and if you are interested in knowing more, there are good books around that can help you.\n\\\nThanks for reading this far. If you have any questions, comments, bug reports or any other feedback, please use the Round tables. I’ll do my best to answer.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":12,"downvotes":1,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3rAZrsBseux2curmx1if6s","type":"Entry","createdAt":"2020-02-20T12:38:07.258Z","updatedAt":"2024-08-07T14:00:23.815Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":571,"revision":58,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part one","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505848)\n<br/>\nIn this article I’ll try to introduce you to the area of computation complexity. The article will be a bit long before we get to the actual formal definitions because I feel that the rationale behind these definitions needs to be explained as well – and that understanding the rationale is even more important than the definitions alone.\n\\\nWhy is it important?\n\\\n__Example 1.__ Suppose you were assigned to write a program to process some records your company receives from time to time. You implemented two different algorithms and tested them on several sets of test data. The processing times you obtained are in Table 1.\n<br/>\n__Table 1. Runtimes of two fictional algorithms.__\n| # of records | 10    | 20    | 50    | 100   | 1000   | 5000   |\n|--------------|-------|-------|-------|-------|--------|--------|\n| algorithm 1  | 0.00s | 0.01s | 0.05s | 0.47s | 23.92s | 47min  |\n| algorithm 2  | 0.05s | 0.05s | 0.06s | 0.11s | 0.78s  | 14.22s |\n<br/>\nIn praxis, we probably could tell which of the two implementations is better for us (as we usually can estimate the amount of data we will have to process). For the company this solution may be fine. But from the programmer’s point of view, it would be much better if he could estimate the values in Table 1 __before__ writing the actual code – then he could only implement the better algorithm.\n\\\nThe same situation occurs during programming challenges: The size of the input data is given in the problem statement. Suppose I found an algorithm. Questions I have to answer before I start to type should be: Is my algorithm worth implementing? Will it solve the largest test cases in time? If I know more algorithms solving the problem, which of them shall I implement?\n\\\nThis leads us to the question: How to compare algorithms? Before we answer this question in general, let’s return to our simple example. If we extrapolate the data in Table 1, we may assume that if the number of processed records is larger than 1000, algorithm 2 will be substantially faster. In other words, if we consider all possible inputs, algorithm 2 will be better for almost all of them.\n\\\nIt turns out that this is almost always the case – given two algorithms, either one of them is almost always better, or they are approximately the same. Thus, this will be our definition of a better algorithm. Later, as we define everything formally, this will be the general idea behind the definitions.\n\\\nA neat trick\n\\\nIf you thing about Example 1 for a while, it shouldn’t be too difficult to see that there is an algorithm with runtimes similar to those in Table 2:\n<br/>\n__Table 2. Runtimes of a new fictional algorithm.__\n| # of records | 10    | 20    | 50    | 100   | 1000  | 5000   |\n|--------------|-------|-------|-------|-------|-------|--------|\n| algorithm 3  | 0.00s | 0.01s | 0.05s | 0.11s | 0.78s | 14.22s |\n<br/>\nThe idea behind this algorithm: Check the number of records. If it is small enough, run algorithm 1, otherwise run algorithm 2.\n\\\nSimilar ideas are often used in praxis. As an example consider most of the sort() functions provided by various libraries. Often this function is an implementation of QuickSort with various improvements, such as:\n- if the number of elements is too small, run InsertSort instead (as InsertSort is faster for small inputs)\n- if the pivot choices lead to poor results, fall back to MergeSort\n\n<br/>What is efficiency?\n\\\n__Example 2.__ Suppose you have a concrete implementation of some algorithm. (The example code presented below is actually an implementation of MinSort – a slow but simple sorting algorithm.)\n<br/>\n```\nfor (int i=0; i<N; i++)\nfor (int j=i+1; j<N; j++)\nif (A[i] > A[j])\nswap( A[i], A[j] );\n```\n\\\nIf we are given an input to this algorithm (in our case, the array A and its size N), we can exactly compute the number of steps our algorithm does on this input. We could even count the processor instructions if we wanted to. However, there are too many possible inputs for this approach to be practical.\n\\\nAnd we still need to answer one important question: What is it exactly we are interested in? Most usually it is the behavior of our program in the __worst possible case__ – we need to look at the input data and to determine an upper bound on how long will it take if we run the program.\n\\\nBut then, what is the worst possible case? Surely we can always make the program run longer simply by giving it a larger input. Some of the more important questions are: What is the worst input with 700 elements? __How fast__ does the maximum runtime grow when we increase the input size?\n\\\nFormal notes on the input size\n\\\nWhat exactly is this “input size” we started to talk about? In the formal definitions this is the size of the input written in some fixed finite alphabet (with at least 2 “letters”). For our needs, we may consider this alphabet to be the numbers 0…255. Then the “input size” turns out to be exactly the size of the input file in bytes.\n\\\nUsually a part of the input is a number (or several numbers) such that the size of the input is proportional to the number.\n\\\nE.g. in Example 2 we are given an int N and an array containing N ints. The size of the input file will be roughly 5N (depending on the OS and architecture, but always linear in N).\n\\\nIn such cases, we may choose that this number will represent the size of the input. Thus when talking about problems on arrays/strings, the input size is the length of the array/string, when talking about graph problems, the input size depends both on the number of vertices (N) and the number of edges (M), etc.\n\\\nWe will adopt this approach and use N as the input size in the following parts of the article.\n\\\nThere is one tricky special case you sometimes need to be aware of. To write a (possibly large) number we need only logarithmic space. (E.g. to write 123456, we need only roughly log<sub style=\"bottom: -.25em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">10</sub>(123456) digits.) This is why the naive primality test does not run in polynomial time – its runtime is polynomial in the __size__ of the number, but not in its __number of digits__! If you didn’t understand the part about polynomial time, don’t worry, we’ll get there later.\n\\\nHow to measure efficiency?\n\\\nWe already mentioned that given an input we are able to count the number of steps an algorithm makes simply by simulating it. Suppose we do this for all inputs of size at most __N__ and find the worst of these inputs (i.e. the one that causes the algorithm to do the most steps). Let f (__N__) be this number of steps. We will call this function the time complexity, or shortly the runtime of our algorithm.\n\\\nIn other words, if we have any input of size __N__, solving it will require at most f (__N__) steps.\n\\\nLet’s return to the algorithm from Example 2. What is the worst case of size __N__? In other words, what array with __N__ elements will cause the algorithm to make the most steps? If we take a look at the algorithm, we can easily see that:\n- the first step is executed exactly N times\n- the second and third step are executed exactly N(N – 1)/2 times\n- the fourth step is executed at most N(N – 1)/2 times\n\n<br/>Clearly, if the elements in A are in descending order at the beginning, the fourth step will always be executed. Thus in this case the algorithm makes 3N(__N__ – 1)/2 + __N__ = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N steps. Therefore our algorithm has f (__N__) = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N.\n\\\nAs you can see, determining the exact function f for more complicated programs is painful. Moreover, it isn’t even necessary. In our case, clearly the -0.5N term can be neglected. It will usually be much smaller than the 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> term and it won’t affect the runtime significantly. The result “f (__N__) is roughly equal to 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>” gives us all the information we need. As we will show now, if we want to compare this algorithm with some other algorithm solving the same problem, even the constant 1.5 is not that important.\n\\\nConsider two algorithms, one with the runtime N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, the other with the runtime 0.001N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>. One can easily see that for N greater than 1 000 the first algorithm is faster – and soon this difference becomes apparent. While the first algorithm is able to solve inputs with N = 20 000 in a matter of seconds, the second one will already need several minutes on current machines.\n\\\nClearly this will occur always when one of the runtime functions grows __asymptotically faster__ than the other (i.e. when N grows beyond all bounds the limit of their quotient is zero or infinity). Regardless of the constant factors, an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> will always be better than an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub> __on almost all inputs__. And this observation is exactly what we base our formal definition on.\n\\\nFinally, formal definitions\n\\\nLet f, g be positive non-decreasing functions defined on positive integers. (Note that all runtime functions satisfy these conditions.) We say that f (N) is O(g(N)) (read: f is big-oh of g) if for some c and N0 the following condition holds:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_1.png](https://images.ctfassets.net/b5f1djy59z3a/22I9okwtiQ8w86WCCuyy2a/6b44bf4a6736db87aa793e7837a3df89/Computational_Complexity_1.png)</div>\nIn human words, f (N) is O(g(N)), if for some c almost the entire graph of the function f is below the graph of the function c.g. Note that this means that f grows at most as fast as c.g does.\n\\\nInstead of “f (N) is O(g(N))” we usually write f (N) = O(g(N)). Note that this “equation” is __not symmetric__ – the notion \" O(g(N)) = f (N)\" has no sense and \" g(N) = O(f (N))\" doesn’t have to be true (as we will see later). (If you are not comfortable with this notation, imagine O(g(N)) to be a set of functions and imagine that there is a E instead of =.)\n\\\nWhat we defined above is known as the big-oh notation and is conveniently used to specify upper bounds on function growth.\n\\\nE.g. consider the function f (N) = 3N(N – 1)/2 + N = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N from Example 2. We may say that f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) (one possibility for the constants is c = 2 and N<sub style=\"bottom: -2.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">0</sub> = 0). This means that f doesn’t grow (asymptotically) faster than N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nNote that even the exact runtime function f doesn’t give an exact answer to the question “How long will the program run on my machine?” But the important observation in the example case is that the runtime function is quadratic. If we double the input size, the runtime will increase approximately to four times the current runtime, no matter how fast our computer is.\n\\\nThe f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) upper bound gives us almost the same – it guarantees that the growth of the runtime function is at most quadratic.\n\\\nThus, we will use the O-notation to describe the time (and sometimes also memory) complexity of algorithms. For the algorithm from Example 2 we would say “The time complexity of this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” or shortly “This algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”.\n\\\nIn a similar way we defined O we may define <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">.\n\\\nWe say that f (N) is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> (g(N)) if g(N) = O(f (N)), in other words if f grows at least as fast as g.\n\\\nWe say that f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> (g(N)) if f (N) = O(g(N)) and g(N) = O(f (N)), in other words if both functions have approximately the same rate of growth.\n\\\nAs it should be obvious,  is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> used to specify lower bounds and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> is used to give a tight asymptotic bound on a function. There are other similar bounds, but these are the ones you’ll encounter most of the time.\n\\\nSome examples of using the notation:\n- 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> -0.5N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- 47N log N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- N log N + 1 000 047N = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n- All polynomials of order k are O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>).\n- The time complexity of the algorithm in Example 2 is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- If an algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), it is also O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">5</sub>).\n- Each comparision-based sorting algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N log N).\n- MergeSort run on an array with N elements does roughly N log N comparisions. Thus the time complexity of MergeSort is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N). If we trust the previous statement, this means that MergeSort is an asymptotically optimal general sorting algorithm.\n- The algorithm in Example 2 uses <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) bytes of memory.\n- The function giving my number of teeth in time is O(1).\n- A naive backtracking algorithm trying to solve chess is O(1) as the tre of positions it will examine is finite. (But of course in this case the constant hidden behind the O(1) is unbelievably large.)\n- The statement “Time complexity of this algorithm is at least O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” is meaningless. (It says: “Time complexity of this algorithm is at least at most roughly quadratic.” The speaker probably wanted to say: “Time complexity of this algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).”)\n\n<br/>When speaking about the time/memory complexity of an algorithm, instead of using the formal <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(f (n))-notation we may simply state the class of functions f belongs to. E.g. if f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N), we call the algorithm linear. More examples:\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N): logarithmic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2): quadratic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3): cubic\n- f (N) = O(Nk) for some k: polynomial\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(2N): exponential\n\n<br/>For graph problems, the complexity <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N + M) is known as “linear in the graph size”.\n\\\nDetermining execution time from an asymptotic bound\n\\\nFor most algorithms you may encounter in praxis, the constant hidden behind the O (or <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">) is usually relatively small. If an algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), you may expect that the exact time complexity is something like 10N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, not 10<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">7</sub>N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nThe same observation in other words: if the constant is large, it is usually somehow related to some constant in the problem statement. In this case it is good practice to give this constant a name and to include it in the asymptotic notation.\n\\\nAn example: The problem is to count occurences of each letter in a string of N letters. A naive algorithm passes through the whole string once for each possible letter. The size of alphabet is fixed (e.g. at most 255 in C), thus the algorithm is linear in N. Still, it is better to write that its time complexity is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S|.N), where S is the alphabet used. (Note that there is a better algorithm solving this problem in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S| + N).)\n\\\nIn a topcoder contest, an algorithm doing 1 000 000 000 multiplications runs barely in time. This fact together with the above observation and some experience with topcoder problems can help us fill the following table:\n<br/>\n__Table 3. Approximate maximum problem size solvable in 8 seconds.__\n| complexity | maximum N   |\n|------------|-------------|\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N)        | 100 000 000 |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N)  | 40 000 000  |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2)       | 10 000      |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3)       | 500         |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N4)       | 90          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(2N)       | 20          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N!)       | 11          |\n<br/>\nA note on algorithm analysis\n\\\nUsually if we present an algorithm, the best way to present its time complexity is to give a . However, it is common practice to only give an O-bound - the other bound is usually trivial, O is much easier to type and better known. Still, don’t forget that O represents only an upper bound. Usually we try to find an O-bound that’s as good as possible.\n\\\n__Example 3.__ Given is a sorted array A. Determine whether it contains two elements with the difference D. Consider the following code solving this problem:\n<br/>\n```\nint j=0;\nfor (int i=0; i<N; i++) {\nwhile ( (j<N-1) && (A[i]-A[j] > D) )\nj++;\nif (A[i]-A[j] == D) return 1;\n}\n```\n\\\nIt is easy to give an O(N2) bound for the time complexity of this algorithm – the inner while-cycle is called N times, each time we increase j at most N times. But a more careful analysis shows that in fact we can give an O(N) bound on the time complexity of this algorithm – it is sufficient to realize that during the __whole execution__ of the algorithm the command “__j++__;” is executed no more than N times.\n\\\nIf we said “this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”, we would have been right. But by saying “this algorithm is O(N)” we give more information about the algorithm.\n\\\n__Conclusion__\n\\\nWe have shown how to write bounds on the time complexity of algorithms. We have also demonstrated why this way of characterizing algorithms is natural and (usually more-or-less) sufficient.\n\\\nThe next logical step is to show how to estimate the time complexity of a given algorithm. As we have already seen in Example 3, sometimes this can be messy. It gets really messy when recursion is involved. We will address these issues in the second part of this article.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20two)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":22,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7mQBfgaWnYKbVjOp2MeCxm","circular":true}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"7mQBfgaWnYKbVjOp2MeCxm","circular":true}}}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3rAZrsBseux2curmx1if6s","type":"Entry","createdAt":"2020-02-20T12:38:07.258Z","updatedAt":"2024-08-07T14:00:23.815Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":571,"revision":58,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Computational Complexity part one","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":["Algorithms","C++","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"20 min read","content":"[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&forumID=505848)\n<br/>\nIn this article I’ll try to introduce you to the area of computation complexity. The article will be a bit long before we get to the actual formal definitions because I feel that the rationale behind these definitions needs to be explained as well – and that understanding the rationale is even more important than the definitions alone.\n\\\nWhy is it important?\n\\\n__Example 1.__ Suppose you were assigned to write a program to process some records your company receives from time to time. You implemented two different algorithms and tested them on several sets of test data. The processing times you obtained are in Table 1.\n<br/>\n__Table 1. Runtimes of two fictional algorithms.__\n| # of records | 10    | 20    | 50    | 100   | 1000   | 5000   |\n|--------------|-------|-------|-------|-------|--------|--------|\n| algorithm 1  | 0.00s | 0.01s | 0.05s | 0.47s | 23.92s | 47min  |\n| algorithm 2  | 0.05s | 0.05s | 0.06s | 0.11s | 0.78s  | 14.22s |\n<br/>\nIn praxis, we probably could tell which of the two implementations is better for us (as we usually can estimate the amount of data we will have to process). For the company this solution may be fine. But from the programmer’s point of view, it would be much better if he could estimate the values in Table 1 __before__ writing the actual code – then he could only implement the better algorithm.\n\\\nThe same situation occurs during programming challenges: The size of the input data is given in the problem statement. Suppose I found an algorithm. Questions I have to answer before I start to type should be: Is my algorithm worth implementing? Will it solve the largest test cases in time? If I know more algorithms solving the problem, which of them shall I implement?\n\\\nThis leads us to the question: How to compare algorithms? Before we answer this question in general, let’s return to our simple example. If we extrapolate the data in Table 1, we may assume that if the number of processed records is larger than 1000, algorithm 2 will be substantially faster. In other words, if we consider all possible inputs, algorithm 2 will be better for almost all of them.\n\\\nIt turns out that this is almost always the case – given two algorithms, either one of them is almost always better, or they are approximately the same. Thus, this will be our definition of a better algorithm. Later, as we define everything formally, this will be the general idea behind the definitions.\n\\\nA neat trick\n\\\nIf you thing about Example 1 for a while, it shouldn’t be too difficult to see that there is an algorithm with runtimes similar to those in Table 2:\n<br/>\n__Table 2. Runtimes of a new fictional algorithm.__\n| # of records | 10    | 20    | 50    | 100   | 1000  | 5000   |\n|--------------|-------|-------|-------|-------|-------|--------|\n| algorithm 3  | 0.00s | 0.01s | 0.05s | 0.11s | 0.78s | 14.22s |\n<br/>\nThe idea behind this algorithm: Check the number of records. If it is small enough, run algorithm 1, otherwise run algorithm 2.\n\\\nSimilar ideas are often used in praxis. As an example consider most of the sort() functions provided by various libraries. Often this function is an implementation of QuickSort with various improvements, such as:\n- if the number of elements is too small, run InsertSort instead (as InsertSort is faster for small inputs)\n- if the pivot choices lead to poor results, fall back to MergeSort\n\n<br/>What is efficiency?\n\\\n__Example 2.__ Suppose you have a concrete implementation of some algorithm. (The example code presented below is actually an implementation of MinSort – a slow but simple sorting algorithm.)\n<br/>\n```\nfor (int i=0; i<N; i++)\nfor (int j=i+1; j<N; j++)\nif (A[i] > A[j])\nswap( A[i], A[j] );\n```\n\\\nIf we are given an input to this algorithm (in our case, the array A and its size N), we can exactly compute the number of steps our algorithm does on this input. We could even count the processor instructions if we wanted to. However, there are too many possible inputs for this approach to be practical.\n\\\nAnd we still need to answer one important question: What is it exactly we are interested in? Most usually it is the behavior of our program in the __worst possible case__ – we need to look at the input data and to determine an upper bound on how long will it take if we run the program.\n\\\nBut then, what is the worst possible case? Surely we can always make the program run longer simply by giving it a larger input. Some of the more important questions are: What is the worst input with 700 elements? __How fast__ does the maximum runtime grow when we increase the input size?\n\\\nFormal notes on the input size\n\\\nWhat exactly is this “input size” we started to talk about? In the formal definitions this is the size of the input written in some fixed finite alphabet (with at least 2 “letters”). For our needs, we may consider this alphabet to be the numbers 0…255. Then the “input size” turns out to be exactly the size of the input file in bytes.\n\\\nUsually a part of the input is a number (or several numbers) such that the size of the input is proportional to the number.\n\\\nE.g. in Example 2 we are given an int N and an array containing N ints. The size of the input file will be roughly 5N (depending on the OS and architecture, but always linear in N).\n\\\nIn such cases, we may choose that this number will represent the size of the input. Thus when talking about problems on arrays/strings, the input size is the length of the array/string, when talking about graph problems, the input size depends both on the number of vertices (N) and the number of edges (M), etc.\n\\\nWe will adopt this approach and use N as the input size in the following parts of the article.\n\\\nThere is one tricky special case you sometimes need to be aware of. To write a (possibly large) number we need only logarithmic space. (E.g. to write 123456, we need only roughly log<sub style=\"bottom: -.25em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">10</sub>(123456) digits.) This is why the naive primality test does not run in polynomial time – its runtime is polynomial in the __size__ of the number, but not in its __number of digits__! If you didn’t understand the part about polynomial time, don’t worry, we’ll get there later.\n\\\nHow to measure efficiency?\n\\\nWe already mentioned that given an input we are able to count the number of steps an algorithm makes simply by simulating it. Suppose we do this for all inputs of size at most __N__ and find the worst of these inputs (i.e. the one that causes the algorithm to do the most steps). Let f (__N__) be this number of steps. We will call this function the time complexity, or shortly the runtime of our algorithm.\n\\\nIn other words, if we have any input of size __N__, solving it will require at most f (__N__) steps.\n\\\nLet’s return to the algorithm from Example 2. What is the worst case of size __N__? In other words, what array with __N__ elements will cause the algorithm to make the most steps? If we take a look at the algorithm, we can easily see that:\n- the first step is executed exactly N times\n- the second and third step are executed exactly N(N – 1)/2 times\n- the fourth step is executed at most N(N – 1)/2 times\n\n<br/>Clearly, if the elements in A are in descending order at the beginning, the fourth step will always be executed. Thus in this case the algorithm makes 3N(__N__ – 1)/2 + __N__ = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N steps. Therefore our algorithm has f (__N__) = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N.\n\\\nAs you can see, determining the exact function f for more complicated programs is painful. Moreover, it isn’t even necessary. In our case, clearly the -0.5N term can be neglected. It will usually be much smaller than the 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> term and it won’t affect the runtime significantly. The result “f (__N__) is roughly equal to 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>” gives us all the information we need. As we will show now, if we want to compare this algorithm with some other algorithm solving the same problem, even the constant 1.5 is not that important.\n\\\nConsider two algorithms, one with the runtime N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, the other with the runtime 0.001N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub>. One can easily see that for N greater than 1 000 the first algorithm is faster – and soon this difference becomes apparent. While the first algorithm is able to solve inputs with N = 20 000 in a matter of seconds, the second one will already need several minutes on current machines.\n\\\nClearly this will occur always when one of the runtime functions grows __asymptotically faster__ than the other (i.e. when N grows beyond all bounds the limit of their quotient is zero or infinity). Regardless of the constant factors, an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> will always be better than an algorithm with runtime proportional to N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">3</sub> __on almost all inputs__. And this observation is exactly what we base our formal definition on.\n\\\nFinally, formal definitions\n\\\nLet f, g be positive non-decreasing functions defined on positive integers. (Note that all runtime functions satisfy these conditions.) We say that f (N) is O(g(N)) (read: f is big-oh of g) if for some c and N0 the following condition holds:\n<br/><div style=\"text-align:center;\">![Computational_Complexity_1.png](https://images.ctfassets.net/b5f1djy59z3a/22I9okwtiQ8w86WCCuyy2a/6b44bf4a6736db87aa793e7837a3df89/Computational_Complexity_1.png)</div>\nIn human words, f (N) is O(g(N)), if for some c almost the entire graph of the function f is below the graph of the function c.g. Note that this means that f grows at most as fast as c.g does.\n\\\nInstead of “f (N) is O(g(N))” we usually write f (N) = O(g(N)). Note that this “equation” is __not symmetric__ – the notion \" O(g(N)) = f (N)\" has no sense and \" g(N) = O(f (N))\" doesn’t have to be true (as we will see later). (If you are not comfortable with this notation, imagine O(g(N)) to be a set of functions and imagine that there is a E instead of =.)\n\\\nWhat we defined above is known as the big-oh notation and is conveniently used to specify upper bounds on function growth.\n\\\nE.g. consider the function f (N) = 3N(N – 1)/2 + N = 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> – 0.5N from Example 2. We may say that f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) (one possibility for the constants is c = 2 and N<sub style=\"bottom: -2.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">0</sub> = 0). This means that f doesn’t grow (asymptotically) faster than N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nNote that even the exact runtime function f doesn’t give an exact answer to the question “How long will the program run on my machine?” But the important observation in the example case is that the runtime function is quadratic. If we double the input size, the runtime will increase approximately to four times the current runtime, no matter how fast our computer is.\n\\\nThe f (N) = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>) upper bound gives us almost the same – it guarantees that the growth of the runtime function is at most quadratic.\n\\\nThus, we will use the O-notation to describe the time (and sometimes also memory) complexity of algorithms. For the algorithm from Example 2 we would say “The time complexity of this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” or shortly “This algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”.\n\\\nIn a similar way we defined O we may define <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">.\n\\\nWe say that f (N) is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> (g(N)) if g(N) = O(f (N)), in other words if f grows at least as fast as g.\n\\\nWe say that f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> (g(N)) if f (N) = O(g(N)) and g(N) = O(f (N)), in other words if both functions have approximately the same rate of growth.\n\\\nAs it should be obvious,  is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\"> used to specify lower bounds and <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\"> is used to give a tight asymptotic bound on a function. There are other similar bounds, but these are the ones you’ll encounter most of the time.\n\\\nSome examples of using the notation:\n- 1.5N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub> -0.5N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- 47N log N = O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- N log N + 1 000 047N = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N).\n- All polynomials of order k are O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">k</sub>).\n- The time complexity of the algorithm in Example 2 is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).\n- If an algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), it is also O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">5</sub>).\n- Each comparision-based sorting algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N log N).\n- MergeSort run on an array with N elements does roughly N log N comparisions. Thus the time complexity of MergeSort is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N). If we trust the previous statement, this means that MergeSort is an asymptotically optimal general sorting algorithm.\n- The algorithm in Example 2 uses <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N) bytes of memory.\n- The function giving my number of teeth in time is O(1).\n- A naive backtracking algorithm trying to solve chess is O(1) as the tre of positions it will examine is finite. (But of course in this case the constant hidden behind the O(1) is unbelievably large.)\n- The statement “Time complexity of this algorithm is at least O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)” is meaningless. (It says: “Time complexity of this algorithm is at least at most roughly quadratic.” The speaker probably wanted to say: “Time complexity of this algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>).”)\n\n<br/>When speaking about the time/memory complexity of an algorithm, instead of using the formal <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(f (n))-notation we may simply state the class of functions f belongs to. E.g. if f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N), we call the algorithm linear. More examples:\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(log N): logarithmic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2): quadratic\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3): cubic\n- f (N) = O(Nk) for some k: polynomial\n- f (N) = <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/SM9V0Z14CXpOrBMRd5084/7947f888cde28f1bdc873af13513fc52/complexity3.png\">(2N): exponential\n\n<br/>For graph problems, the complexity <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N + M) is known as “linear in the graph size”.\n\\\nDetermining execution time from an asymptotic bound\n\\\nFor most algorithms you may encounter in praxis, the constant hidden behind the O (or <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">) is usually relatively small. If an algorithm is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>), you may expect that the exact time complexity is something like 10N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>, not 10<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">7</sub>N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>.\n\\\nThe same observation in other words: if the constant is large, it is usually somehow related to some constant in the problem statement. In this case it is good practice to give this constant a name and to include it in the asymptotic notation.\n\\\nAn example: The problem is to count occurences of each letter in a string of N letters. A naive algorithm passes through the whole string once for each possible letter. The size of alphabet is fixed (e.g. at most 255 in C), thus the algorithm is linear in N. Still, it is better to write that its time complexity is <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S|.N), where S is the alphabet used. (Note that there is a better algorithm solving this problem in <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(| S| + N).)\n\\\nIn a topcoder contest, an algorithm doing 1 000 000 000 multiplications runs barely in time. This fact together with the above observation and some experience with topcoder problems can help us fill the following table:\n<br/>\n__Table 3. Approximate maximum problem size solvable in 8 seconds.__\n| complexity | maximum N   |\n|------------|-------------|\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N)        | 100 000 000 |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N log N)  | 40 000 000  |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N2)       | 10 000      |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N3)       | 500         |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N4)       | 90          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(2N)       | 20          |\n| <img width=\"15\" height=\"14\" align=\"bottom\" border=\"0\" src=\"http://images.ctfassets.net/piwi0eufbb2g/6Z5qzbtqiR7YD5Q8YEAC3U/c61f8064de574235e0c2dc43a3afea98/complexity4.png\">(N!)       | 11          |\n<br/>\nA note on algorithm analysis\n\\\nUsually if we present an algorithm, the best way to present its time complexity is to give a . However, it is common practice to only give an O-bound - the other bound is usually trivial, O is much easier to type and better known. Still, don’t forget that O represents only an upper bound. Usually we try to find an O-bound that’s as good as possible.\n\\\n__Example 3.__ Given is a sorted array A. Determine whether it contains two elements with the difference D. Consider the following code solving this problem:\n<br/>\n```\nint j=0;\nfor (int i=0; i<N; i++) {\nwhile ( (j<N-1) && (A[i]-A[j] > D) )\nj++;\nif (A[i]-A[j] == D) return 1;\n}\n```\n\\\nIt is easy to give an O(N2) bound for the time complexity of this algorithm – the inner while-cycle is called N times, each time we increase j at most N times. But a more careful analysis shows that in fact we can give an O(N) bound on the time complexity of this algorithm – it is sufficient to realize that during the __whole execution__ of the algorithm the command “__j++__;” is executed no more than N times.\n\\\nIf we said “this algorithm is O(N<sub style=\"top: -.5em;font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;\">2</sub>)”, we would have been right. But by saying “this algorithm is O(N)” we give more information about the algorithm.\n\\\n__Conclusion__\n\\\nWe have shown how to write bounds on the time complexity of algorithms. We have also demonstrated why this way of characterizing algorithms is natural and (usually more-or-less) sufficient.\n\\\nThe next logical step is to show how to estimate the time complexity of a given algorithm. As we have already seen in Example 3, sometimes this can be messy. It gets really messy when recursion is involved. We will address these issues in the second part of this article.\n\\\n[…continue to Section 2](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20two)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"15hZ81f4IwUr58BBvJwPrf","type":"Entry","createdAt":"2019-11-28T11:58:14.181Z","updatedAt":"2020-03-31T13:36:21.559Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"misof","tcHandle":"misof","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}}}}],"upvotes":22,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7mQBfgaWnYKbVjOp2MeCxm","circular":true}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"7mQBfgaWnYKbVjOp2MeCxm","circular":true}}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7sLraZ4JsIbN18QeRKgFd","type":"Entry","createdAt":"2019-09-18T07:37:36.197Z","updatedAt":"2019-10-15T15:59:38.697Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Anatolijs Gorbunovs","tcHandle":"gorbunov"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7u469mHPmtr1Q0m5IR4uQ5","type":"Entry","createdAt":"2020-03-28T08:51:00.372Z","updatedAt":"2020-04-01T06:30:01.918Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"monsoon","tcHandle":"monsoon","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"35zK7ZbTYMEaHAQD2viKKT","type":"Asset","createdAt":"2020-04-01T06:29:58.074Z","updatedAt":"2020-04-01T06:29:58.074Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"monsoon big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/35zK7ZbTYMEaHAQD2viKKT/94c375c5ef56a6206470204f364cb3ef/monsoon_big.jpg","details":{"size":4594,"image":{"width":126,"height":140}},"fileName":"monsoon_big.jpg","contentType":"image/jpeg"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7wTYn5b5dSXJnSR7DDKJuQ","type":"Entry","createdAt":"2019-12-28T15:05:40.169Z","updatedAt":"2021-12-02T14:55:43.939Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":48,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot Incentives","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-09-03","readTime":"5 min read","content":"Copilots earn money by delivering outcomes/deliverables for their projects on time, with high quality, and consistent with Topcoder best practices.\n\nCurrently, Copilots are mainly paid based on the completion of successful challenges and tasks they run.  Unless otherwise noted, the standard payments are as follows:\n\n| Work Type                         | Payment (per challenge) |\n|-----------------------------------|-------------------------|\n| First 2 Finish Challenges         | $40                     |\n| Design and Development Challenges | $600                    |\n| Marathon Matches                  | TBD                     |\n\n\n__Note:__ Check back here often for changes.  Topcoder will look to optimize incentive structures to promote the best structure for copilots, the community, and customers.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4aFVL8lFVxQeT2Ey3AMLjy","type":"Entry","createdAt":"2019-12-28T15:05:40.149Z","updatedAt":"2025-06-17T12:45:02.967Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":50,"revision":5,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot Playbook","slug":"copilot-playbook","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4EXetae4afYR3PFbx2CXsd","type":"Entry","createdAt":"2020-02-26T22:21:38.743Z","updatedAt":"2020-02-26T22:21:38.743Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":47,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Challenge Operations","trackParent":"Topcoder","description":"All Challenge operations documentation."}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"l66ifjfnjwZSmYwRdlOID","type":"Entry","createdAt":"2020-01-09T21:49:28.808Z","updatedAt":"2020-01-09T21:49:28.808Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":17,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Copilot","trackParent":"Topcoder","description":"Copilot documentation."}}],"tags":["Members Roles","Copilot","challenge"],"creationDate":"2018-02-20","readTime":"10 min read","content":"Topcoder Copilots work with customers of Topcoder to deliver results using the Topcoder Community. \n\nIf you've earned your way to becoming a copilot, then there are a few things you should know.  Ok, maybe more than a few...\n\n1. Congratulations!  Being a Topcoder Copilot is a very exclusive role and gives you a lot of opportunities to grow your career.\n\n2. We expect Copilots to act as representatives of Topcoder when working with the Topcoder Community and customers.\n\n3. Copilots must stay current with the latest processes/rules/etc. on the Topcoder Platform.\n\n4. __For detailed information and a complete Copilot Playbook, please view__ <https://docs.google.com/document/d/1g9HnJiL3uPNJ6_6P1gimrXj_Ycdn3aitq0OmkBwzJXI/edit#heading=h.ggbn3yyrrvi6>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2o5VKQl5ByP5eKOvL8FmRm","type":"Entry","createdAt":"2019-12-28T15:05:42.061Z","updatedAt":"2025-06-17T12:45:00.087Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":204,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot & Reviewer Certification Program","slug":"copilot-and-reviewer-certification-program","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-06-08","readTime":"5 min read","content":"### Certification Program in Progress\nWe’ve been hard at work designing and developing a new certification program for community member roles (like copilots and reviewers) over the last few months. With the majority of planning work behind us, we’ll be rolling out the infrastructure to support this new training and certification program over the next few months.\n\n### Goals of the Certification Program\nWe love our global community, so much so that we want you to be part of our team, working alongside us to help crowdsourcing challenges go as smoothly as possible and yield amazing results. In order to do that, we need to select the right sherpas and give them the guidance and feedback to help them understand the advanced roles of copilots and reviewers across the various tracks. The goal of our certification program is to provide clear expectations of these roles and responsibilities for copilots and reviewers and ensure that those entrusted to these positions continue to maintain the high level of quality associated with Topcoder. \n\n### Roles Included in the Program\nOur different tracks have different needs from copilots and reviewers, so we have custom tailored the roles within each track. Each certification is separate and distinct, and you should check the details for each role to see the specifics of the job as well as the description of the minimally qualified candidate. Currently, our program includes:\n\n__Design Track:__\n\n- Design Copilot\n- Design Screener\n- Design Spec Reviewer\n\n__Development Track:__\n\n- Copilot\n- Code Reviewer\n- Spec Reviewer\n\n__Data Science Track:__\n\n- Data Science Sprint Copilot\n- Data Science Marathon Copilot\n- Data Science Marathon Tester\n\nIn addition to these track-specific roles, we also have an additional advanced copilot role that requires the ability to provide a higher level of customer interaction. This role is only open to those who already have obtained at least one of the track-specific copilot certifications:\n\n- Project Copilot \n\n### Applying for a Certified Position\n#### Eligibility\nEach role has a set of minimum eligibility requirements that must be attained before applying for the role. Please make sure that you meet these requirements before completing an application for a given role. These requirements can be found on the individual role descriptions.\n\n#### Copilot Application\nThe application for each role gives you an opportunity to describe some of your qualifications and the way you would approach the role. You will be evaluated on both the content of your answers as well as your written English skills which will be required for clear communications with the community and our customers. It is expected that the application consists of responses written solely by you without review or input from others. \n\nThe application will be evaluated by Topcoder team members. In order for you to progress to to the next stage you must be a good fit for the role and there must be a need for us to take on another person into the position. In the case that you are found to be qualified but there is no need for further members in that role, we will wait until there is a need before moving you on to the next phase.\n\n[Apply to be a Copilot](https://forms.gle/U2NX1ReZpgMsmF1X7)\n\n<iframe src=\"https://docs.google.com/forms/d/e/1FAIpQLScLM97dnna0HpSaG6pVQtFjQRZHc5KAAwRdLp70oJtYkZVFGg/viewform?embedded=true\" width=\"640\" height=\"3500\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\">Loading…</iframe>\n\n#### Reviewer Application\nThe review position is one that is earned by being a successful competitor.  We are currently revising the eligibility rules and will update them here soon.  If you qualify to be a reviewer, you will receive and email automatically inviting you to the review board. It is your choice at that point to accept. In order to remain on the review board, you must maintain your qualifications by continuing to compete.\n\n### Training Program\nEach role has a unique set of training materials, consisting of documents and videos created by Topcoder experts. As you move through this phase, pay close attention to which materials are required and which may be optional. It is your responsibility to complete these in a timely manner. Note that if you are a candidate for multiple roles, there may be some duplicate items across your training plans which you can skip if you have already completed them previously.\n\n### Written Exam\nMost of the roles also have a written exam that is designed to help simulate the work you will do in the role before you have to do it in front of a customer. For copilots, these usually involve writing challenge specifications (or “specs”), estimating budget and timeline, and providing strategic feedback to the customer. For reviewers, these usually involve providing reviewer feedback based on sample work.\n\nThese exams are not designed to test your knowledge of obscure Topcoder policy details. They are not designed to trick you. They are designed to give you practice at a portion of what a big part of your job will be should you pass and be placed in the role. It is expected that the work submitted for these exams is completely and solely the work of you, the candidate, without influence or input from anyone else. \n\n### Phone Interview\nOnly one roll, the Project Copilot, will require the member to have verbal communication with the customer. Because this job requirement is so specific, we will be requiring a short phone interview with the Project Copilot candidates to hear how they would respond to specific customer interactions. Excellent English speaking skills are a prerequisite for this role. \n\n### Observation Evaluation\nAfter completing all of the above, you will be ready to try out the role with an actual customer challenge in the community. At this point in the certification process, you will be assigned a Topcoder expert to evaluate you in action as you work with this customer challenge. This expert will evaluate you in various areas as they apply to your specific role, including:\n\n- Topcoder Standards & Processes\n- Customer Management\n- Community Management\n- Technical Skills\n- Communication & Professionalism\n\nIf you pass this evaluation you will officially be certified and can continue to work in this role on customer challenges. Congrats! If you put in a substantial effort but didn’t quite meet the standards, your expert may allow you to retry the observation run after providing you with some mentoring on how to improve.\n\n### Ongoing Performance\n#### Ongoing Metrics\nEach role has specific metrics that we look at to make sure things are going smoothly for the members performing those specific roles. Usually, these are around delivery of materials on time, challenge fulfillment, and satisfaction survey results. If we start to notice a degradation in your performance you may be warned and possibly put on probation. Failure to make a positive change will result in the loss of your certification status.\n\n#### Ongoing Training\nAs we grow the training program, we may add additional documents or modules that you will be required to complete in a timely manner in order to maintain your certification status. Failure to complete assigned modules will result in the loss of your certification status. \n\n#### Good standing\nAs a representative of the Topcoder brand, we expect you to lead by example within the community and maintain a positive and constructive relationship both with Topcoder employees as well as other members of the community. This applies to all interactions including (but not limited to): review feedback, customer interactions, forum posts, and emails. Failure to do so will result in the loss of your certification status.\n\n### Existing Members in These Roles\nAll members filling these roles will need to be certified. As we roll out this program, we acknowledge that there will be a transitionary time and hope to move through the process of certifying our existing members quickly. \n\nThe process may be slightly adjusted at the discretion of the Topcoder certification program leads for existing members who have been performing well in their roles for while in the following ways: \n\n- Certain training modules may be deemed optional\n- Written exams may be replaced with looking at previous challenge work that applies to the same function","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":1,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7wTYn5b5dSXJnSR7DDKJuQ","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"7wTYn5b5dSXJnSR7DDKJuQ","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2o5VKQl5ByP5eKOvL8FmRm","type":"Entry","createdAt":"2019-12-28T15:05:42.061Z","updatedAt":"2025-06-17T12:45:00.087Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":204,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Copilot & Reviewer Certification Program","slug":"copilot-and-reviewer-certification-program","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Copilot"],"creationDate":"2018-06-08","readTime":"5 min read","content":"### Certification Program in Progress\nWe’ve been hard at work designing and developing a new certification program for community member roles (like copilots and reviewers) over the last few months. With the majority of planning work behind us, we’ll be rolling out the infrastructure to support this new training and certification program over the next few months.\n\n### Goals of the Certification Program\nWe love our global community, so much so that we want you to be part of our team, working alongside us to help crowdsourcing challenges go as smoothly as possible and yield amazing results. In order to do that, we need to select the right sherpas and give them the guidance and feedback to help them understand the advanced roles of copilots and reviewers across the various tracks. The goal of our certification program is to provide clear expectations of these roles and responsibilities for copilots and reviewers and ensure that those entrusted to these positions continue to maintain the high level of quality associated with Topcoder. \n\n### Roles Included in the Program\nOur different tracks have different needs from copilots and reviewers, so we have custom tailored the roles within each track. Each certification is separate and distinct, and you should check the details for each role to see the specifics of the job as well as the description of the minimally qualified candidate. Currently, our program includes:\n\n__Design Track:__\n\n- Design Copilot\n- Design Screener\n- Design Spec Reviewer\n\n__Development Track:__\n\n- Copilot\n- Code Reviewer\n- Spec Reviewer\n\n__Data Science Track:__\n\n- Data Science Sprint Copilot\n- Data Science Marathon Copilot\n- Data Science Marathon Tester\n\nIn addition to these track-specific roles, we also have an additional advanced copilot role that requires the ability to provide a higher level of customer interaction. This role is only open to those who already have obtained at least one of the track-specific copilot certifications:\n\n- Project Copilot \n\n### Applying for a Certified Position\n#### Eligibility\nEach role has a set of minimum eligibility requirements that must be attained before applying for the role. Please make sure that you meet these requirements before completing an application for a given role. These requirements can be found on the individual role descriptions.\n\n#### Copilot Application\nThe application for each role gives you an opportunity to describe some of your qualifications and the way you would approach the role. You will be evaluated on both the content of your answers as well as your written English skills which will be required for clear communications with the community and our customers. It is expected that the application consists of responses written solely by you without review or input from others. \n\nThe application will be evaluated by Topcoder team members. In order for you to progress to to the next stage you must be a good fit for the role and there must be a need for us to take on another person into the position. In the case that you are found to be qualified but there is no need for further members in that role, we will wait until there is a need before moving you on to the next phase.\n\n[Apply to be a Copilot](https://forms.gle/U2NX1ReZpgMsmF1X7)\n\n<iframe src=\"https://docs.google.com/forms/d/e/1FAIpQLScLM97dnna0HpSaG6pVQtFjQRZHc5KAAwRdLp70oJtYkZVFGg/viewform?embedded=true\" width=\"640\" height=\"3500\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\">Loading…</iframe>\n\n#### Reviewer Application\nThe review position is one that is earned by being a successful competitor.  We are currently revising the eligibility rules and will update them here soon.  If you qualify to be a reviewer, you will receive and email automatically inviting you to the review board. It is your choice at that point to accept. In order to remain on the review board, you must maintain your qualifications by continuing to compete.\n\n### Training Program\nEach role has a unique set of training materials, consisting of documents and videos created by Topcoder experts. As you move through this phase, pay close attention to which materials are required and which may be optional. It is your responsibility to complete these in a timely manner. Note that if you are a candidate for multiple roles, there may be some duplicate items across your training plans which you can skip if you have already completed them previously.\n\n### Written Exam\nMost of the roles also have a written exam that is designed to help simulate the work you will do in the role before you have to do it in front of a customer. For copilots, these usually involve writing challenge specifications (or “specs”), estimating budget and timeline, and providing strategic feedback to the customer. For reviewers, these usually involve providing reviewer feedback based on sample work.\n\nThese exams are not designed to test your knowledge of obscure Topcoder policy details. They are not designed to trick you. They are designed to give you practice at a portion of what a big part of your job will be should you pass and be placed in the role. It is expected that the work submitted for these exams is completely and solely the work of you, the candidate, without influence or input from anyone else. \n\n### Phone Interview\nOnly one roll, the Project Copilot, will require the member to have verbal communication with the customer. Because this job requirement is so specific, we will be requiring a short phone interview with the Project Copilot candidates to hear how they would respond to specific customer interactions. Excellent English speaking skills are a prerequisite for this role. \n\n### Observation Evaluation\nAfter completing all of the above, you will be ready to try out the role with an actual customer challenge in the community. At this point in the certification process, you will be assigned a Topcoder expert to evaluate you in action as you work with this customer challenge. This expert will evaluate you in various areas as they apply to your specific role, including:\n\n- Topcoder Standards & Processes\n- Customer Management\n- Community Management\n- Technical Skills\n- Communication & Professionalism\n\nIf you pass this evaluation you will officially be certified and can continue to work in this role on customer challenges. Congrats! If you put in a substantial effort but didn’t quite meet the standards, your expert may allow you to retry the observation run after providing you with some mentoring on how to improve.\n\n### Ongoing Performance\n#### Ongoing Metrics\nEach role has specific metrics that we look at to make sure things are going smoothly for the members performing those specific roles. Usually, these are around delivery of materials on time, challenge fulfillment, and satisfaction survey results. If we start to notice a degradation in your performance you may be warned and possibly put on probation. Failure to make a positive change will result in the loss of your certification status.\n\n#### Ongoing Training\nAs we grow the training program, we may add additional documents or modules that you will be required to complete in a timely manner in order to maintain your certification status. Failure to complete assigned modules will result in the loss of your certification status. \n\n#### Good standing\nAs a representative of the Topcoder brand, we expect you to lead by example within the community and maintain a positive and constructive relationship both with Topcoder employees as well as other members of the community. This applies to all interactions including (but not limited to): review feedback, customer interactions, forum posts, and emails. Failure to do so will result in the loss of your certification status.\n\n### Existing Members in These Roles\nAll members filling these roles will need to be certified. As we roll out this program, we acknowledge that there will be a transitionary time and hope to move through the process of certifying our existing members quickly. \n\nThe process may be slightly adjusted at the discretion of the Topcoder certification program leads for existing members who have been performing well in their roles for while in the following ways: \n\n- Certain training modules may be deemed optional\n- Written exams may be replaced with looking at previous challenge work that applies to the same function","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":1,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"7wTYn5b5dSXJnSR7DDKJuQ","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1DeTxEBZ8LxoEvOVv29Rjj","type":"Entry","createdAt":"2019-12-28T15:05:39.159Z","updatedAt":"2020-05-21T06:17:59.113Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":381,"revision":3,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Review - Role & Responsibilities","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6cav9Sq7vjYyUBUZNDBQGf","type":"Entry","createdAt":"2020-01-09T19:03:55.580Z","updatedAt":"2020-01-09T19:03:55.580Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Member Roles","trackParent":"Topcoder"}}],"tags":["Members Roles","Reviewer"],"creationDate":"2018-06-28","readTime":"20 min read","content":"The review process is a critical phase in the Topcoder challenge lifecycle. Reviews are crucial for maintaining top quality for customer deliverables, determining challenge winners, as well as providing opportunities for skills growth via feedback for participating members of each challenge. Reviewers and the review process is what makes the Topcoder methodology unique and provides a tremendous amount of value to all Topcoder participants. \n\nIn order to understand your role and responsibilities as a reviewer, you’ll need to understand the overall review process. Take a look at these other articles to get an overview.\n\n- [Development Challenge Types](https://www.topcoder.com/thrive/articles/Development%20Challenge%20Types)\n- [Topcoder Review Process](https://www.topcoder.com/thrive/articles/Topcoder%20Review%20Process)\n- [Topcoder Scorecards](https://www.topcoder.com/thrive/articles/Topcoder%20Scorecards)\n\nYou’ll also need to be familiar with [Online Review](https://software.topcoder.com/review), where the reviews are managed for Topcoder.\n\n### How to Become a Reviewer\nIf you are an active participant and interested in joining the Topcoder Development Review Board, please visit the [reviewer qualification](https://www.topcoder.com/thrive/articles/Reviewer%20Qualification%20Requirements) page for details.\n\n### The Reviewer Mindset\nThere’s more to being a great reviewer than just filling out a scorecard. We rely on our reviewers to take ownership of the success and overall quality of the challenge output. __You will be representing Topcoder in your actions and in your communications, and it’s important to make sure you’re prepared for what’s ahead__. Here’s some advice from some of our experienced reviewers about how to approach the role.\n\n- Just as a challenge submission must be solely the work of the submitter, reviews must be done solely by the reviewer assigned to that review. \n- Always apply common sense to all aspects of a review. If you can’t understand a good reason for doing something, then perhaps it shouldn't be done. If you have any questions or doubts during a review, please contact the challenge manager/copilot for your project via the Contact Manager link in Online Review. Asking questions early will lead to better quality reviews and will help prevent a long appeals process.\n- It is critical you are prepared to do a proper review. Make sure you feel comfortable with a challenge before applying for review positions. Be prepared and ensure you understand the requirements, technology, and desired goals for the challenge.\n- Do not apply if you are just learning the technology. You should be a competitor in those cases. Doing this is grounds for removal from the review board. \n- It is your responsibility to review the forum for clarifications or adjustments that were made during the challenge. If something is unclear, contact the challenge manager/copilot.\n- Plan ahead and start your reviews early so you are not rushing at the end. All the timelines are available at the start of a challenge. Set aside the time and plan accordingly. Occasionally, reviewer deadlines may change as a challenge is in progress due to all reviews being finished early or if multiple rounds of final fixes are required. Make sure your schedule is flexible enough to complete all your responsibilities on time even if the overall timeline changes slightly. \n- When completing a scorecard, provide detailed review comments that are supported by objective facts. You are responsible for including details such as specific references to challenge requirements or forum posts that support your scores. This will make the appeals process much smoother.\n- Be as respectful and positive as you can in your review comments. You are leaving feedback for your fellow members in the Topcoder community and positive, constructive feedback will benefit everyone.\n- You will encounter submissions that solve for a solution in a different way than you would have, but this should not influence your review. Conduct your review based on how the submission meets the requirements, not on how it meets your own ideal design or development or how it compares to other submissions. If you have suggestions on how to improve the submission you can write comments in the review. These suggestions are very welcome, but they should not influence the scoring of the review process.\n\n### Applying for Review Opportunities\nOnce you have been invited to be a review board member you may apply to review challenges. Challenges with open review positions are listed under the [Review Opportunities](https://www.topcoder.com/challenges?bucket=reviewOpportunities) page. In order to find open review positions, do the following\n\n1. Go to the [challenge listings page](https://www.topcoder.com/challenges).\n2. Click [Open for Review](https://www.topcoder.com/challenges?bucket=reviewOpportunities) in the side nav on the right.\n3. *Before applying to review a challenge, take the time to study the goals, requirements, timeline, and ensure that you are proficient in the technology necessary to do the job*. If you aren't comfortable with the requirements or technologies for a specific challenge, you should not apply for it. Applying for reviews where you do not have the necessary skills will result in being suspended from the review board.\n4. To apply for a review position, check the checkboxes for the positions you are interested in. The Topcoder review process has two types of reviewers: Primary and Secondary. The Primary Reviewer has additional responsibilities (screening, final review, aggregation) and is paid a higher amount to cover this additional work. Secondary reviewers are responsible only for the review and appeals process.\n\nWhen you apply for a review opportunity you may apply to be both a Primary Reviewer and a Secondary Reviewer. You can apply for multiple positions if you feel comfortable with each of them, but the system will only assign you to at most one position. If you only apply for the Primary Reviewer and some else is selected, you will not be able to receive a Secondary Reviewer position.\n\nBefore applying for a Primary Reviewer position you should look at the estimated project phase timeline on the review opportunity details page. The Primary Reviewer is solely responsible for completing several phases of the review process and any delays in completing these tasks can delay the entire project. There is a lot of responsibility on the Primary Reviewer so make sure you are prepared to handle it before applying for the position.\n\n5. To complete your application click the \"Apply Now\" button.\n![review opp header](//images.ctfassets.net/piwi0eufbb2g/QG3dPCIRxR538lla17yla/e3540d3312835fa901afcd05a285fd08/review_opp_header.png)\n\n#### Reviewer Selection Algorithm\nTopcoder is currently revamping this algorithm. Today, assignments are based on Topcoder's evaluation of your previous reviews, technology skills, and your current workload. If you have any questions please email <support@topcoder.com>.\n\n### How to Perform a Review\nReview scorecards are entered via [Online Review](https://software.topcoder.com/review) (also referred to as \"OR\"). Any assigned review scorecards can be accessed on the challenge page in Online Review under the \"Outstanding Deliverables\" section. Simply click the link to open the scorecard you wish to enter.\n\n### How to Download Submissions to Review\nReviewers need to download submissions from Online Review in order to view them. To download a submission open Online Review and navigate to the challenge you are reviewing. The submissions can be downloaded by clicking on the submission ID under the \"Review/Appeals\" tab under the timeline table.\n\n### How to Complete a Scorecard\nOne of the main tasks a reviewer is responsible for is completing a review scorecard via Online Review. Scorecards are different for each track at Topcoder, and different challenges within a track may even have a different scorecards. As a reviewer, it is your job to read the scorecard carefully and make sure you follow the scoring guidelines explained for each section.\n\nYou may open the scorecard by viewing the challenge in Online Review and clicking on the scorecard link under \"Outstanding Deliverables\". Any assigned scorecards (including reviews, appeals responses, aggregation, or final review) will be listed under this section. After completing a scorecard you can choose to save the scorecard to revisit later or submit it by clicking the buttons at the bottom of the scorecard.\n\nDon't forget to use the \"Save for Later\" button at the bottom of the review scorecard often so you don't lose your work!\n\n### How to Answer Scorecard Questions\nFor each scorecard question you will need to select a score using the dropdown menu on the \"Response\" column (on the right side of the screen):\n\n![9](//images.ctfassets.net/piwi0eufbb2g/vzw9jGtHSCGIfcvRIROZ3/f2ff07304ca4dc692c6757398a9b405d/9.png)\n\nThe score you select must follow the scoring guidelines described in the question description. If this question description isn't displayed you may click on the '+' icon to the left of the question number to expand the description.\n\nIn addition to a score, you must also enter a comment that explains the score you selected. Be sure to include supporting details and objective facts to justify your score. Online Review includes an \"Add Response\" button under each comment:\n\n![10](//images.ctfassets.net/piwi0eufbb2g/3oO1iXeumTr6WEUOInWFiQ/e2f59a891d0d184f848630bc63e34dfb/10.png)\n\nYou may use this button to leave multiple comments for any question on the scorecard. For each question, you should enter one comment for each issue you find. Providing multiple comments makes it much easier for submitters to appeal specific comments, and it makes the aggregation, final fix, and final review phases much easier to manage for everyone.\n\n### How to Approach Reviews\n#### View Each Review in Isolation\nA reviewer should never, for any reason, compare submissions in order to assign scores. Each submission should be reviewed in a vacuum. For this reason, justifying an appeal response based on \"the score being fair because all other submissions were treated in the same way\" is invalid. Every scorecard and every appeal response should stand by itself. You should always score a submission based on how well it meets the challenge requirements and scorecard guidelines (NOT on how it compares to other submissions). To help avoid comparing submissions you may want to focus on reviewing one submission at a time and completing the entire scorecard before even looking at the next submission.\n\n#### Provide Clear Reasoning\nEvery scorecard should be self-explanatory. At any point in time, anybody should be able to read the scorecard and easily understand why each item was scored the way it was. This means if you score a submission down, you need to have corresponding reasons documented in the scorecard. The competitors should never need a clarification in order to appeal, the challenge admin should never need a clarification from you in order to determine whether an appeal was properly answered or not, and website visitors shouldn't need to guess in order to know what you thought of the submission. Every item in the scorecard needs to be properly explained and justified. This means including facts and references in your review comments.\n\nAlso, make sure to add a separate response for every point you want to make. Do not combine several points into the same item, but use the \"Add Response\" button instead. Using separate items will make it much easier for submitters to appeal each individual item. It also makes the tasks of aggregation, final fixes, and final review much easier.\n\n#### Approaching Overlapping Scores\nSometimes a project will have a problem that several different review items address. In this case, the decision on how to score is up to you. A very small problem probably deserves to be scored down only once, while a large problem probably justifies adjusting the score in multiple items. When doing this, please explicitly reference the item that the score is overlapping from so the submitter can see where the score comes from. When deciding which item to score down (or up, this principle also applies to enhancements), you should use the more specific items first.\n\nReviewers should use their best judgment and common sense when overlapping scores. Submitters spend days working on their submissions and it's not fair to fail a submission for a minor item that has been scored down in multiple sections of the review scorecard. If you determine that a problem with a submission is minor, pick the most relevant scorecard section and only score it down there.\n\nReviewers can avoid over penalizing a submission with overlapping scores by leaving comments in multiple scorecard sections but only scoring the problem down in the most relevant scorecard section. Leaving comments without taking points off is helpful in later stages of the review and ensures the problem will be corrected during final fixes.\n\n#### Review Item Comments\nBe clear and factual in your comments. Including specific references, such as page numbers or forum posts, is helpful for everyone involved in the review process. If the point you are trying to make is complicated or difficult to understand you may want to consider re-stating your point in multiple ways or providing an example.\n\nThe Topcoder community is made up of members from all over the world. Many of these members speak English as a second language. Reviewers need to be aware of potential language barriers and avoid using vocabulary that is unnecessarily complex.\n\n#### Distinguish Between Required vs. Recommended\nAn item should only be marked \"Required\" if it affects the submission's ability to meet the project requirements as outlined in the challenge requirements specification and forum discussions. These include all issues that may block the solution from working in production, including bugs and poorly written code that could affect functionality, scalability and/or performance, but also code hygiene issues including documentation, test cases and potential deployment problems. All other items are to be marked recommended. Reviewers should not mark items required out of personal preference. This practice is detrimental to the quality of challenge deliverables, as it tends to cause a lot of unnecessary final fixes where issues are much more likely to get introduced since final fixes are only reviewed by one person. Additionally, reviewers can leave comments on their scorecard by marking the item as \"Comment\".\n\nIt's very important for the aggregation, final fix, and final review phase that items be correctly classified on your scorecard.\n\n#### Reviewing Maintenance Projects\nCertain projects involve upgrading a previous submission or existing code. When reviewing these projects, you should only concern yourself with the modifications (and not the pre-existing code base). The submitter is only responsible for fixing any parts of the old code base that needed to be changed to fit the new requirements. They will not be penalized for existing code hygiene issues like formatting, documentation, etc.\n\nIf a submitter chooses to improve aspects of the old code base that are not addressed by the requirements, the best place to reward that extra work is the overall comments review item. We encourage submitters to overachieve, but the bulk of the scorecard is concerned with how the requirements are met and exceeded.\n\n#### Leaving Feedback on Trivial Issues\nPlease concentrate on the core aspects of a submission. It is important to also consider the details, but you shouldn't be spending time chasing down issues that have no impact on the overall design or development. For example, whether a Java interface's methods are explicitly declared public or not has no bearing on the readability of the code, or on the resulting bytecode after compilation. This should not be considered an issue at all.\n\nIf you find trivial issues while reviewing a submission you may want to consider leaving feedback about the item without scoring the submission down. Harsh scoring of trivial issues has the potential to fail a submission and possibly even cause the challenge to fail if no submissions pass review. If a submission meets all the core aspects of a challenge requirements there is no reason it should fail due to trivial issues. Reviewers are welcome and encouraged to point out trivial issues, but these types of small issues should not have a major impact on the overall score. Use your best judgment on the severity of issues before entering a score.\n\n#### Additional Items to Watch Out For\nReviews in development tracks that involve coding (Code, Assembly, F2F, UI Prototype, etc) may require some additional review steps that other challenge tracks don't require. For example, testing code is required for reviews in these types of tracks.\n\n#### Code Redundancy and Helpers\nSubmitters often use helper classes and methods to factor out certain common tasks such as parameter checking and SQL resource closing. There has been some debate as to whether using helpers for parameter checking is good or not. Topcoder's official stance is that using or not using a helper for parameter checking is a minor detail that should not affect a submission's score.\n\n#### Subjective Reviews\n\nSome development challenges will employ a subjective review.  This means that it will be up to the reviewer (often the copilot and/or customer) to determine the winners based on how they interpret the submissions applicability to the challenge requirements. Specific scorecards are used in this case.  You will find only 1 question in the scorecard that is used to rank the submissions from best to worse.  Follow the guidelines in the scorecard.  Note: The system currently won't allow ties, so you'd have to rank them such that they have a unique placement. If you do set the same score on 2 of them, the earlier submission timestamp is the tie breaker.\n\n### Tests\n#### Kinds of Tests\nThere are several different kinds of tests that can be used during the review process.  Some challenges require tests, while others don't.  Please check the challenge requirements and scorecards for the challenge you're reviewing. When tests are required, you may see the following classifications of test cases:\n\n1. __Stress -__ Stress reviewers should try to find the kinds of problems that only appear under heavy load. If a program leaks resources, the stress tests should find this. Similarly, if a component is supposed to be thread safe then the stress tests should try to find deadlocks and race conditions. Stress tests should also try to find inefficient implementations by timing them out.\n2. __Failure -__ Failure reviewers should concern themselves with whether the component handles error conditions as the design specifies. Trigger every kind of error the component should handle, and verify that the component handles it properly (throws the proper exception, doesn't leak resources, etc.)\n3. __Accuracy -__ Accuracy reviewers should find out whether the component produces the right results for any valid input. Find and test the boundary cases, just like you would in an algorithm competition's challenge phase.\n\n#### Intermittent Test Failures\nSometimes, a test fails only once every few runs. Sometimes it will fail once, and then run properly many times in a row. These incidents must be investigated, since there are bugs that only show up rarely or when the system is under heavy load. Just because a tests runs properly once does not mean that the code is correct. Always run each test suite several times.\n\n#### Validity\nTests should be valid for an indefinitely long period of time, as clients may wish to run the tests every time they deploy the code. Do not assume that temporary conditions (such as the existence of an external email address) will hold when the tests are run.\n\nMoreover, tests should be valid on any environment. Assuming that a certain file or directory is read-only, for example, makes a possibly invalid assumption about the environment the tests will be run on. A much better approach would be to first find out if the conditions to run the test are met, and then decide whether to run it or not. Other common (and troublesome) assumptions include assuming that the directory separator character is either '/' or '\\\\', and any other type of hard-coding.\n\nOne last comment about the environment setup: when writing tests, it is always better to replicate a real environment than to simulate it with mock up classes when possible. For example, a component that uses database persistence should be tested using a real database whenever possible.\n\n#### Configuration\nTo address the above hard-coding problem, tests that need configurable information must use environment specific solutions. You can use whichever is most appropriate for the situation, but try to minimize the dependencies you add to the code. Common items to configure can be server addresses, file paths, database connection strings, etc. Test configuration files should reside under the test_files directory.\n\nDuring final review, the primary reviewer should ensure that all tests are configurable and that, if possible, they all read from the same configuration file for database and other server connections. That way, the user of the component does not need to configure four separate files just to get the database connection working.\n\n#### Code Origin\nTests should never utilize a submitter's code. All code should be your own. The only exception to this is the following: when reviewing an upgrade to an existing code base, you may choose to reuse the existing tests from the previous version (provided that they are still valid).\n\n#### Standard Reviewer Payments\nReviewer payments are determined by various factors such as challenge prize amount, the number of submissions that passed screening, and the track of the challenge. Each challenge type has a review incremental coefficient assigned to it, and the coefficients vary with each challenge type. Primary reviewers earn compensation for the screening payment, review payment, aggregation payment and final review payment. Secondary reviewers only earn compensation for the review payment.\n\n#### Screening payment\nThe payment for the primary reviewer to do the screening (Primary Screener role in the Online Review) depends on the number of submissions and is computed in the following way:\n\nScreening Payment = N * SIC * Prize\n\nwhere N is the number of submissions, SIC is the Screening Incremental Coefficient (see the table below) and Prize is the 1st place prize value of the competition.\n\n#### Review payment\nThe payment for doing the review (Reviewer, Accuracy Reviewer, Failure Reviewer, Stress Reviewer roles in the Online Review) depends on the number of submissions which passed screening and is computed in the following way:\n\nReview Payment = (BRC + N * RIC) * Prize\n\nwhere N is the number of submissions which passed screening, BRC is the Base Review Coefficient (see the table below), RIC is the Review Incremental Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Aggregation payment\nThe payment for doing the aggregation (Aggregator role in the Online Review) is 10$ for all development competitions.\n\n#### Final Review payment\nThe payment for doing the final review (Final Reviewer role in the Online Review) is computed in the following way:\n\nFinal Review Payment = FRC * Prize\n\nwhere FRC is the Final Review Coefficient (see the table below) and Prize is the 1st place prize of the competition.\n\n#### Review Payment Coefficients\n| Type            | SIC  | BRC  | RIC  | FRC  |\n|-----------------|------|------|------|------|\n| Architecture    | 0.01 | 0.12 | 0.05 | 0.05 |\n| Assembly & Code | 0.01 | 0.13 | 0.05 | 0.05 |\n| Test Suites     | 0.01 | 0.12 | 0.05 | 0.03 |\n| F2F             | 0    | 0.02 | 0.04 | 0    |\n| Other tracks    | 0.01 | 0.08 | 0.03 | 0.03 |\n\n\n#### Late Deliverables\nTopcoder tracks all late deliverables in Online Review in order to improve the quality and the reliability of the software development process.\n\nEach project in Online Review consists of a set of phases each with its own timeline. Failure to meet the timeline for any of the phases leads to delay of the entire Online Review project which in turn delays the dependent projects. Whenever a member fails to meet the current timeline, it will be logged into the system for the further investigation. These statistics will be used by Topcoder to identify weak places in the process and to apply proper disciplinary measures to the late members if needed.\n\nA lateness penalty will be applied to the reviewer’s payment if a reviewer is late for any of their deadlines without a good reason, such as a phase opening earlier than expected, delays with requisitioning environments, or outstanding questions. If there are good reasons for delays, make sure you communicate them to the challenge manager/copilot as early as possible. The amount of money lost for a lateness penalty will depend on how long of a delay it causes.\n\n#### Previous Late Deliverables\nOne of the factors we rate reviewers on is on time completion of deliverables. If you would like to review your previous missed timelines you can use the Late Deliverables Search page to view your past statistic and the details of all of your late deliverables. \n\n#### Payment Penalties\nThe payment for the late members in Online Review is reduced based on their total delay. The total member's delay for a project is the sum of all his/her unjustified late records for this project. The payment will be reduced by 5% if there's a non-zero delay plus 1% for each full hour.\n\nAdditionally, each unjustified rejected final fix reduces the winner's payment by 5%.\n\nThe maximum possible penalty is 50%.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2B8JwZNtRCs0LOGu2yuFDk","type":"Entry","createdAt":"2019-12-28T15:06:30.013Z","updatedAt":"2024-04-30T01:26:41.544Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":338,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Topcoder Review Process","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-08-05","readTime":"20 min read","content":"The Topcoder review process helps ensure that materials delivered to our customers are of the highest quality. Our review board makes sure we are producing high quality output by individually inspecting and rating every submission. Both our reviewers and submitters learn from the review process through lively discussions and feedback mechanisms which leads to higher quality output and improved skills.\n\nThe review board is made up of experienced members chosen from the community and trained on the process. Membership to the review board is voluntary, but there are strict eligibility criteria which must be met for anyone to be granted membership.\nSome reviews have a mix of review board members, project staff and/or the customer.\n\n#### Important Points to Remember:\n- All parties, submitter, reviewers and challenge managers have responsibilities within the review process\n- You are notified via email when review phases start and end.  MAKE SURE YOU KNOW THE TIMELINE.\n- If you are selected as a reviewer on a challenge, you MUST prepare before the review phase starts.  Make sure you can setup environments, understand requirements, review forum discussions, etc.  Ask questions early.\n- Be thorough and specific in your reviews.  If a submission is scored down on any question, you must be clear in the scorecard comments as to why.\n- Delays can cause a reduction in payment\n- To apply for a review spot, visit <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>\n- To access any of your reviews you can visit Online Review (OR) at <http://software.topcoder.com>\n- If you reviewed a contest that failed and you had access to other members' submissions, you may not submit for the reposted contests (but you may still review them). Please check the article related to [eligibility criteria](https://www.topcoder.com/thrive/articles/Competition%20Eligibility%20and%20Support). \n\n*For detailed information about reviewer roles and responsibilities, please see [Development Review - Role & Responsibilities](https://topcoder.com/thrive/articles/Development%20Review%20-%20Role%20&%20Responsibilities)*\n\n#### Applying to review a challenge\nReview opportunities become available after challenges open for participation. In order to review a challenge, you first need to apply for an open spot at <https://www.topcoder.com/challenges/?bucket=reviewOpportunities>. Once you apply, you will be notified if you have been accepted to review the challenge.  In order to increase your chances of being selected, make sure you continue to compete in the track and technologies for the challenges you are interested in reviewing.\n\nNOTE:  If you are unable to perform a review according to the review schedule, you must withdraw at least 24 hours prior to the start of the review phase by managing your applications on the Review Opportunities page.  If the page is not allowing you to withdraw your application, please email your request to <support@topcoder.com>.\n\n#### Accessing your projects\nLogging into <https://www.topcoder.com/my-dashboard> will bring you straight to your dashboard which is your hub for Topcoder activity. Here you can find all of the projects you are involved in under the \"My Challenges\" section. You can access the forums and the challenge details from links found in this section. To access your reviews directly, please visit Online Review at <http://software.topcoder.com>.\n![My Dashboard](//images.ctfassets.net/piwi0eufbb2g/4EHwbltniZWKlnTn9Zqe5r/c6d7cdda315a3bf370504b6ac99fd82a/1.png)\n\n#### The Phases of Topcoder Review\nAfter submitting to a challenge, submissions will go through some variation of these phases depending on the configuration of the challenge:\n1. Screening\n2. Review\n3. Appeals\n4. Appeals Response\n5. Aggregation\n6. Final Fixes\n7. Final Review\n\n#### Screening\nCertain challenge types include a screening phase to make a quick pass through the submissions and judge whether or not they are worthy of being reviewed. A member of the review board screens each submission to ensure it is non-trivial and possibly capable of meeting the requirements. Submissions that show a significant amount of work will move on to the review phase for a more in-depth analysis whereas obviously incomplete or incorrect submissions will be not.\n\nDuring the screening phase, submitters may use the Contact link in the project's Online Review page to file an appeal if you believe the screening is incorrect. Appeals must be filed promptly: we will not accept any appeals received more than 24 hours after the screening phase ends.\n\n#### Review Scoring\nAfter the screening phase, reviewers assess the submissions that passed screening based on a detailed review scorecard to determine if each solution meets the requirements. Each submission will receive a scorecard for each reviewer assigned to the challenge. Challenges typically use two or three reviewers, thus each submitter will have at least two scorecards. Reviewers score each submission independently and do not compare their scores for submissions. Once all of the reviewers have completed the scorecards, the submitter is notified via email when the review phase is over.\n\n![Review Scorecard link](//images.ctfassets.net/piwi0eufbb2g/2YGUaK8G0XsbF2Qkkl03AN/4f40450fb9f578abc16e54d58ef4179b/2.png)\nDuring the review phase, reviewers focus on assigning scores that are fair and consistent with the scorecard guidelines. Reviewers must provide justifications for all of theirs scores. When justifying a score, reviewers need to be as specific as possible. If a submission is marked down without making the reason for the issue perfectly clear, the challenge manager and the submitter will not be able to understand why the submission received the score which can cause delays to the challenge.\n\nA reviewer may add more than one comment to a scorecard question. Each comment must be marked as:\n\n- __Required:__ This means that the fix must happen for the software to be usable.\n- __Recommendation:__ This means that the fix should be done but it does not affect the current requirements and could be done later.\n- __Comment:__ This means that the reviewer wanted to provide some general feedback for the contest manager or submitter, but it does not require a fix.\n\nIn some cases, you may see an iterative review phase to for First 2 Finish challenges (F2F). This review phase differs slightly as if the first submission passes review, no other submissions are reviewed and the project moves forward. If it does not pass review, the rest of the submissions will be reviewed in the order received until a passing submission is found.\n\nThe last type of review, a peer review, is associated with \"Show Your Skills\" challenges. These follow a different process than the standard community reviews by review board members. Show Your Skills challenges are reviewed by the fellow submitters for the challenge and not members of the review board. When you submit to these challenges, you are taking on the responsibility to review the work of your peers. Each submission will be evaluated by five other submitters and the outlying review scores are dropped. These challenges are marked as \"Peer Review\" instead of \"Community Review\" on the challenge detail page (see image).\n\n![review style](//images.ctfassets.net/piwi0eufbb2g/wq1QIdXH8R8P65hjINQn3/ed64f8c1c47bf4421c5d32a3cd633f01/3.png)\n\nAs part of the challenge, all submitters are asked to not only complete their submissions, but to provide a peer review of each other's work. Typically, these challenges are for skill-building purposes and result in badges, rather than submitting work to customers.\n\n#### Appeals & Appeals Response\nThe appeals phase will open after the review phase is complete. During this phase, submitters have 24 hours to view the scorecards completed by each reviewer for their own submission. Reviewers will leave comments for each item they deduct points. If the submitter feels something was marked down inappropriately they can make an appeal to the reviewer, but they must provide a very good reason based on objective evidence (and not just opinion) to appeal or the reviewer will reject it. Although you may not file a petition against another competitor’s scorecards (only your own submission’s scorecards may be petitioned), you may report an inconsistent review if the reviewer scored submissions differently for the same issue. If it is determined that the reviewer scored the submissions differently for the same issue, Topcoder will evaluate and correct the scorecard at its discretion.\n\nIt is the submitter's responsibility to ensure that every appeal has all the information the reviewer needs to answer it. The submitter should provide links to standards, forum discussions, etc. If the reviewer hasn't provided enough information in the scorecard to know what to appeal, you should contact the manager immediately (and appeal with what information is provided).\n\nFollowing the appeals phase is the appeals response phase. This phase allows the reviewer to review any appeals and decide on a final action. During the appeals response phase, the reviewers will reject any appeal not based on objective fact. Arguments on matters of opinion will be dismissed. Any appeal based on fact must be addressed thoroughly, and the reviewer must provide all the information the submitter needs to understand their decision (links, etc.)\n\nIn the appeals response phase, reviewers will sometimes find that an appeal covers more than one submission. For example, a change to a test case can affect the score of every submission reviewed. Since a reviewer can only change scores when somebody submits an appeal, reviewers might not be able to fully correct this problem. In this case, a reviewer's best option is to use the Contact Manager link in Online Review and explain the problem.\n\nEach appeal will be flagged to as follows:\n\n- __Accepted:__ The appeal was valid and the reviewer will adjust their score. \n- __Accepted - No score change:__ The appeal is valid, but not enough to adjust the score.\n- __Rejected:__ The appeal is not valid and the reviewer does not believe the submitter is correct in their appeal.\n\n#### Winner Determination & Aggregation\nOnce the appeals and appeals response phases are complete, the final scores are calculated and a winner is determined. Then, the primary reviewer compiles all of the scores of the winner’s scorecards which are marked as incomplete or incorrect areas of the solution into a single scorecard to facilitate final fixes.\n\nThis process is called aggregation. All of the comments are combined into the one final, aggregated, scorecard for the winner. Issues must be marked as \"Accepted\", \"Rejected\", or \"Duplicate\". The winner will be responsible to fix any \"Accepted\" items during the final fix phase. \"Duplicate\" is used to note two reviewers found the same issue. One of those comments will be marked \"Accepted\" and the others can be marked as \"duplicate.\" A \"Rejected\" comment is removed from the final scorecard. A comment is marked as rejected if the reviewer's comment was inaccurate or not needed for this version of the software. \"Duplicate\" and \"Rejected\" comments are dropped from the final scorecard.\n\nThis aggregated scorecard is used for the next phase: final fixes.\n\n#### Final Fixes\nThe final fixes phase follows aggregation and is the process to wrap up a challenge before the end result is delivered to a client. The final fix scorecard will contain items that are required and/or recommended before the submission can be considered complete. A submission can only be presented to the client for approval after it has been finalized.\n\nEvery required fix must be addressed otherwise the submission will be rejected by the final reviewer. A rejection will revert the challenge back to the final fix phase and will penalize the submitter for causing a delay. Items that are marked as recommended should be attempted to be fixed but are a lower priority than required fixes. If there is sufficient time, they should be included in the final fix.\n\nCommunication during the final fixes stage is extremely important. If for any reason the submitter has a question or comment on the review, it should be posted as soon as possible. If there is a blocking issue, contact the manager and make a post to the forum. The challenge manager will look into the issue and ensure that the primary reviewer is involved as necessary. If the submitter should feel that a required fix is impossible, it needs to be addressed on the forums.\n\nA submission should never be resubmitted without the fixes completed or a comment in a readme file. Communication between the submitter, reviewer, and a copilot is essential to make sure this phase goes smoothly. The Review Board is always open to communication; reviewers may have overlooked artifacts or misinterpreted the specification. Without communication, the Review Board doesn't know that fixes are being finished and can't mark the fixes as complete.\n\nThe format of the final submission is identical to the version provided during the initial submission but with the fixes completed to address the feedback by the review board. It is encouraged to add a text file or spreadsheet (which is less cumbersome) that thoroughly lists all the changes that were made to expedite the final review. If all of the requirements have been met, the contest is complete.\n\nIf anything is not done, the challenge makes a return trip to the Final Fixes phase and the submitter will be penalized with a \"delayed final fix\" warning by Online Review.\nOnce the fixes are complete and the winner submits the final solution, the reviewer approves it, the payment is set and the challenge is complete!\n\n#### Approval Phase\nThe challenge manager will deliver the final deliverable to the client. The client and the challenge manager will ensure the solution works in the client's environment and then the client will accept the work. During this time there are no tasks assigned to Topcoder members but if any issues do occur, you may be asked some clarifying questions.\n\n#### Post Mortem Phase\nChallenges at Topcoder occasionally fail for different reasons. When a challenge fails it enters the post-mortem phase. During this phase, feedback is collected from various parties to help determine why the challenge failed. Answers to these survey should provide as much detail as possible to ensure that future challenges are successful.\n\n#### Contact Manager\nIf there are concerns at any step in the process, use the Contact Managers link in Online Review to contact support or email <support@topcoder.com> to help resolve any issues.\n\n![Contact Manager link](//images.ctfassets.net/piwi0eufbb2g/1rAP5ypLWYXUQDmnFPCzRU/3d04ea6356759eb3ea27289117762490/4.png)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"3aEbaSZG6fL7m07amA9qOA"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6RtWLyyPIjfqoG7K6pAfGJ","type":"Entry","createdAt":"2019-12-28T15:06:30.851Z","updatedAt":"2021-10-07T01:30:45.340Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":63,"revision":7,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Development Challenge Types","type":"Article","trackCategory":["Topcoder"],"tags":["Development","Competing in Development Challenges"],"creationDate":"2019-05-30","readTime":"5 min read","content":"### Architecture\n*NOTE: This track is being redeveloped. Today you will find more architecture style challenges being run as proof of concepts in the Code track.*\n\nThis challenge type asks competitors to define the technical approach to implement the requirements. The output is a technical architecture document and sometimes a functional proof of concept.\n\n### Code\nThe Code challenge type covers the bulk of our competitive development challenges. Participants are asked to implement code to match the stated requirements and the results are reviewed by members of the Topcoder Review Board as well as automated reviews in some cases. The Topcoder forums are used to discuss requirements.\n\nCode challenges are used for various types of development.  For example, front-end development, API's, functional prototypes, etc.\n\nCode challenges are used to implement specific requirements and are geared to suit more of an iterative approach to development where follow-on challenges and/or tasks are run to implement additional functionality/changes/fixes and iterate on the previous deliverables.  Code challenges do not have a \"final fixes\" phase.\n\n### First2Finish (F2F)\nFirst2Finish is a race to complete a task as fast as possible while maintaining high quality in accordance with the specification. It can be used for any type of work that is needed. Unlike other Topcoder competitions, an F2F ends as soon as a participant submits and passes review.  Review will occur as soon as a submission occurs.  If a submission fails review, the next submitter will be reviewed. If a submission passes review, the challenge ends and other submissions will *NOT* be reviewed.  If a participant re-submits before a review occurs, their previous submission is removed from the queue and their new submission enters the back of the queue.\n\n### Bug Bash\nA list of issues is opened up to competitors and they fix them as rapidly as they can. The goal here is to expose the issues list to the community and let them jump in and fix as many as they can.  Each issue is reviewed and closed independently.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ruMdhDF1H3omdFtci1T98","type":"Entry","createdAt":"2019-09-20T07:13:24.144Z","updatedAt":"2019-10-15T16:56:58.035Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tony Jefts","tcHandle":"tjefts"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"2B8JwZNtRCs0LOGu2yuFDk","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}},{"sys":{"type":"Link","linkType":"Entry","id":"1DeTxEBZ8LxoEvOVv29Rjj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"6YWtojyV9VAIfLDxJEPPNZ"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7H6BZLNaTeji6EHAYFVdty","type":"Entry","createdAt":"2019-11-25T19:06:42.845Z","updatedAt":"2026-02-13T11:10:36.772Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1590,"revision":361,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Payment Policies and Instructions","slug":"payment-policies-and-instructions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}}],"tags":["General Info","Payment"],"creationDate":"2019-06-26","readTime":"10 min","content":"Topcoder is partnered with Trolley to send payments to our community members. Once setup, payments automatically flow into your chosen payment provider at the completion of work. To set up your Topcoder payment account, please follow these steps: <br/><br/>\n\n### Step 1. Update Your Profile\nMake sure your Topcoder profile is up to date with your full name and a complete and accurate address. If these are not completed, it will delay your payment. [Update your member profile now](https://account-settings.topcoder.com).<br/> \n\n__Member Name Changes__ \nThe Topcoder Terms of Service (TOS) require that accurate information be provided in your member profile. A member can update the name listed in their member profile at any time prior to the time that a payment has been set up. Once a payment has been created, the member will need to contact the payments team (support@topcoder.com) in order to update their name with any changes. A copy of government-issued identification may be required for name changes.<br/><br/>\n\n### Step 2. Complete a tax form.\nAll members need to have a tax form on file before they can be paid. \n\nThere are two options: a W-9 or a W-8BEN. \n\nTo see which one you will need to fill out, please continue reading: \n\nNOTE: THE FOLLOWING IS INTENDED TO EXPLAIN WHICH TAX FORMS TOPCODER REQUIRES FOR PAYMENT. THIS IS NOT A COMPLETE DISCUSSION ON TAXES AND WITHHOLDING, AND SHOULD NOT IN ANY CASE BE TAKEN AS TAX ADVICE. IT IS THE RESPONSIBILITY OF EACH MEMBER TO DETERMINE WHICH TAX FORM SHOULD BE COMPLETED AND SENT TO TOPCODER. TOPCODER ENCOURAGES ITS MEMBERS TO CONSULT THE INSTRUCTIONS OF EACH FORM AND/OR CONSULT AN ATTORNEY, TAX PROFESSIONAL, OR OTHER EXPERT FOR ADVICE IF YOU HAVE ANY QUESTIONS REGARDING WHICH FORM YOU SHOULD COMPLETE AND/OR THE PROPER COMPLETION OF THAT FORM.<br/>\n\n#### Who needs to complete Form W-9?\nIndividuals meeting the following conditions:\n\n• You are a US citizen or other US person (such as a resident alien); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-9?\nTopcoder must receive your correctly completed W-9 to report to the IRS income paid to you. Topcoder's policy is not to issue payments to US members until a properly completed Form W-9 is received from the member. \n\n#### Who needs to complete Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a foreign person, non-resident alien or foreign national); and\n\n• You are receiving any form of payment from Topcoder. <br/><br/>\n\n#### Why do I need to complete Form W-8BEN?\nUnder current IRS guidance (See (1) below), foreign persons performing services* outside of the U.S. are not subject to income tax withholding. However, Topcoder requires all such members to provide a properly filled out W-8BEN prior to issuing payment. In addition, prize money paid to foreign persons who are not performing services* (such as winning an SRM competition) is subject to withholding taxes. The W-8BEN is required to: • Establish that you are not a U.S. person • Claim that you are the beneficial owner of the income for which Form W-8BEN is being provided. Topcoder's policy is not to issue payments to foreign members until a properly completed Form W-8BEN is received from the member. \n\n#### Who may be eligible to claim tax treaty benefits under Form W-8BEN?\nIndividuals meeting the following conditions:\n\n• You are NOT a US citizen or other US person (such as a resident alien); and\n\n• You did not perform services \\*. <br/><br/>\n\n#### What is the potential benefit of claiming tax treaty benefits under Form W-8BEN?\nIf you are a foreign person, non-resident alien or foreign national who is not performing services \\*, Topcoder will withhold taxes on the payment. You may claim exemption from or reduction of the rate that will be withheld for taxes if there is an applicable income tax treaty by completing the necessary parts of Form W-8BEN. \n\nNOTE: TOPCODER CAN NOT ADVISE YOU ON THE EXISTENCE OF AN INCOME TAX TREATY. FURTHERMORE, TOPCODER CAN NOT ASSIST YOU IN DETERMINING YOUR ABILITY TO CLAIM A REDUCED RATE OF, OR EXEMPTION FROM, WITHHOLDING. ONCE A MEMBER CLAIMING THE BENEFIT OF A REDUCED TAX WITHHOLDING RATE PURSUANT TO A TAX TREATY PROVIDES ALL NECESSARY FORMS AND INFORMATION TO TOPCODER, TOPCODER WILL MAKE AN INDEPENDENT ASSESSMENT BASED ON THE INFORMATION PROVIDED. <br/><br/>\n\n#### How do I claim tax treaty benefits under Form W-8BEN?\nW-8BEN tax forms will be processed with the standard default 30% tax withholding percentage unless they are properly completed. All members completing the W-8BEN are required to fill out at least the following boxes: \n\nIn Part I: \n\n- Box 1 - Name \n- Box 3 - Type of Beneficial Owner \n- Box 4 - Permanent Residence Address \n- Box 5 - Mailing Address (if different from Box 4) \n\nIn Part IV: Sign and date the form \n\nIf a member wishes to claim the applicability of a withholding percentage of less than 30% pursuant to a tax treaty between their country of residence and the United States, then additional information must be provided. At a minimum, the member would need to provide the following additional information: \n\nIn Part I: \n\n- Box 6 - US Taxpayer ID number \n\nIn Part II: \n\n- Box 9(a) - provide your country of residence \n- Box 10: \n - Specify the number of the Article of the treaty between the United States and your country of residence under which you are claiming benefit of the lower withholding percentage; \n - Specify the lower withholding percentage you are claiming; \n - Specify the type of income on which you are claiming the lower withholding percentage; and \n - Provide a brief explanation of your reasoning for why you feel you are entitled to claim the lower withholding percentage pursuant to the applicable Article of the applicable treaty. \n\nPlease note you will need to provide a separate W-8BEN for each different type of income on which you are claiming a lower withholding percentage. Topcoder will make an independent assessment of the W-8BEN based on the information provided. A failure to provide the appropriate and accurate information in claiming a lower withholding percentage pursuant to a tax treaty will result in a default 30% tax withholding percentage. <br/><br/>\n\n#### Taxes Withheld for Members Completing Form W-8BEN:\nTaxes will be withheld from the following payment types for those members who have submitted a Form W-8BEN: \n\n- Data Science/Algorithm Prizes (SRMs, tournaments, or other similar challenges) \n- Royalties \n- Referral Bonuses \n- Certain Digital Run bonuses (the portion of Digital Run bonus earned on submissions which did not place in 1st or 2nd place of the contest) \n\n*For purposes of determining which tax form is required from members, Topcoder interprets \"performing services\" to include all services and competitions in which the member assigns ownership of the winning submission in exchange for compensation. (1) [See IRS Notice 2001-4](http://www.irs.gov/pub/irs-drop/n-01-4.pdf) (as of 8/21/13); <br/><br/>\n\n### Step 3: Set Up Trolley Settings\n\nBefore you can withdraw your winnings, you’ll need to complete the following three steps in your Wallet home. \n\n- Withdrawal Method Setup\n- Tax Form Submission\n- ID Verification\n\nThese settings will be completed through Trolley.\n\n[Check the Trolley Setup Guidelines](https://www.topcoder.com/thrive/articles/trolley-setup)\n <br/><br/>\n\n### Step 4: Select Payment(s) to be Paid\n\nMembers can track the status of their payments through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory) under \"My Topcoder\". There will be a \"Release Date\" on all payments.<br/><br/>\n\nA payment's \"Release Date\" will be 15 days after its creation date. Once the \"Release Date\" is reached, a member can select a payment to be paid. Select “Pay Me” for the sum of payment(s) you'd like to be paid.<br/><br/>\n\n__Minimum Account Balance__: The minimum withdrawal limit has been revised to $25. Members can withdraw payments equal to or greater than $25 now.  <br/><br/>\n\nIf you have any questions regarding the information on this page, please send an email to [support@topcoder.com](http://mailto:support@topcoder.com). Please be sure to include both your Topcoder handle and your full name in all of the correspondence.<br/><br/>\n\n### Step 5: Payment Tracking\nMembers can track the status of their payment through the [Payments page](https://accounts-auth0.topcoder.com/?retUrl=https%3A%2F%2Fcommunity.topcoder.com%2FPactsMemberServlet%3Fmodule%3DPaymentHistory).  Check out the [Payment Tracking article](https://www.topcoder.com/thrive/articles/Payment%20Tracking) for details.\n\n#### Development Challenge Payments\nFor development challenges, first place winner prize will be processed in two installments of 75% and 25%. The installments will be paid 15 days, after completion of the challenge.<br/><br/>\n\nIf the winner does not provide support during the 15 days of challenge completion, the 25% will be forfeited. Support tasks beyond bug fixing will be enumerated in the competition specification.<br/><br/>\n\nFor other placement winners, the prize money will be paid in one installment, 15 days after completion of the challenge.<br/><br/>\n\nAny exceptions to this policy will be clearly stated in the challenge.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"77i4b3hkXnSQ7lk0liEx2J","type":"Entry","createdAt":"2019-11-25T17:24:41.271Z","updatedAt":"2020-02-06T23:05:45.690Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":29,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Tc Admin"}}],"upvotes":169,"downvotes":34}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"69QWg34X48uW84YNiWtUaS"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yv3fVxbcdHYRkAr0yrVnS","type":"Entry","createdAt":"2020-06-26T13:17:38.391Z","updatedAt":"2021-02-04T05:39:58.059Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Wladimir Leite","tcHandle":"wleite","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"8CMQXCHyKmtkq8q7MPkb5","type":"Entry","createdAt":"2020-01-09T19:03:25.567Z","updatedAt":"2020-01-09T19:03:25.567Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Getting Paid","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"AyICjsAGXwAhfNqR9a8kM","type":"Entry","createdAt":"2020-03-30T23:06:14.883Z","updatedAt":"2020-03-30T23:06:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"boba5551","tcHandle":"boba5551"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"Kti40712QT55MZwopkkXi","type":"Entry","createdAt":"2020-04-20T12:42:14.134Z","updatedAt":"2020-04-20T12:42:14.134Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"vasylalphacom","tcHandle":"vasylalphacom"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"QUWD2QS7RiuC12nzWW4Ai","type":"Entry","createdAt":"2022-10-07T10:12:11.131Z","updatedAt":"2022-10-07T10:12:11.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":33,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"UX Design","slug":"ux-design","type":"Article","trackCategory":["Design"],"contentCategory":[{"sys":{"type":"Link","linkType":"Entry","id":"3nWr3TTerCAx8kkXU9kSMX"}},{"sys":{"type":"Link","linkType":"Entry","id":"6kbzSOMPOI8eWQV2cJzrHR"}}],"tags":["UX"],"creationDate":"2022-10-06","readTime":"7min","content":"UX design is an essential part of the design or redesign of any product. However, more often than not, UX design principles are confused with the design process. It should be noted that the UX design and the design process are similar but different. UX design is the standard principle for a product design, while the design process is the step-by-step guide a designer takes in designing a product. The design process typically varies based on the designer and the effect the designer is trying to create or redesign. \n\nTherefore, here we will be looking at carrying out a UX design while you design an app based on the principles learned and adequately document your design process. Note that the UX design should be based on the needs of the user and the stakeholder. Simply put, your UX design must solve the users' needs and meet business goals.\n\nAccording to the Stanford school of design the UX design comprises:\n- Product definition\n- Research\n- Analysis\n- Design\n- Validation\n\n### Product definition\nThis is the first phase in the user design process. This is where the design team understands the problem they are trying to solve and the context in which the product is being formed. This is where the \"whys” of the design are discussed. This is where the designer will collect the user needs based on business goals. Any mistakes in understanding the scope will lead to a product in the market that is not required. At this stage, the designer has stakeholder meetings in which he meets with the business manager, the product manager, and the lead developer. It is here we determine what our product is all about, who will use our product, and why they will be using our product. The entire team will have to consult with customers in their environment and analyze what they want within the framework of your operation. At this stage, critical KPIs are set, and success metrics are determined.\n\n### Research\nAfter you have adequately defined those, we move further into carrying out our research. This is very important because it helps save us time, money, and effort early in our design process. We identify pain points, needs, wants, and desires, and knowing our user's wants we can design a solution that will solve their problem. Research also involves competitive analysis where we check out what is already in mind and what we can add or remove that would give us an edge in the market. This aids us in entering the market faster.\nWe also look into the latest trends in UI design and design guidelines during the research process.\n\n### Analysis\nThis is where we combine and analyze the information gathered during research to get what we need from the data. We produce storyboards, user stories, personas, and experience maps, among other things. At this point, the designer shifts their focus from what to why a user needs or wants something. The designer has an initial guess about what the user might need, but they are not sure at this point in the user experience design process.\n\nAfter conducting enough studies and assessing the data obtained from research, we confirm our assumptions at this point.\n- __Fictional Personas:__ Developing fictional scenarios enables the designer to understand the many customers of your product better. It allows a realistic portrayal of the finished product. The design team can determine how it will seem following delivery.\n- __Experience Maps:__ These diagrams depict how users move through your finished product. This is accomplished through visual representation and suitable interactions with the customer.\n- __User story:__ A user story is a tool designers can use to better comprehend how users engage with a product or service. As a [user], I want to [objective to attain] so that [motive], which is the typical definition.\n- __Storyboarding:__ Designers can connect user personas and user stories with the storyboarding method. It's a story about a user interacting with your product, as the name suggests.\n\n### Design\nWhen product designers have a strong understanding of what customers want, need, and expect from a product, they move on to the design phase. Product teams work on various projects at this stage, from creating an Information Architecture (IA) to UI design in practice. A successful design phase is highly collaborative (every team member involved in product design must actively participate in this phase), iterative, and combined (meaning it cycles back upon itself to validate ideas).\n\nTypically, the design phase entails:\n- __Sketching:__ The quickest and most straightforward approach to visualize our ideas is through sketches. This can be accomplished by hand-drawing on paper, on a whiteboard, or with a computer tool. It may let the team see a wide range of design possibilities before determining which one to use, which makes it particularly helpful during brainstorming sessions.\n- __Wireframing:__ A wireframe is a tool designers may use to see the essential components of a future page and how they will work together. Wireframing is the product's backbone, and designers frequently utilize it as a foundation for mockups and prototypes.\n- __Prototyping:__ While wireframes are primarily concerned with structure and visual hierarchy (the look), prototypes are concerned with the actual interaction experience (the look and feel). A prototype resembles a simulation of the finished product and ranges from low-fidelity (clickable wireframes) to high-fidelity (coded prototypes) depending on the specific screens.\n- __Design specifications:__ They include user flow and task flow diagrams. It shows how the UI/UX product will generally function and its stylistic needs. It explains the procedures and visual components needed to produce fantastic user experiences.\n- __The development of design systems:__ Designers frequently construct a system of components, patterns, and styles for significant projects to enable designers and developers to stay on the same page with the design.\n\n### Validation or Testing\nTesting is the stage that establishes the final product's overall quality. When something has to be fixed, the testers make notes and submit them back to the appropriate team so they can fix the mistakes. Although some businesses conduct internal tests, doing so is not recommended because it is likely that these individuals have a basic understanding of how these apps operate and are prejudiced in favor of the product. \n\nThe validation process typically begins after the high-fidelity design is completed because testing with high-fidelity methods yields more insightful feedback from end-users. It is, however, also advisable to carry out tests also on your low-fi design; this helps in knowing that your user can carry out given actions with the barest minimum. During several user testing sessions, the team validates the product with stakeholders and end-users. \n\nThe following activities may be included in the validation phase of the UX process: \n- __Testing sessions:__ User testing sessions with participants who correspond to your target market are crucial. There are numerous forms to experiment with, such as moderated/unmoderated usability testing, focus groups, beta testing, and A/B testing.\n- __Surveys:__ Surveys are a fantastic tool for gathering quantitative and qualitative data from actual people. Open-ended questions, such as \"What portion of the product do you dislike?\" might be added by UX designers to elicit user feedback on specific features. \n- __Analytics:__ Quantitative data (clicks, navigation time, search queries, and so on) from an analytics tool can be helpful in determining how users engage with your product.\n\nThere are a few things to consider while assessing your finished project. Some are:\n- Is the system simple to use? \n- Is it adaptable and straightforward to use? \n- Does it resolve the client's problem? \n- Does it have credibility and entice customers to return when they require your service?\n\nIt should be noted that the UX design process is an iterative process where the designer performs back and forth movement based on findings from user testing sessions and meetings with stakeholders and our developers. \n\n### Conclusion\nOne must adopt a systematic approach to create excellent UX/UI interfaces. To do this, we need a UI/UX design process technique. The entire design team will participate in the process. In this increasingly competitive world, this is one of the most acceptable methods to maintain present clients and attract new ones.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},"contentAuthor":[{"sys":{"type":"Link","linkType":"Entry","id":"KLiU6Wijp0SYkFb5R8l8O"}}],"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5APeNbEeKnTF02HUbvVoq4"}},{"sys":{"type":"Link","linkType":"Entry","id":"2uvUxTj7xgbHN7m06Ekpmo"}},{"sys":{"type":"Link","linkType":"Entry","id":"6caWgGv16CdBLAnAELHGjH"}}],"openExternalLinksInNewTab":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"Yq88cq14TQ3XuFPRYqdQu","type":"Entry","createdAt":"2021-10-07T09:56:26.406Z","updatedAt":"2022-07-27T14:36:05.190Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":118,"revision":50,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Tarjan’s Algorithm for Strongly Connected Components","slug":"tarjans-algorithm-for-strongly-connected-components","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6LejbREKwjFTtngZH8SHgt","type":"Entry","createdAt":"2019-09-18T07:37:42.467Z","updatedAt":"2019-09-18T07:37:42.467Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Graph Theory","trackParent":"Competitive Programming"}}],"tags":["SCC","Tarjan","Low link"],"creationDate":"2021-10-07","readTime":"9min","content":"Strongly connected components (SCCs) can be thought of as self-contained cycles within a directed graph where every vertex in a given cycle can reach every other vertex in the same cycle.\n\nIf you look at the graph below, you will find that it has four SCCs, each has its own self-contained cycle and for each component, there is no way to find a path that leaves a component and returns back. This property ensures that SCCs in a graph are unique.\n\n![image](//images.contentful.com/piwi0eufbb2g/15p4U9s2ie9Md3PcGMIs3P/34dcbfcb2ee2483a67a8f2924227f734/image.png)\n\nTo find SCCs we have two algorithms at hand, Tarjan’s and Kosaraju’s algorithms. In this article we are going to cover Tarjan’s algorithm.\n\n### Low-Link Values\n\nBefore we jump to Tarjan’s algorithm, we must have an understanding of low-link values.\n\nThe low-link value of a node is the smallest node ID reachable from that node when doing a depth-first search (DFS), including itself.\n\nThere is a catch with doing a DFS on the graph, as it is highly dependent on the traversal order of the DFS, which is effectively random.\n\nWe are going to prove our above statement by giving you some examples:\n\n![image](//images.contentful.com/piwi0eufbb2g/1RuYR0FmiHXmFSVyC6griS/e9130e69d68bd923c83b99d3fd0b5f55/image.png)\n\nIn the above graph, we labeled it with some data and did the DFS on the 0th node, and let the DFS play and mark every node with its low-link value. After the graph is labeled it looks like this:\n\n![image](//images.contentful.com/piwi0eufbb2g/lKwKOYnOJsN8OLOULYKiu/9f3d56137b38f9f92b0876a876922704/image.png)\n\nSeeing the results we might feel that it’s working fine. But, to contradict our example, we will now label the nodes differently and start the DFS again from the 0th node. Let’s see how it pans out.\n\n![image](//images.contentful.com/piwi0eufbb2g/Krd8BzrvT6Ts6KgAMxetb/c9e686902f959a13e1e25ffbf969a7c5/image.png)\n\nAs we can see all the nodes have the same low-link value, but there are multiple SCCs.\n\n__Note__: Depending on where the DFS starts, and the order in which nodes/edges are visited, the low-link values for identifying SCCs could be wrong.\n\nSo, to make it work, we have to use an invariant that prevents SCCs from interfering with the low-link value of other SCCs.\n\n### Stack invariant\n\n#### Algorithm:\nTo cope with the random traversal order of the DFS, Tarjan’s algorithm maintains a stack of valid nodes from which to update low-link values. Nodes are added to the stack of valid nodes as they are explored for the first time. Nodes are removed from the stack each time a complete SCC is found.\n\n#### Update Condition for Low-Link\nIf u and v are nodes in a graph and we were currently exploring u, then our new low-link update condition is:\nTo update node u to node v low-link there has to be a path of edges from u to v and node v must be on the stack.\n\n#### Time Complexity\nWe are going to update low-link values on the fly  during the DFS so we can get a linear O(V+E) time complexity.\n\nCode:\n\n```c++\n#include<iostream>\n#include<stack>\n#define v 5\nusing namespace std;\n\nint graph[v][v];\n\nint min(int a, int b) {\n   return (a<b)?a:b;\n}\n\nvoid findComponent(int u, int disc[], int lowLink[], stack<int>&stk, bool stkItem[]) {\n   static int time = 0;\n   disc[u] = lowLink[u] = ++time;    \n   stk.push(u);\n   stkItem[u] = true;    \n\n   for(int v = 0; v<v; v++) {\n      if(graph[u][v]) {\n         if(disc[v] == -1) {   \n            findComponent(v, disc, lowLink, stk, stkItem);\n            lowLink[u] = min(lowLink[u], lowLink[v]);\n         } else if(stkItem[v])    \n            lowLink[u] = min(lowLink[u], disc[v]);\n      }\n   }\n\n   int poppedItem = 0;\n   if(lowLink[u] == disc[u]) {\n      while(stk.top() != u) {\n         poppedItem = stk.top();\n         cout << poppedItem << \" \";\n         stkItem[poppedItem] = false;   \n         stk.pop();\n      }\n      poppedItem = stk.top();\n      cout << poppedItem <<endl;\n      stkItem[poppedItem] = false;\n      stk.pop();\n   }\n}\n\nvoid strongConComponent() {\n   int disc[v], lowLink[v];\n   bool stkItem[v];\n   stack<int> stk;\n\n   for(int i = 0; i<v; i++) {    \n      disc[i] = lowLink[i] = -1;\n      stkItem[i] = false;\n   }\n\n   for(int i = 0; i<v; i++)    \n      if(disc[i] == -1)\n         findComponent(i, disc, lowLink, stk, stkItem);\n}\n\nint main() {\n   strongConComponent();\n}\n```\n\n### Overview \n\nMark the ID of each node as unvisited.\nStart DFS. Upon visiting a node, assign it an ID and a low-link value. Also, mark current nodes as visited and add them to a seen stack. \nOn DFS callback, if the previous node is on the stack, then min the current node’s low-link value with the last node’s low-link value. After visiting all neighbors, if the current node started a connected component, then pop nodes off the stack until the current node is reached.\n","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1WA4wbSfAiGt7pf2mprZ4U","type":"Asset","createdAt":"2021-10-07T09:47:05.963Z","updatedAt":"2021-10-07T09:47:05.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"tarjan","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1WA4wbSfAiGt7pf2mprZ4U/ad45125680ba3a7033501dd8ca75fd5e/tarjan.jpeg","details":{"size":34129,"image":{"width":990,"height":355}},"fileName":"tarjan.jpeg","contentType":"image/jpeg"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7CyVdH9aPUhVdq5DYUvH3A","type":"Entry","createdAt":"2021-10-05T15:42:33.118Z","updatedAt":"2021-10-06T09:53:02.310Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Nikhil Kumar Singh","tcHandle":"Vrishchik"}}],"upvotes":6,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3KntZ6sSEjLlQmtIa4hbA2"}},{"sys":{"type":"Link","linkType":"Entry","id":"64dCpVTbATrysnaZ8MEmMz"}},{"sys":{"type":"Link","linkType":"Entry","id":"5IShlfU89ow1d1M8sujBp3"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"bVyyo5py0gykE4M3Qo73C","type":"Entry","createdAt":"2021-11-20T15:09:24.320Z","updatedAt":"2021-12-03T16:05:59.917Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":54,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Merging Two Sorted LinkedLists","slug":"merging-two-sorted-linkedlists","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}}],"tags":["JAVA"],"creationDate":"2021-11-20","readTime":"7min","content":"Suppose we are given two LinkedLists which are sorted in increasing order and we need to merge them into one. We will create a method, __mergeLinkedList()__, which will traverse both the LinkedLists, merge them into a single LinkedList, and return the single LinkedList.\nThe new returned LinkedList will have all the nodes which are present in both original LinkedLists.\nIf we have, \n\n__LikedList1__:  2 -> 5 -> 9 -> 12 -> 15 -> 20\n\n__And__\n\n__LinkedList2__:  3 -> 7 -> 10 -> 17 -> 22\n\nthen our method should return the head pointer pointing to a merged LinkedList.\n\n__Merged LinkedList:__  2 -> 3 -> 5 -> 7 -> 9 -> 10 -> 12 -> 15 -> 17 -> 20 \n->22\t\n\n### Methods of Merging \n#### Method: Using Dummy Nodes\nIn this example we will create a dummy node as a result of our merged LinkedList. The tail pointer will point to the dummy node initially and then we will have a tail pointer pointing to the last node of our result list. \n\n##### Algorithm for Dummy Nodes\n__Declaration__\ncreate two Nodes\ndummyNode =null\ntail = dummyNode;\n\n__Execution__\n__Step 1:__\nif List1=null\nwe have traversed the List1 or List1 is empty\nthen tail.next will point to List2\n\nif List2=null\nwe have traversed the List2 or List2 is empty\nthen tail.next will point to List1\n\n__Step 2:__\n\t  check if list1.data < list2.data\n\t\t   then tail.next will point to node containing List1.data\n\t\t   update list1=list.next\n\t\t else\n\t\t       tail.next will point to node containing List2.data\n\t\t       update list2=list.next\n\n__Step 3:__\n\t\tif both lists not processed then\n\t\tupdate tail and  go to step 1\n\t\telse go to Step 4\n\n__Step 4:__  \tReturn dummyNode.next\n\n__Java Implementation for Dummy Nodes__\n```java\nclass Solution\n{\n//will return a node pointing to Result List\nNode mergeLinkedList(Node listA, Node listB)\n{\n\n\t//create dummy Node\n    Node dummyNode = new Node();\n\n    Node tail = dummyNode;\n\n\t//will break out of Loop\n    while(true)\n    {\n        //check if listA is empty of traversed\n        if(listA == null)\n        {\n            tail.next = listB;\n            break;\n        }\n\t\t//check if listB is empty of traversed\n        if(listB == null)\n        {\n            tail.next = listA;\n            break;\n        }\n\n        /* \n\t\tcheck which listdata is lesser will be appended to\n\t\t tail.next\n        */\n        if(listA.data <= listB.data)\n        {\n            tail.next = listA;\n            listA = listA.next;\n        }\n        else\n        {\n            tail.next = listB;\n            listB = listB.next;\n        }\n\n        //update tail\n        tail = tail.next;\n    }\n\t//returning the Result List\n    return dummyNode.next;\n}//method Ends\n\n}//Class Ends\n```\n\n#### Method: Using Recursion\nIn the above method we tried the iterative approach using dummy nodes. Now we will try the recursion technique to merge two sorted LinkedLists. There is less code than with the iterative approach as it uses the call stack to call itself to work with passed arguments.\n\n##### Algorithm\n\n__Step 1:__ Call made to mergeLinkedList() and list1 and List2 will be passed\n\n__Step 2:__\n\tif list1 is empty return list2\n\tif list2 is empty return list1\n\n__Step 3:__\n\tif list1.data < list2.data\n\tthen call mergeLinkedList(list1.next, list2) to Step 1\n\tand return list1\n\telse\n\tcall mergeLinkedList(list1, list2.next) to Step 1\n\tand return list2\n\n__Java Implementation Using Recursion__\n```java\nclass Solution\n{ \n//Result List will listBe returned\nNode sortedMerge(Node listA, Node listB)\n{\n     if(listA == null) return listB;\n        if(listB == null) return listA;\n\n        if(listA.dlistAtlistA < listB.dlistAtlistA)\n        {\t//call mergeLinkedList recurively\n            listA.next = SortedMerge(listA.next, listB);\n            return listA;\n        }\n        else\n        {\t//call mergeLinkedList recurively\n            listB.next = SortedMerge(listA, listB.next);\n            return listB;\n        }\n\n    }\n}\n```\n\n#### Method: Reversing LinkedLists\nIn this method we will maintain both the LinkedLists in decreasing order; this means both LinkedLists will be reversed. Then, comparing the head of each list and adding to the last of the resultant list will get the LinkedList in increasing order.\n\n__Java Implementation__\n```java\nclass Solution\n{ \n\nNode reverseLL(Node A)\n    {\n        Node prev = null;\n        Node current = A;\n        Node next = null;\n        while (current != null) {\n            next = current.next;\n            current.next = prev;\n            prev = current;\n            current = next;\n        }\n        A = prev;\n        return A; //returning reversed LList\n\n    }\n//Result List will listBe returned\nNode sortedMerge(Node listA, Node listB)\n{\n\tlistA=reverseLL(listA);\n\tlistB=reverseLL(listB);\n\n\tNode res=null;\n\tNode temp=null;\n\n\twhile(listA!=null && listB!=null)\n\t{\t\n\n\t\t if (listA.data >= listB.data) {\n             temp = listA.next;\n\n            listA.next= res;\n                      res = listA;\n\n            listA = temp;\n        }\n        else {\n\n            temp = listB.next;\n            listB.next;= ress;\n            res= listB;\n            listB = temp;\n        }\n\n}\n\n    }//methodSM Ends\n}\n```\n\n#### Method: Using Local Reference\nIn this method we will use a local reference variable which will point to the head of the result node. We will use infinite iteration to execute the same.\n\n#### Algorithm\n\n__Step 1:__ Call made to mergeLinkedList() and list1 and List2 will be passed\n\n__Step 2:__\n\tif list1 is empty return list2\n\tif list2 is empty return list1\n\n__Step 3:__\nLoop ,Iteration for each Node\nif list1.data < list2.data\nthen call put current head of list1 in next of result\nif list2.data < list1.data\nthen call put current head of list2 in next of result\n\ncheck if any list is empty\nthen add second list to end of result ilst and break\n\nreturn the result\n\n__Java Implementation__\n```java\nclass Solution\n{ \n//Result List will listBe returned\nNode sortedMerge(Node listA, Node listB)\n{   Node resultLL=null;\n     if(listA == null) return listB;\n        if(listB == null) return listA;\n\nfor(int i=1;i>0;)\n{\n\tif(listA.data<listB.data)\n\t{ resultLL.next=listA;\n\t   listA=listA.next;\n\t}\n\telse\n\t{\n resultLL.next=listB;\nlistB=listB.next;\n}\nif(listA==null)\n{\n\tresultLL.next=listB; break;\n}\nif(listB==null)\n{\n\tresultLL.next=listA; break;\n}\n}   //for loop ends      \n    }\n}\n```","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1ZaMXHSILRR4CTOabSGHTC","type":"Asset","createdAt":"2021-11-20T15:00:35.154Z","updatedAt":"2021-11-20T15:00:35.154Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Banner (5)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1ZaMXHSILRR4CTOabSGHTC/4c307af9eca5c2bbcb60a61b675f21c6/Banner__5_.png","details":{"size":13435,"image":{"width":1050,"height":600}},"fileName":"Banner (5).png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"39ckTBSt0xTU3sOrfGTeM6","type":"Entry","createdAt":"2021-09-15T13:57:45.457Z","updatedAt":"2021-11-20T15:25:07.546Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Kulwinder Kaur","tcHandle":"kulwinder3213"}}],"upvotes":3,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"5T5qgfiHwl75dfm6IMxBcy"}},{"sys":{"type":"Link","linkType":"Entry","id":"74eK6bUhfnKnzBkBpjSREj"}},{"sys":{"type":"Link","linkType":"Entry","id":"3RUcXHuc3tXWkmdesAkmr7"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"f9pUhpnMyK8zZmgYuuEjD","type":"Entry","createdAt":"2022-04-19T07:40:38.653Z","updatedAt":"2022-04-19T07:40:38.653Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Druti Bansal","tcHandle":"drutibansal"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"fzXd6gE9YaVI5wn3t3KF9","type":"Entry","createdAt":"2019-09-19T09:55:30.314Z","updatedAt":"2019-09-19T09:55:30.314Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"How-To","trackParent":"Competitive Programming"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"krziWcdrBi43HXkh0VYWr","type":"Entry","createdAt":"2019-08-27T06:12:20.665Z","updatedAt":"2019-08-27T06:12:20.665Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Topcoder-Centric","trackParent":"Development"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"l66ifjfnjwZSmYwRdlOID","type":"Entry","createdAt":"2020-01-09T21:49:28.808Z","updatedAt":"2020-01-09T21:49:28.808Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":17,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Copilot","trackParent":"Topcoder","description":"Copilot documentation."}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"n6mlhtkgBaqaEoDit68Rs","type":"Entry","createdAt":"2020-01-09T19:02:56.321Z","updatedAt":"2020-01-09T19:02:56.321Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":11,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Competitor Documentation","trackParent":"Topcoder"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"ngf3PiJzyUzZn7ouBvbJv","type":"Entry","createdAt":"2020-04-20T12:42:16.217Z","updatedAt":"2020-04-20T12:42:16.217Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":1,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"teja349","tcHandle":"teja349"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"qYP8EEHcdphNJ7DcOGTgf","type":"Entry","createdAt":"2019-12-28T15:05:40.611Z","updatedAt":"2022-07-25T11:23:54.972Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":638,"revision":42,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"How to Compete in SRM Algorithm Competitions","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"[General Topcoder Arena Usage / Getting Started](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena)\n\n1). Become a Topcoder Member\n2). What is the Topcoder Arena?\n3). How to Run the Topcoder Arena\n  <span style=\"display: inline-block; padding-left: 25px\">a) What software will you need to install?</span>\n  <span style=\"display: inline-block; padding-left: 25px\">b). Running the Topcoder Arena as an Applet or by using Java Web Start</span>\n  <span style=\"display: inline-block; padding-left: 25px\">c). Local Firewall and Network Considerations</span>\n  <span style=\"display: inline-block; padding-left: 25px\">d). HTTP Tunneling</span>\n4). Logging in to the Topcoder Arena\n5). General Usage and the Various Lobbies\n6). Chatting / Asking Questions\n      <span style=\"display: inline-block; padding-left: 25px\">a). General Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). ReplyTo</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Whisper</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). Admin</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Auto-Enhanced Chat</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Emoting</span>\n7). Other Members in the Arena\n      <span style=\"display: inline-block; padding-left: 25px\">a). Getting Information about another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Finding Another Member</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). Seeing Who's in the Arena</span>\n8). Moving Around\n9). The Leader Board\n\n[Practicing / Training in the Topcoder Arena](https://www.topcoder.com/thrive/articles/Practicing%20in%20the%20Topcoder%20Arena)\n1). The Practice Rooms\n      <span style=\"display: inline-block; padding-left: 25px\">a). Timing in the Practice Room</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). Selecting a Problem</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). System Testing</span>\n      <span style=\"display: inline-block; padding-left: 25px\">d). The Room Summary</span>\n      <span style=\"display: inline-block; padding-left: 25px\">e). Challenging</span>\n      <span style=\"display: inline-block; padding-left: 25px\">f). Clearing Problems</span>\n\n[Competing in a Rated Event](https://www.topcoder.com/thrive/articles/Competing%20in%20a%20Rated%20Algorithm%20Competition)\n1). When are the Rated Events?\n2). How does a Rated Event Differ from the Practice Room?\n3). Registration for a Single Round Match\n4). Division One versus Division Two\n5). Room Assignments - Getting to Your Room\n6). The Phases of a Rated Event\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Coding Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Challenge Phase</span>\n      <span style=\"display: inline-block; padding-left: 25px\">c). The System-Testing Phase</span>\n7). Code Obfuscation\n8). Excessive / Extra Code Rule\n9). Broadcast Messages\n10). Getting the Status of Other Competitors\n      <span style=\"display: inline-block; padding-left: 25px\">a). The Leader Board</span>\n      <span style=\"display: inline-block; padding-left: 25px\">b). The Room Summary Window</span>\n11). Getting Help\n12). Determining Score\n13). Rating Changes\n14). Web Site Statistics\n15). Problems in the Practice Rooms\n16). What if You Do Not Agree with the Results?\n17). Problem Set Analysis and Discussion\n18). Getting Disconnected from the Arena\n19). Cheating at Topcoder\n20). Using Pre-Written Code\n21). Topcoder Arena Plug-ins\n\n[The Coding Window](https://www.topcoder.com/thrive/articles/The%20Coding%20Window)\n1). The Problem Statement\n2). Choosing a Language\n3). Creating a Solution\n4). Compiling\n5). User Testing\n6). Submitting\n7). Saving\n8). Clearing the Code\n9). The Timer\n\n[The Problem Arguments Window](https://www.topcoder.com/thrive/articles/The%20Problem%20Arguments%20Window)\n1). Examples\n2). Simple Data Types\n3). Complex Data Types\n\n[The Room Summary Window](https://www.topcoder.com/thrive/articles/The%20Room%20Summary%20Window)\n1). Spectating\n2). Challenging\n3). Division Summary","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":12,"downvotes":2,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"36BwBXiBam8QqCTRVz9WMo","circular":true}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3C2k9vkRQwLa7Irbni9ocx","type":"Entry","createdAt":"2019-12-28T15:05:40.842Z","updatedAt":"2022-05-26T01:43:15.420Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":104,"revision":13,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Practicing in the Topcoder Arena","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-12-05","readTime":"5 min read","content":"### 1. The Practice Rooms\nAfter each rated event, a practice room will be added to the Arena that contains the problem set that was used in that rated event. This gives the event participants a chance to identify their errors or fine-tune their solutions, and it gives others a chance to get a feel for the types of problems that are used in a rated event. Although the practice rooms behave a bit differently than an actual rated event, utilizing the practice rooms is the best way for a non-rated member to become familiar with the most important part of the TopCoder Arena. The practice rooms are labeled based on the match and division in which they were used as actual problems.\n\nIt is highly recommend that all new members visit the practice rooms prior to competing in an algorithm rated event. By visiting a practice room you will learn the Arena interface, the nature of the problems, and the expected structure of your solution. You will also get a chance to look at thousands of submissions in various languages from other competitors who have visited the practice rooms. At the very least, looking at some submissions from others who use your intended language will show you: \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1) exactly how to structure your class, \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2) the various input and output types that are specific to your language\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3) how to import libraries in your language. Even though the submissions in the practice rooms are not necessarily correct, you do know that they have been successfully compiled.\n\n#### 1.1 Timing in the Practice Room\nThe practice room is designed to allow you to take your time and get a feel for the user interface. Once a problem is opened, you will have an unlimited amount of time to come up with a solution to the problem. However, the method of scoring is based on a total of 75 minutes - which is the amount of time that is given to complete a full set of problems during a rated event. The advantage of this is that the score that you receive upon submission of a solution will compare to the score that you would have received had you participated in that event. However, since there is no time limit in the practice area, if you exceed the 75 minutes, your score will bottom out at the lowest allowable score for that problem. During a rated event, the competition phases will proceed as such: coding phase, intermission, challenge phase, and finally the system-testing phase. In contrast, when in a practice room all of the functionality from the coding phase, the challenge phase, and the system-testing phase will be available all the time (see below for descriptions of each). There is no concept of changing phases in the practice rooms. In addition, the timer in the practice room will always show the phase as \"Coding\" and the remaining time as \"00:00:00\". During a rated event, the timer will always count down to the end of each phase along with indicating the current phase. \n\n#### 1.2 Selecting a Problem\nOnce in a practice room, you will need to select a problem before you can begin coding. To select a problem, click on the \"Select One\" drop-down box. In the list you will see point values that correspond to the difficulty of the problem - the higher the value, the more difficult the problem will be. Problems with higher point values have the potential to yield higher points for a successful submission. Once a problem is selected, TopCoder's server will begin keeping track of how long the problem has been open. The elapsed time between opening a problem and submitting a solution for that problem is the biggest factor in determining how many points are received upon submission of a solution. You may open more than one problem at a time - but keep in mind that the clock will be ticking for each problem, independent of one another. Once a problem is selected, the Coding Window will appear.\n\n#### 1.3 System Testing\nAfter you've submitted one or more problems in a practice room, you have the option of running the system tests. During the system tests, various sets of valid input parameters are applied to your submission, with the output from your submission being compared against the expected output for each test case. If the expected output does not match the received output for one or more of the test cases, your submission will \"fail\" the system tests. Failing the system tests in a practice room will not mark your submission as failed, nor will it deduct any points from your final score (as it would during a rated event). The execution time for system tests in a practice room will vary depending on the number of submissions you have, the number of test cases there are, and the efficiency of your submissions. Just keep in mind that you may need to wait a minute or more for all tests to finish. The system test results will appear in a pop-up window when they are done - the results in the window will be for any/all problems that you have submitted in that room. The system testing option is only available in a practice room - it will not be available in a competition room during a rated event. In a rated event, the system tests will run automatically - following the challenge phase. You may run the system tests by choosing \"Practice Options / Run System Tests\" from within a practice room.   \n\n#### 1.4 The Room Summary\nThe room summary window allows you to view information about other competitors and is also the interface for the challenge functionality. Check here for a detailed description of the Room Summary Window.\n\n#### 1.5 Challenging\nWhen you are in a practice room, the phases behave as if the coding phase and the challenge phase are running simultaneously and perpetually. At any time, you may view the source code of any other competitors in a practice room - and you have the option to challenge any of the submissions. The challenge restrictions that are regularly in place during a rated event have been lifted for the practice rooms. Therefore, you may challenge regardless of your current point total and you may challenge any submission at any time, regardless of its status.\n\n#### 1.6 Clearing Problems\nSince this is a practice room, you are welcome to start over on any or all of the problems in any of the practice rooms. Under the \"Practice Options\" menu item that appears when in a practice room, you'll see a \"Clear All Problems\" option along with a \"Clear Problem(s)\" option. The \"clear all\" will remove all of your submissions and history for all problems in that particular practice room. The \"clear problem\" option will allow you to specify a particular problem (or multiple problems) that should be cleared.","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":9,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6G5x331zgQQyDCOBrPghYj","type":"Entry","createdAt":"2019-12-28T15:05:39.002Z","updatedAt":"2024-08-21T20:47:43.292Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":163,"revision":22,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Solutions for Practice Problems","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-07-24","readTime":"5 min read","content":"1. Navigate this link: <https://community.topcoder.com/tc?module=ProblemArchive>\n\n2. Enter the problem name in Class Name.\n\n3. Click on Submit.<br/><br/>\n\n![imageufiuef](//images.ctfassets.net/piwi0eufbb2g/28vN96cZCobKXkkL6xp3xt/805ba6134fdbec94664fabc6e02b5220/imageufiuef.png)<br/><br/>\n\n4. Click on the problem name from the below.<br/><br/>\n\n![Inkedimage (1) LIiuhfiefoiefoewf](//images.ctfassets.net/piwi0eufbb2g/3fqxGyHpUJXAoqc9WvVXmi/848157c449ce28cdaa093ea86cf7a67a/Inkedimage__1__LIiuhfiefoiefoewf.jpg)<br/><br/>\n\n5. This will redirect you to the Problem Statement page.\n\n6. Scroll down the page and click on the link below this label \"__This problem was used for:__\"<br/><br/>\n\n![Inkedimage (2) LIjfdhdhfjhf](//images.ctfassets.net/piwi0eufbb2g/6vvtZrZaK2Z4NQejS6y0Zt/39a12c6ed2fdc8031b648ae8be4d9b51/Inkedimage__2__LIjfdhdhfjhf.jpg)<br/><br/>\n\n7. This will redirect you to the Problem detail page then click on View button to view the solution.<br/><br/>\n\n![Inkedimage (3) LIuidfoiwfuifjoif](//images.ctfassets.net/piwi0eufbb2g/6YMO1E8IhEmsFcJTBbTxjy/c5b2ea3d1d285eda87383aae8f192c17/Inkedimage__3__LIuidfoiwfuifjoif.jpg)<br/><br/>","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}}],"upvotes":9,"downvotes":9,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"3C2k9vkRQwLa7Irbni9ocx","circular":true}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3sjDvvGSbBIxAfEuRsKRYL","type":"Entry","createdAt":"2019-12-28T15:05:40.336Z","updatedAt":"2022-02-02T15:26:55.527Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":72,"revision":4,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"SRM Overview","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2017-04-25","readTime":"5 min read","content":"SRM competitions are timed contests where all contestants compete online and are given the same problems to solve under the same time constraints. The competitions are available in five programming languages: Java, C#, C++, VB.NET and Python.\n\nEach Single Round Match (SRM) consists of three phases: Coding Phase, Challenge Phase, and System Testing Phase.\n\n- __The Coding Phase__ is a timed event where all contestants are presented with the same three questions representing three levels of complexity and, accordingly, three levels of point earnings potential. Points for a problem are awarded upon submission of any solution that successfully compiles and are calculated on the total time elapsed from the time the problem was opened until the time it was submitted. The Coding Phase lasts 75 minutes.\n\n- __The Challenge Phase__ is a timed event wherein each competitor has a chance to challenge the functionality of other competitors' code. A successful challenge will result in a loss of the original problem submission points by the defendant, and a 50-point reward for the challenger. Unsuccessful challengers will incur a point reduction of 25 points as a penalty, applied against their total score in that round of competition. The Challenge Phase lasts 15 minutes.\n\n- __The System Testing Phase__ is applied to all submitted code that has not already been successfully challenged. If the TopCoder System Test finds code that is flawed, the author of that code submission will lose all of the points that were originally earned for that code submission. The automated tester will apply a set of inputs, expecting the output from the code submission to be correct. If the output from a coder's submission does not match the expected output, the submission is considered flawed. The same set of input/output test cases will be applied to all code submissions for a given problem. All successful challenges from the Challenge Phase will be added to the sets of inputs for the System Testing Phase.\n\nBe sure to read the [Algorithm Competition Guide](https://www.topcoder.com/thrive/articles/How%20to%20Compete%20in%20SRM%20Algorithm%20Competitions) for detailed information on how to compete in algorithm competitions.\n\nIn order to practice or compete in algorithm competitions, you'll need to run the [TopCoder Algorithm Competition Arena](https://www.topcoder.com/thrive/articles/The%20Algorithm%20Competition%20Arena).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":2,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"36BwBXiBam8QqCTRVz9WMo","type":"Entry","createdAt":"2019-12-28T15:05:40.988Z","updatedAt":"2022-04-27T10:57:32.422Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":294,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Competing in a Rated Algorithm Competition","type":"Article","trackCategory":["Topcoder"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TAPWduNbFCzV1yUJvFOsm","type":"Entry","createdAt":"2019-10-19T15:33:43.603Z","updatedAt":"2019-10-19T15:33:43.603Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Help Articles","trackParent":"Topcoder"}}],"tags":["Data Science","Single Round Matches (SRMs)"],"creationDate":"2019-03-07","readTime":"20 min read","content":"### 1 When are the Rated Events?\nTopCoder holds two types of rated events. Single Round Matches (SRMs) are held twice a month. The day and time of SRMs varies from match-to-match. See the event schedule on TopCoder's web site for the dates and times of future SRMs. Please keep in mind that all times on TopCoder's web site are communicated in either Eastern Standard Time (EST / GMT -5) or Eastern Daylight Time (EDT / GMT-4) depending on the time of the year. The web site will specify for which time zone the time for each match is specified. In addition, you may elect to receive a reminder email preceding each SRM. To do so, select to \"Next Competition\" box under the \"Email Notification\" heading in your TopCoder profile information. By checking this option, you will also receive emails regarding upcoming TopCoder tournaments and events.\nIn addition to SRMs, TopCoder holds one advancement tournament (the TopCoder Open ) each year. Advancement tournaments are elimination tournaments and generally have a substantial prize purse involved. Each round of a tournament will affect the ratings of all participants, so they are also considered \"rated events\". The details on each of these events are posted to TopCoder's site as they are finalized. You can also view the information and details of most past tournaments.\n\n### 2 How does a Rated Event Differ from the Practice Room?\nThere are a number of differences - the biggest being that participating in a rated event will affect your TopCoder rating, whereas utilizing the practice rooms does not affect your rating. If you register for a rated event and proceed to open any of the problems during the coding phase, your rating will be affected following the match.\n\nAdditionally, a rated event is timed - whereas in a practice room you have unlimited time to submit solutions to a problem (and start over if you'd like). For example, if you attempt to submit a solution after the coding phase has ended, or a challenge after the challenge phase time has run out, the TopCoder servers will reject it.\n\nIn the practice rooms, you always have the ability to view the source code of other members who have submitted code in that room. In a rated event, you will not have the option of viewing the source code of other competitors until the start of the challenge phase.\n\nDuring a rated event, you must always be cognizant of the amount of time that is remaining in the current phase of competition.\n\n### 3 Registration for a Single Round Match\nIn order to participate in a match, you must register for that match from within the TopCoder Arena prior to the start of the match. The registration period lasts for 2 hours and 55 minutes and starts exactly 3 hours before the match begins. In order to register, highlight the appropriate match from the \"Active Contests\" menu and select \"Register\". At this point, you will be asked to agree to the terms and rules of the match, as well as answer a short multiple-choice poll. Once you select \"I Agree\" at the bottom, you will be registered for the match. It is a good idea to confirm your match registration by selecting \"Registrants\" for the appropriate match in the Active Contests menu and verifying that your handle is in the list. The list may be sorted by any of the column headings (by clicking on the heading). If you are not in this list, you will not be assigned a place in the match. Please make sure that you register well in advance of the close of registration to ensure that registration does not close while you are in the process of registering. TopCoder cannot add anyone to the match after the registration period closes. After you have registered, it is not necessary for you to remain logged into the TopCoder Arena. When you log back in, you will still be registered for that match.\n\n### 4 Division One versus Division Two\nAt TopCoder, there are two divisions of competition. The specific division that you are in is dependant only on your TopCoder rating. If your TopCoder rating is 1200 or above, you will be competing in Division One. Otherwise, you will be competing in Division Two - even if you are non-rated. The problem set in Division One is harder than the Division Two problem set. Frequently, one problem from the Division One set will be shared in Division Two - generally as a higher point value problem in Division Two. A coder will move into Division One immediately upon attaining a rating of 1200 or higher. Likewise, when a coder's rating drops below 1200, they will be placed (and seeded) in Division Two. The rating calculations that are performed at the end of each match will only consider your comparative performance within the division that you competed in.\n\n### 5 Room Assignments - Getting to Your Room\nWhen the registration period for a match closes (5 minutes before the start of each match), the \"room assignments\" will be created. The result of room assignments is that each member who registered for the match will have been assigned to a room in which they will be competing. The algorithm that is used may differ with each match. The room assignments for a match really only matter for the challenge phase (you may only challenge those in your assigned room), since the overall rating adjustments will consider all coders in a given division - not just the room. The room assignment process will take about 2 minutes. When it has completed, you will be able to move to your competition room by selecting the appropriate match from the \"Active Contests\" menu, and selecting \"Enter\". Whenever you are assigned to a room in a current match, the \"Enter\" option will take you to whatever room you are assigned. If you are not assigned to any room, you will be taken to room one by default. If you are not in your assigned room when the coding phase begins, you will receive a message notifying you of such - and asking you if you would like to move directly to your assigned room. If you move to your room early (before the coding phase begins) you will not have the ability open any problems until the coding phase begins. In other words, you cannot see the problems until the coding phase begins. You may, however, see the point values assigned to the problems in the drop-down list prior to the start of the coding phase.\n\n### 6 The Phases of a Rated Event\nAll phases of a TopCoder rated event will start and end at the same time for every competitor. Certain functionality in the Arena will become enabled or disabled based on which phase is taking place. Each event will consist of the following phases.\n\n#### 6.1 The Coding Phase\nThe Coding Phase is the period during which each competitor attempts to create solutions to three problem statements. In most cases, the coding phase will last 75 minutes, which is the total time that you have to submit solutions to any or all of the problems. When the coding phase begins, each competitor will have the opportunity to view the problem statements. Each problem can be opened by selecting its point value from the \"Select One\" drop-down box. The higher the point value assigned, the more difficult the problem will be. You may open the problems in any order. As soon as a problem is selected, the submission point value for that problem will begin to decrease. The longer a problem is open, the lower your score will be should you submit. You have the option to open more than one problem at a time, however the submission value of each open problem will be counting down. Closing a problem will not stop that's problem's point value countdown. Once you open a problem, you will be presented with the Coding Window. The description of the Coding Window contains information about the features and functionality available to you to allow you to create a solution to the problem, compile the solution, test the solution, and submit the solution.\n\n#### 6.2 The Challenge Phase\nThe Challenge Phase generally begins five minutes after the end of the Coding Phase (the period in between is an intermission), and will last for 15 minutes.\n\nDuring the Challenge Phase, you have the opportunity to view the source code submissions of the other competitors in your competition room. If you believe that any of the submissions are flawed, you may challenge the submission with a specific test case that you feel will result in that submission returning the wrong result. If your challenge is successful, and the submission returns the wrong result, you will be awarded 50 points and the competitor will lose the points that were received for the challenged submission. However, if your challenge is unsuccessful, and the submission returns the correct result for the test case, you will lose 25 points from your score.\n\nTo challenge a competitor's submission, open the Room Summary Windowin the competition room by using the \"Summary\" button. Double click on any of the point values to view the source code for that submission. When viewing the source code, you will notice a \"Challenge\" button at the bottom of the window. The Challenge button will bring up the Argument Windows, allowing you to enter the test case with which to challenge the submission.\n\nChallenges may also be used as a way to introduce new test cases into the suite of system test cases. Any challenge during the challenge phase that is recorded as successful will be added as a system test case - to be run against all remaining submissions during the system-testing phase.\n\nThere are a few restrictions during the challenge phase:\n- You may only submit a challenge if you have a score of zero or greater at the time of the challenge. Once your score drops below zero, you will no longer have the option / ability to challenge.\n- You may only challenge submissions made in the same competition room as your own.\n- A given submission may only be successfully challenged once. If any competitor has already successfully challenged a submission, it may not be further challenged.\n- You may not challenge your own submissions.\n\nIt is a violation of the rules to discuss any aspect of the problems or any specific submissions with anyone until the challenge phase has ended.\n\n#### 6.3 The System-Testing Phase\nThe system-testing phase is non-interactive. Immediately following the challenge phase, the TopCoder servers will run a number of housekeeping tasks, followed by the system testing. During the system testing, every problem that is still standing will be subjected to an extensive set of test cases. The system will check to make sure that each submission returns the correct result in under 2 seconds for each of these test cases. If any submission fails any of the test cases, the submission will be marked incorrect and the points achieved for that submission would be removed from that coder's total score. The system testing will generally take between 10 and 20 minutes - sometimes longer. You do not need to stay logged into the TopCoder Arena during the system tests - only if you want to see your final score as soon as it is announced. When the system tests have completed, a message will be sent out to all competitors who are logged in, and the leader board, room summary, and division summary scores will all be updated to reflect the final results.\n\n__From time to time, system tests may need to be re-run for a match, possibly several hours after it ends or even the following day. In cases where this happens, the results of the last run are considered the final results for the match. Competitors who write non-deterministic submissions (e.g. randomized algorithms, or monte-carlo type simluations) may be at risk of their pass/fail status changing as a result of system tests being re-run. The results of the last run will be considered final, without consideration to how a submission fared initially.__\n\n### 7 Code Obfuscation\nTopCoder has a policy against any intentional obfuscation of code submissions. Code obfuscation is defined as any obvious and deliberate attempt to create obstacles to reading and understanding the submission, usually by attempting to disguise the true behavior or nature of the code. Note that inclusion of large amounts of unused code formatted in a way that makes it difficult to locate the relevant parts of the submission can also be considered as obfuscation.\n\nIn ALL cases, TopCoder will make the final decision as to whether or not a code submission has violated this rule. Any code submission that is determined to be obfuscated will be rejected and any points received for that submission would not count towards your final score. In some cases, TopCoder may additionally decide to “nullify” any unsuccessful challenges that have been applied against a code submission that is determined by TopCoder to be obfuscated.\n\nWe encourage any TopCoder competitor to notify us in the event that they feel that a code submission during a rated event violates this policy.\n\n### 8 Excessive / Extra Code Rule\nTopCoder previously had a policy against including extra content in a submission that is not part of the solution to the problem. Starting from TCO 2021 online finals this rule has now been removed. There is no penalty for extra content in a submission, as long as it does not violate the rule on code obfuscation.\n\nThe most common way of producing a submission that may contain large amounts of unused code is the inclusion of a code template or a pre-written code library. If your submission contains unused code for this reason, it is your responsibility to make sure that it is formatted it in a way that makes it clear which parts of your submission are pre-written.\n\nNote that for the time being TopCoder Arena may still give you a warning when your submission seems to contain a significant amount of unused code. As long as your submission complies with these rules, the warning can safely be ignored.\n\n### 9 Broadcast Messages\nDuring a competition, TopCoder may notify participants of important information regarding the competition via the use of broadcast messages. Broadcast messages, by default, will pop-up on your screen when they are sent. If the broadcast pop-up is disabled in your Arena, the \"Messages\" button will blink when a new message arrives. In either case, it is possible to get a history of recent messages by clicking on the \"Messages\" button. These messages may contain important information about changes or additions to the problem statements being used in the match. Be sure to read any messages that are sent during a match - chances are it's important! Also, remember to check for new messages every time you log into the Arena during a match - you may have missed a message that was sent while you were disconnected.\n\n### 10 Getting the Status of Other Competitors\n#### 10.1 The Leader Board\nDuring times when there is at least one TopCoder event taking place in the Arena, you can get an overview of the action by clicking on the \"Leader Board\" button on the left side of the Arena. The leader board window contains a list of all rooms for a given event along with the current leader in each room. Additional information for each room includes 1) the room number, 2) the seed (expected room placement) of the current leader, and 3) the current point total for the leader. If there are multiple events taking place, you can switch the leader board to a different event using the \"Rounds\" drop-down list at the bottom of the leader board window. Clicking on any of the column headings in the leader board will sort the list by the information in the column that was clicked.\n\nIn addition, you have the option of \"drilling in\" to any of the rooms by double clicking on any of the individual rooms listed in the leader board. Drilling into a room will open the Room Summary Window, which will display each member who is competing in that room, along with their current point totals and status for each of the problems.\n\n#### 10.2 The Room Summary Window\nThe Room Summary Window will show information about each competitor within a given room of competition. The room summary is also the competitor interface for the challenge phase. View the Room Summary Window explanation for more information.\n\n### 11 Getting Help\nAt some point during your TopCoder adventures you will likely need to get a question answered by the administrators. During rated events, there are always administrators available to answer your questions. The best place to find a TopCoder administrator (identified by their bold, orange handles) is in the \"Admin Lobby Room\" - which can be found under the \"Lobbies\" menu option. Please keep in mind that all chat in the Admin Lobby Room is reserved for questions related to the current rated event that is taking place. You also may communicate with TopCoder administrators without leaving your assigned competition room. At any time while in the TopCoder Arena, prefacing a chat message with \"admins: \" will broadcast the chat message to the Admin Lobby Room, as well as the room that you are in. The TopCoder Administrators can reply directly to you without leaving the Admin Lobby Room. If you prefer a private correspondence with the TopCoder Administrators, you may whisper to an individual administrator by prefacing your chat message with \"/msg \". This will allow you to ask a question of the administrators without other in your room being able to see the nature of the question. All administrators will see your whisper (as well as all whispered messages).\n\n### 12 Determining Score\nThe point value of a submission is dependent upon the problem's level of difficulty and the time it took to code a solution. The TopCoder server will calculate the time spent on a problem by counting the time between when the coder selects a problem and when a solution is submitted. Keep in mind that these times are captured when a problem request or problem submission actually gets to our server, so network latency may play a minor role in the competition process.\nTotal points awarded = ![pts](//images.ctfassets.net/piwi0eufbb2g/39ByrsCpQJdXaPaBbMGU8N/27fd18b353859dfe689b302342fcf2a6/pts.gif)\n\nWhere PT is the time spent coding a problem, TT is the total time allocated for coding all problems, and MP is the maximum points available for that problem.\nFor example:\nA coder spends 22.7 minutes working on the medium problem before submitting. Given the fact that the total coding round is one hour, and the maximum point value for the medium problem is 500, the coder's awarded points for the submission will be:\n500*(.3 + .7*60^2/(10*22.7^2+60^2))\nor\n293.95 points (point calculations are rounded to two decimal places)\n\n### 13 Rating Changes\nAt the conclusion of the system-testing phase, TopCoder will recalculate the TopCoder ratings of all match participations based on our rating formula. If you did not open any problem during the coding phase, you will not have your rating adjusted. Once the rating adjustments are completed, it will be announced via an administrative broadcast message.\n\nYour rating change is essentially a measure of how well you performed compared to others in your division - given how well you were expected to perform based on your previous rating. Your rating increases when your performance exceeds expectations!\n\nThe rating updates are subject to change based on any appeals that TopCoder may receive the day following a match. If any scores are determined to be incorrect (within the appeals period), TopCoder will re-adjust the ratings based on the correct scores.\n\n### 14 Web Site Statistics\nAfter each match, you can find comprehensive statistics about almost all aspects of the match on TopCoder's website. This includes both summary information regarding the success rate on each of the problems all the way down to viewing the code submissions of each competitor and the arguments that caused any submission to fail a system test. In order to view most of the statistical information on the website, you will need to log in to the site with your TopCoder handle and password. When the statistics have been compiled by our servers and are ready to be viewed (about 15-20 minutes after the system tests are complete), TopCoder will announce the availability of the statistics via an administrative broadcast message. \"Statistics / Round Overview\" in the left side navigation area of the TopCoder website will take you to the top level of the statistics for the most recent match. Clicking on the \"[*]\" symbol next to any entry will drill into the statistics for the given entry.\n\n### 15 Problems in the Practice Rooms\nBoth the Division One and the Division Two problem sets are placed into new practice rooms following each match. The new practice rooms will usually be available within an hour of the match ending.\n\n### 16 What if You Do Not Agree with the Results?\nIn the event that you do not agree with some aspect of the results of a match, you have until 11:00 AM EST/EDT on the day following the match to notify TopCoder of your concerns. Please send an email to <service@topcoder.com> explaining in detail what it is that you feel is inaccurate. We will investigate each appeal and we will determine what, if anything, to do about it.\n\n### 17 Problem Set Analysis and Discussion\nFollowing each match, an overview and analysis of each problem will be posted on TopCoder's site. You can find an archive of these write-ups [here](http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=archive). On many occasions, a further discussion will take place on TopCoder's forums (Round Tables), which you can find [here](http://forums.topcoder.com/?module=ThreadList&forumID=7167). The TopCoder Round Tables are a great place to get questions answered about algorithms, specific problems, Arena usage, and all other aspects of TopCoder.\n\n### 18 Getting Disconnected from the Arena\nOn occasion, we will all get disconnected from the Internet for various reasons. If you get disconnected from TopCoder's servers while you are in the Arena, simply log back in and move to your assigned competition room. You will not be penalized for logging out - however, the time will always be counting down from when you first opened the problem (or problem(s)). Once you reopen the problem that you were working on, the latest compiled or saved code should appear in the Coding Window. Remember to save your code often!\n\n### 19 Cheating at TopCoder\nCheating is taken seriously at TopCoder. There are a number of ways in which you could cheat, and have your account deactivated by TopCoder.\n\nCollaborating in any way with anyone else (member or not) during a rated event is considered cheating. This includes discussing problem statements or solutions between the time that the coding phase begins and the time that the challenge phase ends.\n\nUsing multiple accounts to participate in a rated event is considered cheating.\n\nRegistering a new account for the purpose of resetting your rating is considered cheating.\n\nPurposefully performing poorly during a rated event with the intention of artificially lowering your rating is considered very poor sportsmanship - and may result in account deactivation.\n\nModifying the Arena applet in any way is against the rules and may result in account deactivation. Attempting to digitally extract competitor's code during the challenge phase is considered cheating.\n\nObviously, TopCoder cannot identify all malicious behavior (we try hard, though), so we do rely on each member's sportsmanship and integrity.\n\n### 20 Using Pre-Written Code\nTopCoder previously used to require that all your submissions have to be completely authored by you. Starting from TCO 2021 online finals this rule has now been relaxed as follows: You are responsible for being legally allowed to use all the code included in your submission, and for being able to demonstrate this. More precisely:\n\n* You may use any code you authored during the competition.\n* You may also use any code you personally authored before the competition, unless there are legal reasons that prohibit you from doing so.\n* You are also allowed to include (and modify) any other code authored by a third party, as long as it is verifiable that this third-party code has been written and published before the start of the competition under a license that allows you to include it in your submission (and modify it, if applicable).\n\nRegarding the last item, please note that public availability of code does not automatically give you the legal right to use it. It is always your responsibility to make sure that you are not violating the license or copyright of the third-party code, and in case your submission is investigated for violation of this rule, it is your responsibility to produce evidence that you used the third-party code in a legally allowed way.\n\nAlso note that by submitting any source code you agree to license to Topcoder the right to use and publish said code. If your submission includes any third-party code, it is also your responsibility to make sure that its license allows you to do this.\n\nWe encourage any TopCoder competitor to notify us in the event that they have evidence that a code submission during a rated event violates this policy.\n\n### 21 TopCoder Arena Plug-ins\nThe TopCoder Arena supports a \"plug-in\" architecture that allows additional functionality to be built in. While the functionality provided by these plug-ins is not initially available to you, you may freely install and configure any of the available plug-ins. Most plug-ins are designed to create a more efficient and effective competition environment. There are plug-ins available for feature-rich code editing, automatic example checking, external editor integration, auto code generation, and more. For a list of available plug-ins and instructions on how to [install](https://www.topcoder.com/thrive/articles/How%20to%20install%20The%20Arena%20plug-ins) and use them, check [here](https://www.topcoder.com/thrive/articles/Topcoder%20Arena%20Plugins).","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3XrMlEcHcIzg61arCn2do4","type":"Entry","createdAt":"2019-09-18T07:37:53.166Z","updatedAt":"2019-10-15T16:16:25.689Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Rashid Sial","tcHandle":"pizza_and_dog"}}],"upvotes":4,"downvotes":0,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"21NdRA2F0D1wXSpeaog0U8"}},{"sys":{"type":"Link","linkType":"Entry","id":"6G5x331zgQQyDCOBrPghYj","circular":true}}]}}]}},{"sys":{"type":"Link","linkType":"Entry","id":"qYP8EEHcdphNJ7DcOGTgf","circular":true}},{"sys":{"type":"Link","linkType":"Entry","id":"4WVuna1YTTk1LMWsRpwsMt"}}]}}]}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"r6KyTqSjVsgTCjazeXGO9","type":"Entry","createdAt":"2019-12-28T13:36:22.641Z","updatedAt":"2019-12-28T13:36:22.641Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"Neha Sharma","tcHandle":"sharma.neha","avatar":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"zu5gDtaZVfEijvYd3J00I","type":"Entry","createdAt":"2020-02-19T13:25:37.391Z","updatedAt":"2022-06-29T23:13:30.131Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":82,"revision":9,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Planning an Approach to a Topcoder Problem Part 2","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":[" Div I","Problem Writing","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"\\\n[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505845&amp;mc=4)\n\\\n__[…read Section 1](https://www.topcoder.com/thrive/articles/%20Planning%20an%20Approach%20to%20a%20Topcoder%20Problem%20Part%201)__\n<br><br>\n### Bottom Up Programming\nThis technique is the antithesis to breaking down a program, and should be the first thing you start doing when you get stuck. Bottom-up programming is the process of building up primitive functions into more functional code until the solution becomes as trivial as one of the primitives. Sometimes you know that you’ll need certain functions to form a solution and if these functions are atomic or easy to break down, you can start with these functions and build your solution upward instead of breaking it down.\n\\\nIn the case of MatArith, the procedure to add and multiply matrices was given in the problem statement making it easy to follow directions and get two functions to start with. From there you could make a smaller evalMult function that multiplied matrices together using a string evaluation and variable names, then a similar evalAdd that treats each term as a block and you have an approach to solve the problem.\n\\\nIn general, it’s a very good strategy to code up any detailed procedure in the problem statement before tackling the actual problem. Examples of these are randomizer functions, any data structures you’re asked to simulate, and any operations on mathematical objects like matrices and complex numbers. You’ll find that by solving these smaller issues and then rereading the problem statement that you will understand what needs to be done much better. And sometimes, if you’re really stuck, it doesn’t hurt to write a couple atomic pieces of code that you know that you’ll need in order to convince your mind to break down the problem towards those functions. As you can see, your path to the right approach need not be linear as long as it follows your train of thought. \n\\\nAlso, in case of a hidden bug, keep in mind that any code that you write using this approach tactic should be scanned for bugs before your top-down code, because you tend to write this code first and thus at a stage where you understand the problem less than when you finish the code. This is a good rule of thumb to follow when looking for errors in your code; they usually sit in the older sections of the code, even if older is only decided by minutes or even seconds.\n<br><br>\n### Brute Force\nAny time the solution requires looking for an optimal configuration or a maximal number or any other choice of one of a finite set of objects, the simplest way to solve the problem is to try all configurations. Any time the solution requires calculating a massive calculation requiring many steps, the best way to solve it is to do every calculation as asked for in the problem. Any time the problem asks you to count the number of ways something can be done, the best way to solve it is to try every way and make a tally. In other words, the first approach to consider in any possibly time-intensive problem is the most obvious one, even if it is horribly inefficient.\n\\\nThis approach tactic, called brute force, is so called because there is no discerning thought about the method of calculation of the return value. Any time you run into this kind of an optimization problem the first thing you should do is try to figure in your head the worst possible test cases and if 8 seconds is enough time to solve each one. If so, brute force can be a very speedy and usually less error prone approach. In order to utilize brute force, you have to know enough about the programming environment to calculate an estimate how much time any calculation will take. But an estimate is just a guess, and any guess could be wrong. This is where your wisdom is forced to kick in and make a judgment call. And this particular judgment call has bitten many a coder that didn’t think it could be done brute force and couldn’t debug a fancier approach, and likewise those that didn’t figure correctly the worst of the cases to be tested for time.\n\\\nIn general, if you can’t think of a way to solve the problem otherwise, plan to use brute force. If it ends up that you are wrong, and there is a test case that takes too long, keep the brute force solution around, and while recoding the more elegant solution, use the brute-force solution to verify that your elegant code is correct in the smaller cases, knowing that its more direct approach is a good verification of these cases (being much less error-prone code).\n<br><br>\n### A Place for Algorithms\nWell-known and efficient algorithms exist for many standard problems, much like basic approaches exist for many standard word problems in math, just like standard responses exist for most common opening moves in chess. While in general it’s a bad idea to lean heavily upon your knowledge of the standard algorithms (it leads down the path of pattern mining and leaves you vulnerable to more original problems), it’s a very good idea to know the ones that come up often, especially if you can apply them to either an atomic section of code or to allow them to break your problem down.\n\\\nThis is not the place to discuss algorithms (there are big books to read and other tutorials in this series to follow that will show you the important stuff), but rather to discuss how algorithms should be used in determining an approach. It is not sufficient to know how to use an algorithm in the default sense; always strive to know any algorithms you have memorized inside and out. For example, you may run into a problem like CityLink (SRM 170 Div I Med), which uses a careful mutation of a basic graph algorithm to solve in time, whereby just coding the regular algorithm would not suffice. True understanding of how the algorithm works allows the insight needed to be able to even conceive of the right mutation.\n\\\nSo, when you study algorithms, you need to understand how the code works, how long it will take to run, what parts of the code can be changed and what effect any changes will have on the algorithm. It’s also extremely important that you know how to code the algorithm by memory before you try to use it in an approach, because without the experience of implementing an algorithm, it becomes very hard to tell whether your bugs are being caused by a faulty implementation or faulty input into the implementation. It’s also good to practice different ways to use the algorithms creatively to solve different problems, to see what works and what doesn’t. Better for an experiment with code to fall flat on its face in practice than during a competition. This is why broad-based algorithmic techniques (like divide-and-conquer, dynamic programming, greedy algorithms) are better to study first before you study your more focused algorithms because the concepts are easier to manipulate and easier to implement once you understand the procedure involved.\n<br><br>\n### Manipulating the Domain\nThis situation will become more and more familiar: you find yourself trudging through the planning stages of a problem because of the sheer amount of work involved in simulating the domain of the problem. This may be due to the inappropriateness of the presented domain, and there are times when manipulating the domain of the problem to something more convenient will create an easier or more recognizable problem. The classic example of this is the game of Fifteen (used as a problem in SRM 172). In the game of Fifteen, you have numbers from 1 to 9 of which you may claim one per turn, and if exactly three of your numbers add to 15 before exactly three of your opponent’s numbers adds to 15, then you win. For this problem, you can manipulate the domain by placing the numbers in the configuration of a 3×3 magic square (where every row, column, and diagonal add up to the same sum, in this case 15). Instantly you realize that the game of Fifteen is just the game Tic-Tac-Toe in disguise, making the game easier to play and program a solution for, because the manipulation of the domain transformed the situation of a game where you have no prior knowledge into one where you have a lot more knowledge. Some mathematicians think of this as the ABA<sup>-1</sup> approach, because the algebra suggests the proper process: first you transform the domain, then you perform your action, then (the A<sup>-1</sup>) you reverse your transformation.  This approach is very common in solving complex problems like diagonalizing matrices and solving the Rubik’s Cube.\n\\\nMost commonly this approach tactic is used to simplify basic calculations. A good example of this type of approach is HexagonIntersections from SRM 206. In this problem it was needed to find the number of tiled hexagons that touched a given line. The problem became much easier if you \"slanted\" the grid by transforming the numbers involved so that the hexagons involved had sides parallel to the x and y axis and the problem still had the same answer, thereby simplifying calculations.\n\\\nExtreme care must be taken while debugging if you manipulate the domain. Remember that the correct procedure to domain manipulation is to first manipulate the domain, then solve the problem, and then correct the domain. When you test the code, remember that either the domain must be properly reversed by the transformation before the result is returned, or the reversal must not affect the answer. Also, when looking at values inside the domain manipulation, remember that these are transformed values and not the real ones. It’s good to leave comment lines around your transformed section of code just to remind yourself of this fact.\n<br><br>\n### Unwinding the Definitions\nThis approach tactic is an old mathematician’s trick, relating to the incessant stacking of definitions upon definitions, and can be used to unravel a rather gnarly problem statement to get at the inner intended approach to the problem. The best way to do this is with code. When you read the definition of something you have never encountered before, try to think how you would code it. If the code asks you to find the simplest *grozmojt* in a set of integers, first figure out how your code would verify that something was a *grozmojt* and then figure out how to search for it, regardless if you even need to verify that something was a *grozmojt* in the solution. This is very similar to the bottom-up programming above, but taken at the definition level instead of the procedural one.\n\\\nSimulation problems fall under similar tactics, and create one of those times when those predisposed to object oriented coding styles run up the scores. The best way to manage a simulation problem is to create a simulation object that can have actions performed on it from a main function. That way you don’t worry if you passed enough state into a given function or not; since all of the information in the simulation is coming along with you, the approach becomes very convenient and reaches atomic code very quickly. This is also the correct approach to take if an algorithm needs to be simulated to count the steps needed in the algorithm (like MergeSort) or the number of objects deallocated in the execution of another algorithm (like ImmutableTrees). In these situations, the elegance of the code is usually sacrificed in the name of correctness and thoroughness, also making the approach easier to plan ahead for.\n<br><br>\n### The Problem is Doable\nAn old geometry puzzle goes like this: you have a pair of concentric circles and the only length you are given is the length of a chord of the outer circle (call the chord length x) that is tangent to the inner circle, and you are asked for the area between the circles. You respond: \"Well, if the problem is doable then the inner circle’s radius is irrelevant to the calculation, so I’ll declare it to be 0. Because the area of the inner circle is 0, or degenerates to the center of the outer circle, the chord of the outer circle passes through the center and is thus the diameter, and thus the area of the outer circle is Pi(x/2)<sup>2</sup>.\" Note that a proper geometric proof of this fact is harder to do; the sheer fact that a solution exists actually makes the problem easier. Since the writer had to write a solution for the problem, you know it’s always solvable, and this fact can be used to your advantage in an SRM.\n\\\nThis approach tactic broadens into the concept that the writer is looking for a particular type of solution, and sometimes through edits of the original problem statement this approach is given away (especially if the original problem is considered too hard for the level it’s at). Look for lowered constraints like arrays of size 20 (which many a seasoned coder will tell you is almost a codeword that the writer is looking for a brute force solution), or integers limited to between 1 and 10000 (allowing safe multiplication in ints without overflow). By leaning on the constraints you are acting similarly to the situation above, by not allowing the complexities of the problem that were trimmed off by the constraints to complicate your approach.\n\\\nSometimes the level of the problem alone will give a hint to what solution is intended. For example, look at FanFailure (from SRM 195 Div I Easy). The problem used the language of subsets and maximal and minimal, so you start to think maybe attack with brute force, and then you see the constraints opened up to 50 for the array size. 2<sup>50</sup> distinct subsets rules out brute force (better to find this out in the approach than in the code, right?) and you could look to fancier algorithms… but then you realize that this is a Div I Easy and probably isn’t as hard as it looks so you think through the greedy algorithm and decide that it probably works. This choice wouldn’t have been so obvious had it not been a Div I Easy.\n\\\nKeep in mind that these invisible cues are not objective and can’t be used to reason why an approach will work or not; they are there only to suggest what the writer’s mind was thinking. Furthermore, if the writer is evil or particularly tricky, cues of this nature may be red herrings to throw these tactics astray. As long as you temper this approach tactic with solid analysis before you go on a wild goose chase, this \"circular reasoning\" can be used to great advantage. \n<br><br>\n### Case Reduction\nSometimes the simplest problems to state are the ones that provide the most difficulty. With these types of problems it’s not unusual that the solution requires that you break up the problem not into steps but into cases. By breaking a problem up into cases of different sets of inputs you can create subproblems that can be much easier to solve. Consider the problem TeamPhoto (SRM 167 Div I Medium). This problem is simple to state, but abhorrent to solve. If you break up the problem into a series of cases, you find that where the entire problem couldn’t alone be solved by a greedy algorithm, each of the different cases could be, and you could take the best case from those optimal configurations to solve the problem.\n\\\nThe most common use of case reduction involves removing the boundary cases so that they don’t mess up a naï¿½ve solution. A good example of this is BirthdayOdds (SRM 174 Div I Easy); many people hard coded if(daysInYear==1)return 2; to avoid the possible problems with the boundary case, even if their solution would have handled it correctly without that statement. By adding that level of security, it became easier to verify that the approach they chose was correct.\n<br><br>\n### Plans Within Plans\nAs illustrated above, an approach isn’t easily stated, and is usually glossed over if reduced to a one-word label. Furthermore, there are many times when there exist levels to a problem, each of which needs to be solved before the full solution comes to light. One clear example of this is the problem MagicianTour (SRM 191 Div I Hard). There are definitely two delineated steps to this problem: the first step requires a graph search to find all connected components and their 2-coloring, and the second step requires the DP knapsack algorithm. In cases like this, it’s very helpful to remember that sometimes more than one approach tactic needs to be applied to the situation to get at the solution. Another great example is TopographicalImage (SRM 209 Div I Hard) which asks for the lowest angle that places a calculated value based on shortest path under a certain limit. To solve, note that looking for this lowest value can be approached by binary search, but there are plans within plans, and the inner plan is to apply Floyd-Warshall’s All Pairs Shortest Paths algorithm to decide if the angle is satisfactory.\n\\\nRemember also that an approach isn’t just \"Oh, I know how to break this down… Let’s go!\" The idea of planning your approach is to strategically think about: the steps in your code, how an algorithm is to be applied, how the values are to be stored and passed, how the solution will react to the worst case, where the most probable nesting places are for bugs. The idea is that if the solution is carefully planned, there is a lower chance of losing it to a challenge or during system tests. For each approach there are steps that contain plans for their steps.\n<br><br>\n### Tactical Permutation\nThere is never a right approach for all coders, and there are usually at least two ways to do a problem. Let’s look at an unsavory Division One Easy called OhamaLow (SRM 206 Div I Easy). One of the more popular ways to approach this problem is to try all combinations of hands, see if the hand combination is legal, sort the hand combination, and compare it to the best hand so far. This is a common brute-force search strategy. But it’s not the entire approach. Remember that there are plans within plans. You have to choose an approach on how to form each hand (this could be done recursively or using multiple for-loops), how to store the hands (int arrays, Strings, or even a new class), and how to compare them. There are many different ways to do each of these steps, and most of the ways to proceed with the approach will work. As seen above as well as here, there are many times where more than one approach will do the job, and these approaches are considered permutable. In fact, one way to permute the top-level brute-force search strategy is to instead of considering all possible constructible hands and picking the best one, you can construct all possible final hands in best to worst order and stop when you have found one that’s constructible. In other words you take all 5 character substrings of \"87654321\" in order and see if the shared hand and player hand can make the chosen hand, and if so return that hand. This approach also requires substeps (how to decide if the hand can be formed, how to walk the possible hands, and so on) but sometimes (and in this case it is better) you can break it down faster.\n\\\nThe only way you get to choose between two approaches is if you are able to come up with both of them. A very good way to practice looking for multiple approaches to problems is to try to solve as many of the problems in the previous SRM using two different approaches. By doing this, you stretch your mind into looking for these different solutions, increasing your chances of finding the more elegant solution, or the faster one to type, or even the one that looks easier to debug.\n<br><br>\n### Backtracking from a Flawed Approach\nAs demonstrated in the previous section, it is very possible for there to exist more than one way to plan an approach to a problem. It may even hit you in the middle of coding your approach how to more elegantly solve the problem. One of the hardest disciplines to develop while competing in topcoder Single Round Matches is the facility to stick to the approach you’ve chosen until you can prove without a shadow of a doubt that you made a mistake in the approach and the solution will not work. Remember that you are not awarded points for code elegance, or for cleverness, or for optimized code. You are granted points solely on the ability to quickly post correct code. If you come up with a more elegant solution than the one you’re in the middle of typing up, you have to make the split second analysis of how much time you’ll lose for changing your current approach, and in most cases it isn’t worth it.\n\\\nThere is no easy answer to planning the right approach the first time. If you code up a solution and you know it is right but has bugs this is much easier to repair than the sudden realization that you just went the entirely wrong direction. If you get caught in this situation, whatever you do, don’t erase your code! Relabel your main function and any subfunctions or data structures that may be affected by further changes. The reason is because while you may desire a clean slate, you must accept that some of your previous routines may be the same, and retracing your steps by retyping the same code can be counterproductive to your thinking anew. Furthermore, by keeping the old code you can test against it later looking for cases that will successfully challenge other coders using the same flawed approach.\n<br><br>\n### Conclusion\nPlanning an approach is not a science, although there is a lot of rigor in the thought involved. Rather, it is mainly educated guesswork coupled with successful planning. By being creative, economical, and thorough about your thought process you can become more successful and confident in your solutions and the time you spend thinking the problem through will save you time later in the coding and debugging. This ability to plan your code before the fingers hit the keys only develops through lots of practice, but this diligence is rewarded with an increasing ability to solve problems and eventually a sustained rating increase.\n\\\n__Mentioned in this writeup:__\n\tTCI ’02 Round 2 Div I Med – [MatArith](http://community.topcoder.com/stat?c=problem_statement&amp;pm=511&amp;rd=4335)\n\tSRM 170 Div I Med – [CityLink](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1864&amp;rd=4655)\n\tSRM 172 Div I Med – [Fifteen](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1850&amp;rd=4665)\n\tSRM 206 Div I Hard – [HexagonIntersections](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2920&amp;rd=5852)\n\tSRM 195 Div I Easy – [FanFailure](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2235&amp;rd=5070)\n\tSRM 167 Div I Med – [TeamPhoto](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1614&amp;rd=4640\")\n\tSRM 174 Div I Easy – [BirthdayOdds](http://community.topcoder.com/stat?c=problem_statement&amp;pm=1848&amp;rd=4675)\n\tSRM 191 Div I Hard – [MagicianTour](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2346&amp;rd=4775)\n\tSRM 210 Div II Hard – [TopographicalImage](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2932&amp;rd=5856)\n\tSRM 206 Div I Easy – [OmahaLow](http://community.topcoder.com/stat?c=problem_statement&amp;pm=2435&amp;rd=5852)","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7grGsA4QB6NKhy18BmMCHX","type":"Entry","createdAt":"2020-02-19T13:03:26.091Z","updatedAt":"2020-02-19T13:03:26.091Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"leadhyena_inran","tcHandle":"leadhyena_inran"}}],"upvotes":3,"downvotes":0,"recommended":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4xGaY8n7TtVlO6VRAchgtX","type":"Entry","createdAt":"2020-02-19T13:20:21.395Z","updatedAt":"2024-08-07T16:36:23.022Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":106,"revision":15,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Planning an Approach to a Topcoder Problem Part 1","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":[" Div I","Problem Writing","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"\\\n[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505845&amp;mc=4)\n\\\nPlanning an approach is a finicky art; it can stump the most seasoned coders as much as it stumps the newer ones, and it can be extremely hard to put into words. It can involve many calculations and backtracks, as well as foresight, intuition, creativity, and even dumb luck, and when these factors don’t work in concert it can inject a feeling of helplessness in any coder. Sometimes it’s this feeling of helplessness that discourages coders from even attempting the Div I Hard. There are even coders that stop competing because they abhor that mental enfeeblement that comes with some problems. However, if one stays diligent, the solution is never really out of the mind’s reach. This tutorial will attempt to flesh out the concepts that will enable you to pick an approach to attack the problems with a solid plan.\n<br><br>\n### Pattern Mining and the Wrong Mindset\nIt is easy to fall into the trap of looking at the algorithm competition as a collection of diverse yet classifiable story problems. For those that have done a lot of story problems, you know that there are a limited number of forms of problems (especially in classes where the professor tends to be repetitious), and when you read a problem in a certain form, your mind says, \"Oh, this is an X problem, so I find the numbers that fit the problem and plug and chug.\" There are many times when this kind of pattern mining pays off; after a number of topcoder Single Round Matches, most coders will recognize a set of common themes and practice against them, and this method of problem attack can be successful for many matches.\n\\\nHowever, this approach is perilous. There are times when you skim the problem statement and assume it’s of type Q, then start coding and discover that your code passes none of the examples. That’s when you reread the problem and find out that this problem is unique to your experience. At that point, you are paralyzed by your practice; being unable to fit any of your problem types to the problem you are unable to proceed. You’ll see this often when there’s a really original problem that comes down the pipe, and a lot of seasoned coders fail the problem because they are blinded by their experience.\n\\\nPattern mining encourages this kind of mindset that all of the problem concepts have been exhausted, when in reality this is impossible. Only by unlearning what you have learned (to quote a certain wise old green midget) and by relearning the techniques of critical thought needed to plan an approach can your rating sustainably rise.\n<br><br>\n### Coding Kata\nHere’s your first exercise: take any problem in the Practice Rooms that you haven’t done. Fight through it, no matter how long it takes, and figure it out (use the editorial from the competition as a last resort). Get it to pass system tests, and then note how long you took to solve it. Next, clear your solution out, and try to type it in again (obviously cutting and pasting will ruin the effect). Again, get it to pass system tests. Note how long it took you to finish the second time. Then, clear it out and do the problem a third time, and again get it to pass system tests. Record this final time.\n\\\nThe time it takes for your first pass is how long it takes you when you have no expectations of the problem and no approach readily in mind. Your time on the second pass is usually the first time minus the amount of time it took you to understand the problem statement. (Don’t be surprised at the number of bugs you’ll repeat in the second pass.) That final recorded time is your potential, for you can solve it this fast in competition if you see the correct approach immediately after reading it. Let that number encourage you; it really is possible to solve some of these problems this quickly, even without super fast typing ability. But what you should also learn from the third pass is the feeling that you knew a working strategy, how the code would look, where you would tend to make the mistakes, and so on. That’s what it feels like to have the right approach, and that feeling is your goal for future problems in competition.\n\\\nIn most martial arts, there’s a practice called kata where the martial artist performs a scripted series of maneuvers in order, usually pretending to defend (or sometimes actually defending) against an onslaught of fighters, also scripted to come at the artist predictably. At first this type of practice didn’t make any sense, because it didn’t seem realistic to the chaotic nature of battle. Furthermore it seems to encourage the type of pattern mining mentioned in the previous section.  Only after triple-coding many problems for a while can one comprehend the true benefit of this coding kata.  The kata demonstrates to its practitioners the mental experience of having a plan, encouraging the type of discipline it takes to sit and think the problem through. This plan of attack is your approach, and it carries you through your coding, debugging, and submission.\n<br><br>\n### Approach Tactics\nNow that you know what an approach feels like and what its contents are, you’ll realize that you know a lot of different types of these approaches. Do you give them names? \"Oh, I used DP (dynamic programming) on that problem.\" \"Really, I could have done that one greedy?\" \"Don’t tell me that the brute-force solution would have passed in time.\" Really, the name you give an approach to a problem is a misnomer, because you can’t classify every problem as a type like just greedy or just brute-force. There are an infinite number of problem types, even more solution types, and even within each solution type there are an infinite number of different variations. This name is only a very high level summary of the actual steps it takes to get to the solution.\n\\\nIn some of the better match editorials there is a detailed description of one approach to solving the code. The next time you look at a match summary, and there is a good write-up of a problem, look for the actual steps and formation of the approach. You start to notice that there is a granularity in the steps, which suggests a method of cogitation. These grains of insight are approach tactics, or ways to formulate your approach, transform it, redirect it, and solidify it into code that get you closer to the solution or at least point you away from the wrong solution. When planning your approach, the idea is that you will use whatever approach tactics are at your disposal to decide on your approach, the idea being that you are almost prewriting the code in your head before you proceed. It’s almost as if you are convincing yourself that the code you are about to write will work.\n\\\nCoders with a math background may recognize this method of thinking, because many of these approach tactics are similar to proof writing techniques. Chess players may identify it with the use of tactics to look many moves ahead of the current one. Application designers may already be acquainted with this method when working with design patterns. In many other problem solving domains there is a similar parallel to this kind of taxonomy.\n\\\nTo practice this type of critical thinking and to decide your preferences among approach tactics, it is very useful to record the solutions to your problems, and to write up a post-SRM analysis of your own performance. Detail in words how each of your solutions work so that others could understand and reproduce the approach if they wanted to just from your explanations. Not only will writing up your approaches help you to understand your own thoughts while coding, but this kind of practice also allows you to critique your own pitfalls and work on them in a constructive manner. Remember, it is difficult to improve that which you don’t understand.\n<br><br>\n### Breaking Down a Problem\nLet’s talk about one of the most common approach tactics: breaking down a problem. This is sometimes called top-down programming: the idea is that your code must execute a series of steps in order, and from simple decisions decide if other steps are necessary, so start by planning out what your main function needs before you think about how you’ll do the subfunctions. This allows you to prototype the right functions on the fly (because you only code for what you need and no further), and also it takes your problem and fragments it into smaller, more doable parts.\n\\\nA good example of where this approach is useful is in MatArith from Round 2 of the 2002 topcoder Invitational. The problem requires you to evaluate an expression involving matrices. You know that in order to get to the numbers you’ll need to parse them (because they’re in String arrays) and pass those values into an evaluator, change it back into a String array and then you’re done. So you’ll need a print function, a parse function and a new calc function. Without thinking too hard, if you imaging having all three of these functions written already the problem could be solved in one line:\n\n```\npublic String[] calculate(String[] A, String[] B, String[] C, String eval){\n   return print(calc(parse(A),parse(B),parse(C),eval));\n}\n```\n\nThe beauty of this simplest approach tactic is the guidance of your thoughts into a functional hierarchy. You have now fragmented your work into three steps: making a parse function, a print function, and then a calc function, breaking a tough piece of code into smaller pieces. If you break down the code fine enough, you won’t have to think hard about the simplest steps, because they’ll become atomic (more on this below). In fact the rest of this particular problem will fall apart quickly by successive partitioning into functions that multiply and add the matrices, and one more that reads the eval statement correctly and applies the appropriate functions.\n\\\nThis tactic really works well against recursive problems. The entire idea behind recursive code is that you are breaking the problem into smaller pieces that look exactly like the original, and since you’re writing the original, you’re almost done. This approach tactic also plays into the hands of a method of thinking about programs called functional programming. There are several articles on the net and even a topcoder article written by radeye that talk more about this concept in depth, but the concept is that if properly fragmented, the code will pass all variable information between functions, and no data needs to be stored between steps, which prevents the possibility of side-effects (unintended changes to state variables between steps in code) that are harder to debug.\n<br><br>\n### Plan to Debug\nWhenever you use an approach you should always have a plan to debug the code that your approach will create. This is the dark underbelly of every approach tactic. There is always a way that a solution may fail, and by thinking ahead to the many ways it can break, you can prevent the bugs in the code before you type them. Furthermore, if you don’t pass examples, you know where to start looking for problems. Finally, by looking for the stress points in the code’s foundation, it becomes easier to prove to yourself that the approach is a good one.\n\\\nIn the case of a top-down approach, breaking a problem down allows you to isolate sections of the code where there may be problems, and it will allow you to group tests that break your code into sections based on the subfunction they seem to exploit the most. There is also an advantage to breaking your code into functions when you fix a bug, because that bug is fixed in every spot where the code is used. The alternative to this is when a coder copy/pastes sections of code into every place it is needed, making it harder to propagate a fix and makes the fix more error prone. Also, when you look for bugs in a top-down approach, you should look for bugs inside the functions before you look between the calls to each function. These parts make up a debugging strategy: where to look first, how to test what you think is wrong, how to validate pieces and move on. Only after sufficient practice will a debugging strategy become more intuitive to your method of attack.\n<br><br>\n### Atomic Code\nIf you arrive at a section of code that you cannot break down further this is atomic code. Hopefully you know how to code each of these sections, and these form the most common forms of atomic code. But, don’t be discouraged when you hit a kernel of the problem that you don’t know how to code; these hard-to-solve kernels are in fact what make the problem interesting, and sometimes being able to see these in advance can make the big difference between solving the problem early with the right approach and heading down the wrong path with the wrong approach, wasting a lot of time in the process.\n\\\nThe most common type of atomic code you’ll write is in the form of primitives. I’ve always been a proponent of knowing the library of your language of choice. This is where that knowledge is of utmost importance. What better way to save yourself time is there in both planning your approach and coding your solution when you know that a possibly difficult section of your code is in fact atomic and solved using a library function or class?\n\\\nThe second type of atomic code you’ll write are what I call language techniques. These are usually snippets of code committed to memory that perform a certain operation in the language, like locating the index of the first element in an array with the minimum value, or parsing a String into tokens separated by whitespace. These techniques are equally essential to planning an approach, because if you know how to do these fundamental operations intuitively, it makes more tasks in your search for a top-down approach atomic, thus making the search for the right approach shorter. In addition, it makes the segments of the code in these atomic segments less error prone. Furthermore, if you are asked to perform a task similar to one that you already know a language technique for, it makes it much easier to mutate the code to fit the situation (for example: searching for the index of the first maximal element in an array based on some heuristic is easy if you already know how to type up similar tasks). Looking for these common language techniques should become an element of your daily practice, and any atomic code should fly off your fingers as soon as you think about it.\n\\\nAs an aside, I must address the use of code libraries. I know that this is a contested topic, and many successful coders out there make use of a (sometimes encyclopedic) library as a pre-inserted segment of code before they start coding. This is totally legal (although changes to the rules after the [2004 topcoder Open](https://tco04.topcoder.com) may affect their future legality), and there are obvious advantages to using a library, mainly through the ability to declare more parts of your top-down approach atomic, and by being able to more quickly construct bottom-up fragments of code (as discussed below). It is my opinion, however, that the disadvantages of using library code outweigh the advantages. On a small note, library code executed through functions can sometimes slow your coding, because you have to make the input match the prototype of the code you’re trying to use. Library code is mostly non-mutatable, so if your library is asked to do something that isn’t expressly defined, you find yourself fumbling over a language technique or algorithm that should already be internalized. It is also possible that your library code isn’t bug-free, and debugging your library mid-competition is dangerous because you may have to propagate that change to code you’ve already submitted and also to the template before you open any more problems. Also, library use is not allowed in onsite competition. Finally, the use of library code (or macros for that manner) get you used to leaning on your library instead of your instincts of the language, making the use of normal primitives less intuitive and the understanding of other coder’s solutions during challenge phase not as thorough. If used in moderation your library can be powerful, but it is not the ultimate weapon for all terrain.\n\\\nThere may be a point where you hit a piece of atomic code that you are unable to fragment. This is when you have to pull out the thinking cap and start analyzing your current approach. Should I have broken up the tasks differently? Should I store my intermediate values differently? Or maybe this is the key to the problem that makes the problem hard? All of these things must be considered before you pound the keys. Even at these points where you realize that you’re stuck, there are ways to manipulate the problem at hand to come to an insight on how to proceed quickly, and these ways comprise the remaining approach tactics. \n\\\n__[…continue to Section 2](https://www.topcoder.com/community/data-science/data-science-tutorials/planning-an-approach-to-a-topcoder-problem-part-2/)__","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7grGsA4QB6NKhy18BmMCHX","type":"Entry","createdAt":"2020-02-19T13:03:26.091Z","updatedAt":"2020-02-19T13:03:26.091Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"leadhyena_inran","tcHandle":"leadhyena_inran"}}],"upvotes":6,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"zu5gDtaZVfEijvYd3J00I","circular":true}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"zu5gDtaZVfEijvYd3J00I","circular":true}}}}],"journeyPrevious":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4xGaY8n7TtVlO6VRAchgtX","type":"Entry","createdAt":"2020-02-19T13:20:21.395Z","updatedAt":"2024-08-07T16:36:23.022Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":106,"revision":15,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"article"}},"locale":"en-US"},"fields":{"title":"Planning an Approach to a Topcoder Problem Part 1","type":"Article","trackCategory":["Competitive Programming"],"contentCategory":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48KN1aOT7mIG4Nqjzglga9","type":"Entry","createdAt":"2020-02-24T22:43:25.259Z","updatedAt":"2020-02-24T22:43:25.259Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"contentCategory"}},"locale":"en-US"},"fields":{"name":"Tutorials","trackParent":"Competitive Programming"}}],"tags":[" Div I","Problem Writing","Competitive Programming Tutorials"],"creationDate":"2018-10-31","readTime":"15 min","content":"\\\n[Discuss this article in the forums](http://apps.topcoder.com/forums/?module=ThreadList&amp;forumID=505845&amp;mc=4)\n\\\nPlanning an approach is a finicky art; it can stump the most seasoned coders as much as it stumps the newer ones, and it can be extremely hard to put into words. It can involve many calculations and backtracks, as well as foresight, intuition, creativity, and even dumb luck, and when these factors don’t work in concert it can inject a feeling of helplessness in any coder. Sometimes it’s this feeling of helplessness that discourages coders from even attempting the Div I Hard. There are even coders that stop competing because they abhor that mental enfeeblement that comes with some problems. However, if one stays diligent, the solution is never really out of the mind’s reach. This tutorial will attempt to flesh out the concepts that will enable you to pick an approach to attack the problems with a solid plan.\n<br><br>\n### Pattern Mining and the Wrong Mindset\nIt is easy to fall into the trap of looking at the algorithm competition as a collection of diverse yet classifiable story problems. For those that have done a lot of story problems, you know that there are a limited number of forms of problems (especially in classes where the professor tends to be repetitious), and when you read a problem in a certain form, your mind says, \"Oh, this is an X problem, so I find the numbers that fit the problem and plug and chug.\" There are many times when this kind of pattern mining pays off; after a number of topcoder Single Round Matches, most coders will recognize a set of common themes and practice against them, and this method of problem attack can be successful for many matches.\n\\\nHowever, this approach is perilous. There are times when you skim the problem statement and assume it’s of type Q, then start coding and discover that your code passes none of the examples. That’s when you reread the problem and find out that this problem is unique to your experience. At that point, you are paralyzed by your practice; being unable to fit any of your problem types to the problem you are unable to proceed. You’ll see this often when there’s a really original problem that comes down the pipe, and a lot of seasoned coders fail the problem because they are blinded by their experience.\n\\\nPattern mining encourages this kind of mindset that all of the problem concepts have been exhausted, when in reality this is impossible. Only by unlearning what you have learned (to quote a certain wise old green midget) and by relearning the techniques of critical thought needed to plan an approach can your rating sustainably rise.\n<br><br>\n### Coding Kata\nHere’s your first exercise: take any problem in the Practice Rooms that you haven’t done. Fight through it, no matter how long it takes, and figure it out (use the editorial from the competition as a last resort). Get it to pass system tests, and then note how long you took to solve it. Next, clear your solution out, and try to type it in again (obviously cutting and pasting will ruin the effect). Again, get it to pass system tests. Note how long it took you to finish the second time. Then, clear it out and do the problem a third time, and again get it to pass system tests. Record this final time.\n\\\nThe time it takes for your first pass is how long it takes you when you have no expectations of the problem and no approach readily in mind. Your time on the second pass is usually the first time minus the amount of time it took you to understand the problem statement. (Don’t be surprised at the number of bugs you’ll repeat in the second pass.) That final recorded time is your potential, for you can solve it this fast in competition if you see the correct approach immediately after reading it. Let that number encourage you; it really is possible to solve some of these problems this quickly, even without super fast typing ability. But what you should also learn from the third pass is the feeling that you knew a working strategy, how the code would look, where you would tend to make the mistakes, and so on. That’s what it feels like to have the right approach, and that feeling is your goal for future problems in competition.\n\\\nIn most martial arts, there’s a practice called kata where the martial artist performs a scripted series of maneuvers in order, usually pretending to defend (or sometimes actually defending) against an onslaught of fighters, also scripted to come at the artist predictably. At first this type of practice didn’t make any sense, because it didn’t seem realistic to the chaotic nature of battle. Furthermore it seems to encourage the type of pattern mining mentioned in the previous section.  Only after triple-coding many problems for a while can one comprehend the true benefit of this coding kata.  The kata demonstrates to its practitioners the mental experience of having a plan, encouraging the type of discipline it takes to sit and think the problem through. This plan of attack is your approach, and it carries you through your coding, debugging, and submission.\n<br><br>\n### Approach Tactics\nNow that you know what an approach feels like and what its contents are, you’ll realize that you know a lot of different types of these approaches. Do you give them names? \"Oh, I used DP (dynamic programming) on that problem.\" \"Really, I could have done that one greedy?\" \"Don’t tell me that the brute-force solution would have passed in time.\" Really, the name you give an approach to a problem is a misnomer, because you can’t classify every problem as a type like just greedy or just brute-force. There are an infinite number of problem types, even more solution types, and even within each solution type there are an infinite number of different variations. This name is only a very high level summary of the actual steps it takes to get to the solution.\n\\\nIn some of the better match editorials there is a detailed description of one approach to solving the code. The next time you look at a match summary, and there is a good write-up of a problem, look for the actual steps and formation of the approach. You start to notice that there is a granularity in the steps, which suggests a method of cogitation. These grains of insight are approach tactics, or ways to formulate your approach, transform it, redirect it, and solidify it into code that get you closer to the solution or at least point you away from the wrong solution. When planning your approach, the idea is that you will use whatever approach tactics are at your disposal to decide on your approach, the idea being that you are almost prewriting the code in your head before you proceed. It’s almost as if you are convincing yourself that the code you are about to write will work.\n\\\nCoders with a math background may recognize this method of thinking, because many of these approach tactics are similar to proof writing techniques. Chess players may identify it with the use of tactics to look many moves ahead of the current one. Application designers may already be acquainted with this method when working with design patterns. In many other problem solving domains there is a similar parallel to this kind of taxonomy.\n\\\nTo practice this type of critical thinking and to decide your preferences among approach tactics, it is very useful to record the solutions to your problems, and to write up a post-SRM analysis of your own performance. Detail in words how each of your solutions work so that others could understand and reproduce the approach if they wanted to just from your explanations. Not only will writing up your approaches help you to understand your own thoughts while coding, but this kind of practice also allows you to critique your own pitfalls and work on them in a constructive manner. Remember, it is difficult to improve that which you don’t understand.\n<br><br>\n### Breaking Down a Problem\nLet’s talk about one of the most common approach tactics: breaking down a problem. This is sometimes called top-down programming: the idea is that your code must execute a series of steps in order, and from simple decisions decide if other steps are necessary, so start by planning out what your main function needs before you think about how you’ll do the subfunctions. This allows you to prototype the right functions on the fly (because you only code for what you need and no further), and also it takes your problem and fragments it into smaller, more doable parts.\n\\\nA good example of where this approach is useful is in MatArith from Round 2 of the 2002 topcoder Invitational. The problem requires you to evaluate an expression involving matrices. You know that in order to get to the numbers you’ll need to parse them (because they’re in String arrays) and pass those values into an evaluator, change it back into a String array and then you’re done. So you’ll need a print function, a parse function and a new calc function. Without thinking too hard, if you imaging having all three of these functions written already the problem could be solved in one line:\n\n```\npublic String[] calculate(String[] A, String[] B, String[] C, String eval){\n   return print(calc(parse(A),parse(B),parse(C),eval));\n}\n```\n\nThe beauty of this simplest approach tactic is the guidance of your thoughts into a functional hierarchy. You have now fragmented your work into three steps: making a parse function, a print function, and then a calc function, breaking a tough piece of code into smaller pieces. If you break down the code fine enough, you won’t have to think hard about the simplest steps, because they’ll become atomic (more on this below). In fact the rest of this particular problem will fall apart quickly by successive partitioning into functions that multiply and add the matrices, and one more that reads the eval statement correctly and applies the appropriate functions.\n\\\nThis tactic really works well against recursive problems. The entire idea behind recursive code is that you are breaking the problem into smaller pieces that look exactly like the original, and since you’re writing the original, you’re almost done. This approach tactic also plays into the hands of a method of thinking about programs called functional programming. There are several articles on the net and even a topcoder article written by radeye that talk more about this concept in depth, but the concept is that if properly fragmented, the code will pass all variable information between functions, and no data needs to be stored between steps, which prevents the possibility of side-effects (unintended changes to state variables between steps in code) that are harder to debug.\n<br><br>\n### Plan to Debug\nWhenever you use an approach you should always have a plan to debug the code that your approach will create. This is the dark underbelly of every approach tactic. There is always a way that a solution may fail, and by thinking ahead to the many ways it can break, you can prevent the bugs in the code before you type them. Furthermore, if you don’t pass examples, you know where to start looking for problems. Finally, by looking for the stress points in the code’s foundation, it becomes easier to prove to yourself that the approach is a good one.\n\\\nIn the case of a top-down approach, breaking a problem down allows you to isolate sections of the code where there may be problems, and it will allow you to group tests that break your code into sections based on the subfunction they seem to exploit the most. There is also an advantage to breaking your code into functions when you fix a bug, because that bug is fixed in every spot where the code is used. The alternative to this is when a coder copy/pastes sections of code into every place it is needed, making it harder to propagate a fix and makes the fix more error prone. Also, when you look for bugs in a top-down approach, you should look for bugs inside the functions before you look between the calls to each function. These parts make up a debugging strategy: where to look first, how to test what you think is wrong, how to validate pieces and move on. Only after sufficient practice will a debugging strategy become more intuitive to your method of attack.\n<br><br>\n### Atomic Code\nIf you arrive at a section of code that you cannot break down further this is atomic code. Hopefully you know how to code each of these sections, and these form the most common forms of atomic code. But, don’t be discouraged when you hit a kernel of the problem that you don’t know how to code; these hard-to-solve kernels are in fact what make the problem interesting, and sometimes being able to see these in advance can make the big difference between solving the problem early with the right approach and heading down the wrong path with the wrong approach, wasting a lot of time in the process.\n\\\nThe most common type of atomic code you’ll write is in the form of primitives. I’ve always been a proponent of knowing the library of your language of choice. This is where that knowledge is of utmost importance. What better way to save yourself time is there in both planning your approach and coding your solution when you know that a possibly difficult section of your code is in fact atomic and solved using a library function or class?\n\\\nThe second type of atomic code you’ll write are what I call language techniques. These are usually snippets of code committed to memory that perform a certain operation in the language, like locating the index of the first element in an array with the minimum value, or parsing a String into tokens separated by whitespace. These techniques are equally essential to planning an approach, because if you know how to do these fundamental operations intuitively, it makes more tasks in your search for a top-down approach atomic, thus making the search for the right approach shorter. In addition, it makes the segments of the code in these atomic segments less error prone. Furthermore, if you are asked to perform a task similar to one that you already know a language technique for, it makes it much easier to mutate the code to fit the situation (for example: searching for the index of the first maximal element in an array based on some heuristic is easy if you already know how to type up similar tasks). Looking for these common language techniques should become an element of your daily practice, and any atomic code should fly off your fingers as soon as you think about it.\n\\\nAs an aside, I must address the use of code libraries. I know that this is a contested topic, and many successful coders out there make use of a (sometimes encyclopedic) library as a pre-inserted segment of code before they start coding. This is totally legal (although changes to the rules after the [2004 topcoder Open](https://tco04.topcoder.com) may affect their future legality), and there are obvious advantages to using a library, mainly through the ability to declare more parts of your top-down approach atomic, and by being able to more quickly construct bottom-up fragments of code (as discussed below). It is my opinion, however, that the disadvantages of using library code outweigh the advantages. On a small note, library code executed through functions can sometimes slow your coding, because you have to make the input match the prototype of the code you’re trying to use. Library code is mostly non-mutatable, so if your library is asked to do something that isn’t expressly defined, you find yourself fumbling over a language technique or algorithm that should already be internalized. It is also possible that your library code isn’t bug-free, and debugging your library mid-competition is dangerous because you may have to propagate that change to code you’ve already submitted and also to the template before you open any more problems. Also, library use is not allowed in onsite competition. Finally, the use of library code (or macros for that manner) get you used to leaning on your library instead of your instincts of the language, making the use of normal primitives less intuitive and the understanding of other coder’s solutions during challenge phase not as thorough. If used in moderation your library can be powerful, but it is not the ultimate weapon for all terrain.\n\\\nThere may be a point where you hit a piece of atomic code that you are unable to fragment. This is when you have to pull out the thinking cap and start analyzing your current approach. Should I have broken up the tasks differently? Should I store my intermediate values differently? Or maybe this is the key to the problem that makes the problem hard? All of these things must be considered before you pound the keys. Even at these points where you realize that you’re stuck, there are ways to manipulate the problem at hand to come to an insight on how to proceed quickly, and these ways comprise the remaining approach tactics. \n\\\n__[…continue to Section 2](https://www.topcoder.com/community/data-science/data-science-tutorials/planning-an-approach-to-a-topcoder-problem-part-2/)__","featuredImage":{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},"contentAuthor":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7grGsA4QB6NKhy18BmMCHX","type":"Entry","createdAt":"2020-02-19T13:03:26.091Z","updatedAt":"2020-02-19T13:03:26.091Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"person"}},"locale":"en-US"},"fields":{"name":"leadhyena_inran","tcHandle":"leadhyena_inran"}}],"upvotes":6,"downvotes":1,"recommended":[{"sys":{"type":"Link","linkType":"Entry","id":"zu5gDtaZVfEijvYd3J00I","circular":true}}],"journeyNext":{"sys":{"type":"Link","linkType":"Entry","id":"zu5gDtaZVfEijvYd3J00I","circular":true}}}}}}],"Asset":[{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"13xehp2Kyjd978mQjPk2mK","type":"Asset","createdAt":"2022-09-13T16:53:42.698Z","updatedAt":"2022-09-14T06:52:14.883Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Want to become a ReactJs Developer? Here-s what you need to know","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/13xehp2Kyjd978mQjPk2mK/fadf465eb8afc41030cf76f5c08c1c00/Want_to_become_a_ReactJs_Developer.png","details":{"size":57946,"image":{"width":599,"height":355}},"fileName":"Want_to_become_a_ReactJs_Developer.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1Bg3agf5Sp99NMpQyD2nig","type":"Asset","createdAt":"2020-01-23T07:45:47.503Z","updatedAt":"2023-09-10T10:36:23.350Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"adult-books-business-coffee-374016","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1Bg3agf5Sp99NMpQyD2nig/63bc7f1a839182d35ce1e74c24a6e04d/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1TlqUx1nGJjrenmM3uJzmi","type":"Asset","createdAt":"2022-10-21T14:49:03.618Z","updatedAt":"2023-09-15T21:00:19.700Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"How to be an Effective Freelancer, Freelancing with Topcoder and More","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1TlqUx1nGJjrenmM3uJzmi/dab38d05faeb5c03db7f377a309ce6ba/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1WA4wbSfAiGt7pf2mprZ4U","type":"Asset","createdAt":"2021-10-07T09:47:05.963Z","updatedAt":"2021-10-07T09:47:05.963Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"tarjan","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1WA4wbSfAiGt7pf2mprZ4U/ad45125680ba3a7033501dd8ca75fd5e/tarjan.jpeg","details":{"size":34129,"image":{"width":990,"height":355}},"fileName":"tarjan.jpeg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1X3e1DpKoRfKDk0EMSnicL","type":"Asset","createdAt":"2020-05-03T12:48:07.179Z","updatedAt":"2020-05-03T12:48:07.179Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Errichto","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1X3e1DpKoRfKDk0EMSnicL/234c8f177e0a9ffc60fe4aaf076e4691/Errichto.jpeg","details":{"size":3969,"image":{"width":126,"height":140}},"fileName":"Errichto.jpeg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1ZaMXHSILRR4CTOabSGHTC","type":"Asset","createdAt":"2021-11-20T15:00:35.154Z","updatedAt":"2021-11-20T15:00:35.154Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Banner (5)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1ZaMXHSILRR4CTOabSGHTC/4c307af9eca5c2bbcb60a61b675f21c6/Banner__5_.png","details":{"size":13435,"image":{"width":1050,"height":600}},"fileName":"Banner (5).png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1bxxqiFLlqQFQecucXOhlA","type":"Asset","createdAt":"2021-10-29T08:31:18.687Z","updatedAt":"2021-10-29T08:54:46.106Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"kosaraju","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1bxxqiFLlqQFQecucXOhlA/f704fa808ac674f01803d0748be0d898/kosaraju.jpeg","details":{"size":37251,"image":{"width":926,"height":355}},"fileName":"kosaraju.jpeg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1ftSQbsFvZ7hslLfqCrVSk","type":"Asset","createdAt":"2022-07-28T04:57:17.425Z","updatedAt":"2022-07-28T06:24:37.608Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"Comparison Networks - ss3","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1ftSQbsFvZ7hslLfqCrVSk/c5e889dddd40852a26d5d87c7e311e99/comparison-networks.png","details":{"size":22011,"image":{"width":445,"height":355}},"fileName":"comparison-networks.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1i786NVOB6KrgH8WIjNA5o","type":"Asset","createdAt":"2022-08-08T17:15:51.156Z","updatedAt":"2022-08-08T17:15:51.156Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"What Skills do you Need to be a Graphic Designer?","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1i786NVOB6KrgH8WIjNA5o/f4c8f049da0a86b350b2d0871784b97b/What_Skills_do_you_Need_to_be_a_Graphic_Designer","details":{"size":79753,"image":{"width":640,"height":640}},"fileName":"What Skills do you Need to be a Graphic Designer?.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"1tb4jBUcwMt8P7VnUiu0J1","type":"Asset","createdAt":"2023-09-06T19:21:40.802Z","updatedAt":"2023-09-06T19:21:40.802Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"google-deepmind-mbq0qL3ynMs-unsplash","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/1tb4jBUcwMt8P7VnUiu0J1/6832a5541d83ccbc176df7b954041cc5/google-deepmind-mbq0qL3ynMs-unsplash.jpg","details":{"size":2263000,"image":{"width":4000,"height":4000}},"fileName":"google-deepmind-mbq0qL3ynMs-unsplash.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"239h0OBv0NnoVKO2FqTyQt","type":"Asset","createdAt":"2023-07-10T18:40:42.469Z","updatedAt":"2023-07-10T18:40:42.469Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"turned on black and grey laptop computer","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/239h0OBv0NnoVKO2FqTyQt/6783896940660baa8e235ecf68fd6d5f/photo-1504868584819-f8e8b4b6d7e3.avif","details":{"size":55904,"image":{"width":1476,"height":978}},"fileName":"photo-1504868584819-f8e8b4b6d7e3.avif","contentType":"image/avif"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"25IGVOZ5BEPsskug7znVSS","type":"Asset","createdAt":"2019-12-18T08:25:08.779Z","updatedAt":"2023-09-08T07:03:19.095Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"locale":"en-US"},"fields":{"title":"man-with-headphones-facing-computer-monitor-845451","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/25IGVOZ5BEPsskug7znVSS/0193b9d63fb7eabac8f1f891e10172b0/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"27rs0Lz9k49ITcQO1hnXsx","type":"Asset","createdAt":"2022-03-15T09:18:22.355Z","updatedAt":"2022-03-15T09:18:22.355Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"interpolation (2)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/27rs0Lz9k49ITcQO1hnXsx/2b6f8fd61c2399d2c0a9c65249afe559/interpolation__2_.jpeg","details":{"size":20289,"image":{"width":455,"height":431}},"fileName":"interpolation (2).jpeg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2E7acuXQQKFsBewSg1AxMG","type":"Asset","createdAt":"2020-03-31T13:36:18.289Z","updatedAt":"2020-03-31T13:36:18.289Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"misof big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2E7acuXQQKFsBewSg1AxMG/f8507d688787d65784dc2410d808d3f8/misof_big.jpg","details":{"size":3899,"image":{"width":126,"height":140}},"fileName":"misof_big.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2ZZoOM5Y5M4PxOkDSspB9Q","type":"Asset","createdAt":"2021-01-26T06:41:44.609Z","updatedAt":"2021-01-26T06:41:57.563Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"binary-2957504 960 720","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2ZZoOM5Y5M4PxOkDSspB9Q/7a9a7a8014161e59af955a14bbd8c619/binary-2957504_960_720.jpg","details":{"size":150332,"image":{"width":760,"height":760}},"fileName":"binary-2957504_960_720.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"2bAdOFpJGT2SDWvp6UeM1R","type":"Asset","createdAt":"2021-12-15T09:24:52.920Z","updatedAt":"2021-12-15T09:24:52.920Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"image","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/2bAdOFpJGT2SDWvp6UeM1R/6a4d5633c262fe074d23dfd0faebb7c6/image.png","details":{"size":222871,"image":{"width":861,"height":632}},"fileName":"image.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"35zK7ZbTYMEaHAQD2viKKT","type":"Asset","createdAt":"2020-04-01T06:29:58.074Z","updatedAt":"2020-04-01T06:29:58.074Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"monsoon big","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/35zK7ZbTYMEaHAQD2viKKT/94c375c5ef56a6206470204f364cb3ef/monsoon_big.jpg","details":{"size":4594,"image":{"width":126,"height":140}},"fileName":"monsoon_big.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3NYB2aT7Gq3kJRqScz4IPw","type":"Asset","createdAt":"2022-07-08T03:28:13.117Z","updatedAt":"2023-09-14T11:30:09.820Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Python Data Structures - Strings","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3NYB2aT7Gq3kJRqScz4IPw/7478abbc77e49c6af713855f234d3e34/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3TdAZLeLjjtJvf5Sux7sAx","type":"Asset","createdAt":"2020-01-23T08:33:47.104Z","updatedAt":"2020-01-23T08:33:47.104Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"photo-of-people-leaning-on-wooden-table-3183183","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3TdAZLeLjjtJvf5Sux7sAx/15435a836e6edea36635eee03e242034/photo-of-people-leaning-on-wooden-table-3183183.jpg","details":{"size":251590,"image":{"width":1280,"height":854}},"fileName":"photo-of-people-leaning-on-wooden-table-3183183.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"3tRoCZFELdC9YQLAKGGOw9","type":"Asset","createdAt":"2022-10-06T16:06:00.245Z","updatedAt":"2022-10-06T16:06:00.245Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"UX Design","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/3tRoCZFELdC9YQLAKGGOw9/4593051748860e4f33e31932cdfd24bc/UX_Design.jpg","details":{"size":71739,"image":{"width":640,"height":480}},"fileName":"UX Design.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"48SmHD7c0d2X94RWb1Ug6j","type":"Asset","createdAt":"2019-11-25T21:44:05.698Z","updatedAt":"2019-11-25T21:46:46.988Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":12,"revision":3,"locale":"en-US"},"fields":{"title":"Nick Profile Mic","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/48SmHD7c0d2X94RWb1Ug6j/9e61ada513c7c4bdcd29662697faebbb/portrait_square.jpg","details":{"size":85529,"image":{"width":769,"height":769}},"fileName":"portrait_square.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4LcbM4JxqhqWyc80igmItw","type":"Asset","createdAt":"2019-12-28T13:36:05.983Z","updatedAt":"2019-12-28T13:36:05.983Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"Neha Sharma","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4LcbM4JxqhqWyc80igmItw/8e3d59348a045858a14be27dc21dceaf/sharma.neha-1570659993186.png","details":{"size":57291,"image":{"width":140,"height":140}},"fileName":"sharma.neha-1570659993186.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4MvV4MKBVxBwYrrrE2PNlw","type":"Asset","createdAt":"2023-07-10T11:03:28.308Z","updatedAt":"2023-07-10T11:03:28.308Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"ux-versus-ia","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4MvV4MKBVxBwYrrrE2PNlw/f74026d7fd00b73102cdabee82b8bab3/ux-process.png","details":{"size":293363,"image":{"width":445,"height":355}},"fileName":"ux-process.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4TjMoEs4HOxvv6rcSzA1uP","type":"Asset","createdAt":"2023-09-06T18:54:06.319Z","updatedAt":"2023-09-06T18:54:06.319Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"photo-1576153192621-7a3be10b356e","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4TjMoEs4HOxvv6rcSzA1uP/09c8ce04f0afddf1e40c770056229f66/photo-1576153192621-7a3be10b356e.avif","details":{"size":27900,"image":{"width":500,"height":375}},"fileName":"photo-1576153192621-7a3be10b356e.avif","contentType":"image/avif"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4Y1AOG1YXQlhTmMHfBYvPz","type":"Asset","createdAt":"2021-09-21T10:12:41.521Z","updatedAt":"2021-09-21T10:12:41.521Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":1,"locale":"en-US"},"fields":{"title":"localization example app","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4Y1AOG1YXQlhTmMHfBYvPz/837841b4bfc581f036b8db3c2084ffe8/Banner.png","details":{"size":22355,"image":{"width":455,"height":355}},"fileName":"Banner.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4YytE3oNPvlye512WD73FD","type":"Asset","createdAt":"2019-09-03T05:38:20.793Z","updatedAt":"2019-09-03T05:38:20.793Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"hmehta-1460012668303","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4YytE3oNPvlye512WD73FD/7ec8bc9abcb19e57421595ff6f21c8ab/hmehta-1460012668303.jpeg","details":{"size":187321,"image":{"width":1185,"height":1185}},"fileName":"hmehta-1460012668303.jpeg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"4db3h4oxgTjuVYLtatj6n0","type":"Asset","createdAt":"2020-12-18T08:31:55.729Z","updatedAt":"2020-12-18T08:31:55.729Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":5,"revision":1,"locale":"en-US"},"fields":{"title":"Screenshot 2020-12-18 10:31:19","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/4db3h4oxgTjuVYLtatj6n0/25558fe2444e661882c4e1b1dd32b4bf/Screenshot_2020-12-18_10_31_19.png","details":{"size":325728,"image":{"width":998,"height":555}},"fileName":"Screenshot 2020-12-18 10:31:19.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5OnWggND3ytsXYNaJSC2WH","type":"Asset","createdAt":"2021-11-15T14:38:22.172Z","updatedAt":"2021-11-15T14:46:12.965Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"ternary","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5OnWggND3ytsXYNaJSC2WH/7f23bc81873fd8fb13833189e830b0e2/ternary.jpeg","details":{"size":25803,"image":{"width":709,"height":355}},"fileName":"ternary.jpeg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5SgnMyymPz8xOByiJ2tWkg","type":"Asset","createdAt":"2021-12-11T13:37:20.463Z","updatedAt":"2021-12-11T13:37:20.463Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"flatten","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5SgnMyymPz8xOByiJ2tWkg/0785c506c25aa2a283eef647e0d23d53/flatten.jpeg","details":{"size":88846,"image":{"width":558,"height":447}},"fileName":"flatten.jpeg","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"5iRr09ikoioZLtsyZV5tfA","type":"Asset","createdAt":"2020-01-06T06:26:43.766Z","updatedAt":"2023-09-29T17:34:47.881Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":8,"revision":2,"locale":"en-US"},"fields":{"title":"image7","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/5iRr09ikoioZLtsyZV5tfA/5a17dd83fb3e7c42c6f9ca3226b461f2/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"610OyAhwls4IzHgLN9HRs","type":"Asset","createdAt":"2019-09-23T23:25:29.153Z","updatedAt":"2019-09-23T23:25:29.153Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"Feedback helped ndondo","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/610OyAhwls4IzHgLN9HRs/7f689c24af0266ddfc92aeb7941bace2/Feedback_helped_ndondo.jpg","details":{"size":233315,"image":{"width":1080,"height":720}},"fileName":"Feedback helped ndondo.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"65O3MMsGuTqX4eiLdgJ6H","type":"Asset","createdAt":"2021-12-15T09:42:36.366Z","updatedAt":"2023-09-24T18:57:08.206Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"b-tree article banner","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/65O3MMsGuTqX4eiLdgJ6H/c10ef628e0390748e0efd711eb161452/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6JuGH4xpBrXFLGMaYTMdyU","type":"Asset","createdAt":"2021-11-10T16:32:25.875Z","updatedAt":"2021-11-10T16:32:25.875Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"Banner (4)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6JuGH4xpBrXFLGMaYTMdyU/c7a0674ac968c4d1c95ed125a4129722/Banner__4_.png","details":{"size":38234,"image":{"width":1050,"height":600}},"fileName":"Banner (4).png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6QLzQzBkpSu4Gc8lhd8GgL","type":"Asset","createdAt":"2022-07-08T14:13:18.057Z","updatedAt":"2022-07-08T14:13:18.057Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":4,"revision":1,"locale":"en-US"},"fields":{"title":"Data Structures and Algorithms in Python","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6QLzQzBkpSu4Gc8lhd8GgL/5ebfde8ae7ab831cbcbc03d3a1085cff/campaign-creators-pypeCEaJeZY-unsplash.jpg","details":{"size":509040,"image":{"width":3008,"height":2177}},"fileName":"campaign-creators-pypeCEaJeZY-unsplash.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6bvUg0VyRhu4vaVuwEsnf9","type":"Asset","createdAt":"2022-10-14T15:38:29.516Z","updatedAt":"2022-10-14T15:38:29.516Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"Create a Basic Browser GraphiQL Tool using React.js","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6bvUg0VyRhu4vaVuwEsnf9/f93570c88415793d8e403023acf9a627/Create_a_Basic_Browser_GraphiQL_Tool_using_React.js.jpg","details":{"size":61935,"image":{"width":640,"height":425}},"fileName":"Create a Basic Browser GraphiQL Tool using React.js.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6dPCtHf6FFNDZ5cE5gVINx","type":"Asset","createdAt":"2020-10-22T11:21:47.159Z","updatedAt":"2020-10-22T11:21:47.159Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":3,"revision":1,"locale":"en-US"},"fields":{"title":"default avatar","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6dPCtHf6FFNDZ5cE5gVINx/57c84b93efe5032e94cff71132636e66/default_avatar.svg","details":{"size":2232,"image":{"width":167,"height":168}},"fileName":"default avatar.svg","contentType":"image/svg+xml"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6nCaCYxOpz6ody4U5cGIbd","type":"Asset","createdAt":"2019-09-18T22:05:07.141Z","updatedAt":"2021-09-13T03:51:41.089Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":90,"revision":14,"locale":"en-US"},"fields":{"title":"Topcoder Generic Banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6nCaCYxOpz6ody4U5cGIbd/1b0d2bb3e83f8a58f2ffc9bcab941480/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"6uqY80Xv4nhpVfZtPZwAot","type":"Asset","createdAt":"2021-10-14T14:03:58.177Z","updatedAt":"2021-10-14T14:04:17.815Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"couting","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/6uqY80Xv4nhpVfZtPZwAot/c725bc250b7928a8ba058c3bf6a71223/couting.png","details":{"size":29399,"image":{"width":626,"height":355}},"fileName":"couting.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7fSG7idnmJAPzpmeZ44SrX","type":"Asset","createdAt":"2022-02-17T19:02:55.677Z","updatedAt":"2023-09-21T14:44:33.218Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":2,"locale":"en-US"},"fields":{"title":"GraphQL article banner image","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7fSG7idnmJAPzpmeZ44SrX/f9cbaaa4f13d2e583c9a314218943c16/Banner_Thrive__1_.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive (1).png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7koRSof4dMlEfXfkdGMKdH","type":"Asset","createdAt":"2022-01-07T18:18:28.869Z","updatedAt":"2023-09-24T18:35:10.267Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":9,"revision":2,"locale":"en-US"},"fields":{"title":"1200px-Pets flow.svg","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7koRSof4dMlEfXfkdGMKdH/b60c11fac7cb4e507a0af6e26b4fb7ff/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7nzds1n2pv6LnYvwPgOO5V","type":"Asset","createdAt":"2021-11-05T10:38:00.136Z","updatedAt":"2023-09-06T14:45:27.235Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":2,"locale":"en-US"},"fields":{"title":"Merlion","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7nzds1n2pv6LnYvwPgOO5V/b365b1e6360ba6b21ac0aefe3a76ff14/Banner_Thrive.png","details":{"size":160048,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7pkcVHw39lnZ9pALSfDb8I","type":"Asset","createdAt":"2022-08-10T15:50:09.547Z","updatedAt":"2022-08-10T15:50:09.547Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"Intersection of Two LinkedList","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7pkcVHw39lnZ9pALSfDb8I/faca94fc767f799e74e7f1b2d038b655/Intersection_of_Two_LinkedList.jpg","details":{"size":185741,"image":{"width":1050,"height":600}},"fileName":"Intersection of Two LinkedList.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7v2hlDsVep7FWufHw0lXpQ","type":"Asset","createdAt":"2021-08-03T09:25:08.111Z","updatedAt":"2021-08-03T09:25:08.111Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":7,"revision":1,"locale":"en-US"},"fields":{"title":"default article banner","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7v2hlDsVep7FWufHw0lXpQ/2505e61a880e68fab4e80cd0e8ec1814/0C37CB5E-B253-4804-8935-78E64E67589E.png","details":{"size":88903,"image":{"width":445,"height":356}},"fileName":"0C37CB5E-B253-4804-8935-78E64E67589E.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"7yO45g1yJfxerGOktJVufM","type":"Asset","createdAt":"2022-10-18T14:37:19.496Z","updatedAt":"2023-09-15T21:03:26.749Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"Being a Successful Topcoder Freelancer","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/7yO45g1yJfxerGOktJVufM/a283509c9e75aeb72730662fb1bc989a/Banner_Thrive.png","details":{"size":160141,"image":{"width":455,"height":355}},"fileName":"Banner_Thrive.png","contentType":"image/png"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"PGvqAWgEvqP6KRy8s8xhg","type":"Asset","createdAt":"2022-09-20T00:07:20.001Z","updatedAt":"2022-09-20T00:07:20.001Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"React Developer Hacking Tips","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/PGvqAWgEvqP6KRy8s8xhg/fd6b3be44f998718b98498dfb07eafe6/React_Developer_Hacking_Tips.jpg","details":{"size":38891,"image":{"width":640,"height":427}},"fileName":"React Developer Hacking Tips.jpg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"a3l0Zo35J49OubdaXhw4v","type":"Asset","createdAt":"2022-03-08T09:45:18.283Z","updatedAt":"2022-03-08T09:45:35.718Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":6,"revision":2,"locale":"en-US"},"fields":{"title":"interpolation (1)","description":"","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/a3l0Zo35J49OubdaXhw4v/7ba5af4d80e65266c2603ac5aaf8e4bf/interpolation__1_.jpeg","details":{"size":20289,"image":{"width":455,"height":431}},"fileName":"interpolation (1).jpeg","contentType":"image/jpeg"}}},{"metadata":{"tags":[],"concepts":[]},"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"piwi0eufbb2g"}},"id":"nSbNxiqpcPSDVkj8MafjW","type":"Asset","createdAt":"2019-12-13T17:00:19.927Z","updatedAt":"2019-12-13T17:00:19.927Z","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"publishedVersion":2,"revision":1,"locale":"en-US"},"fields":{"title":"TCO 2019 Marathon Match Final","file":{"url":"//images.ctfassets.net/piwi0eufbb2g/nSbNxiqpcPSDVkj8MafjW/b60420529907af58085eb526f4951de9/TCO_2019_Marathon_Match_Final","details":{"size":113899,"image":{"width":1024,"height":683}},"fileName":"TCO 2019 Marathon Match Final","contentType":"image/jpeg"}}}]}}