Intro to CP
Jeffrey, Autumn, Steven, and Joshua
Sep 28, 2021
Admin stuff
Sign-Up Form
Discord
Today’s Agenda
Beginner
Advanced
What is CP?
Technical Details
| C++ | Java | Python | C | PyPy | Kotlin | Rust | PHP |
USACO | | | | | | | | |
Practice sites | | | | | | | | |
Most "real" CP contests | | | | | | | | |
More Technical Details
Structure of Problems
Test Case Verdicts
Sample problem 1 (stream I/O)
Solution 1
t = int(input())
for i in range(t):
n=int(input())
for val in range(n):
print("()"*val+"("*(n-val) + ")"*(n-val))
Sample problem 2 (file I/O)
Solution 1
#include <iostream>
using namespace std;
int psum1[100001];
int psum2[100001];
int psum3[100001];
int a[100001];
int n, q;
int main() {
freopen("bcount.in", "r", stdin);
freopen("bcount.out", "w", stdout);
cin >> n >> q;
for(int i=1; i<=n; i++){
cin >> a[i];
}
for(int i=1; i<=n; i++){
psum1[i]=psum1[i-1];
psum2[i]=psum2[i-1];
psum3[i]=psum3[i-1];
if(a[i]==1) psum1[i]++;
if(a[i]==2) psum2[i]++;
if(a[i]==3) psum3[i]++;
}
for(int i=1; i<=q; i++){
int a, b; cin >> a >> b;
cout << psum1[b]-psum1[a-1] << " " << psum2[b]-psum2[a-1] << " " << psum3[b]-psum3[a-1] << '\n';
}
return 0;
}
Practice problems
Practice problems hints
Questions?
Topic requests?
Material from today: https://compteam.mbhs.edu/curriculum#meeting2-card
Make sure you’ve filled out the daily club check-in form: