freee Programming Contest 2022(AtCoder Beginner Contest 264)A~D题详细讲解
目錄
博主賽情
網站鏈接
比賽簡介
Contest Information
Reason why freee needs AtCoder users
freee's business content that can utilize the abilities cultivated at AtCoder
About freee's competitive programming club
Point Values
Contest Rules
Useful Links
題目講解?
A - "atcoder".substr()
原題描述
題目大意
題目思路
題目代碼
相關知識
B - Nice Grid
原題描述
題目大意
題目思路
題目代碼
相關知識
C - Matrix Reducing
原題描述
題目大意
題目思路
題目代碼
相關知識
D - "redocta".swap(i,i+1)
原題描述
題目大意?
題目思路
題目代碼
相關知識
比賽總結
博主賽情
從244起,博主一直堅持打ABC,今天終于上千分了,特此紀念!(碼齡僅一歲,勿噴!)
網站鏈接
freee Programming Contest 2022(AtCoder Beginner Contest 264) - AtCoder
比賽簡介
Contest Information
- Duration: 100 minutes
- Rated Range: 0 -?1999
?
?Contest Summary
This is an online programming contest sponsored by?freee, Inc.
freee's mission is to 「Empower Small Businesses to Take Center Stage」 and we develop and provide services with the aim of building an "integrated management platform that allows anyone to run their business freely. We believe that small businesses, which can materialize their ideas boldly and with a sense of speed, can create various innovations and at the same time, stimulate large companies to create a new movement in the world as a whole.
Reason why freee needs AtCoder users
freee is a cloud-based ERP that stores customer's Accounting, Human Resources, and other business data and provides functions to improve business efficiency.
Records of daily transactions, time and attendance, etc. gradually become large volumes of data as the company grows, and the calculation efficiency must be considered in order to tabulate and present this information in real time. Tax and salary calculations also require the ability to translate complex specifications of laws that change from year to year into logic and accurately put them into code. In addition, since the complexity of each domain area is divided into microservices and loosely coupled so as not to affect others, data must be efficiently federated while maintaining consistency among the services.
We believe that AtCoder users' 「ability to select the appropriate data structure and algorithm for the problem」 and 「ability to implement quickly while considering edge cases」 will be of great help in these challenges. This time we are organizing a programming contest on AtCoder to meet AtCoder users who have such talent and to get them interested in freee.
freee's business content that can utilize the abilities cultivated at AtCoder
This section describes an example of freee's business content that can utilize the implementation skills cultivated with AtCoder, knowledge of data structures and algorithms, and ability to estimate the amount of calculation.
- In the development of the common infrastructure, we are also developing microservices that handle tree structures such as the organizational hierarchy of a company.
- Algorithms are used to structure real-world data, such as tracking changes in credit card statements over time or inferring transaction details from receipt images.
- Various microservices have distributed system designs to maintain data integrity among other internal services.
- In the development of infrastructure services, we are implementing libraries that provide common functions such as authentication and failover with only a small overhead.
- At DBRE, we understand the internal implementation of each database from open source code and papers to determine optimal usage and deploy stable operations throughout the company.
If you are interested, please apply through the link below.
- Job Description of Global engineering team
- Mid-Career Recruitment List (Written in Japanese)
- New Graduate Recruitment Page (Written in Japanese)
- AtCoder Job offer page (Written in Japanese)
To learn more about freee's corporate culture, please see below.
- freee Developers Hub (Written in Japanese)
- freee Tech Night (Written in Japanese)
About freee's competitive programming club
freee launched the Competitive Programming Club in January 2022 as a club activity, and currently meets twice a week, mainly to discuss impressions and solutions to AtCoder contests held on Saturdays and Sundays. For more information, please see the?article (Written in Japanese) about the club's activities.?In recent activities other than impression battles, we are expanding the range of activities every day, such as holding an in-house programming contest in which the members were in charge of asking questions.
Read about holding an in-house programming contest here. (Written in Japanese)
Point Values
| Task | Score |
|---|---|
| A | 100 |
| B | 200 |
| C | 300 |
| D | 400 |
| E | 500 |
| F | 500 |
| G | 600 |
| Ex | 600 |
Contest Rules
This contest is full-feedback (solutions are judged during the contest).
When you solve a problem, you get a score assigned to it. Competitors are ranked first by total scores, then by penalties. The penalties are computed as (the time you spend to get your current score) + (5 minutes) * (the number of incorrect attempts).
Useful Links
- AtCoder top page
- How to participate
- Practice contest
題目講解?
A - "atcoder".substr()
原題描述
題目大意
打印字符串“atcoder”中的第l位到第r位之間的字符。
題目思路
從l循環到r,輸出每一位。
題目代碼
C++ (GCC 9.2.1) 100 1375 Byte AC 5 ms 3624 KB Detail #include<bits/stdc++.h> using namespace std; int main(){cin.tie(0);ios::sync_with_stdio(0);string s="atcoder";int l,r; cin>>l>>r;for(int i=l;i<=r;i++) cout<<s[i-1];return 0; } //ACplease!!!/* printf(" \n");printf(" \n");printf(" * * * * * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * * * * * * * * * * * * * * * * * * * * \n"); \n"); */
相關知識
① string是C++、java、VB等編程語言中的字符串,字符串是一個特殊的對象,屬于引用類型。 在java、C#中,String類對象創建后,字符串一旦初始化就不能更改,因為string類中所有字符串都是常量,數據是無法更改,由于string對象的不可變,所以可以共享。對String類的任何改變,都是返回一個新的String類對象。 C++標準庫中string類以類型的形式對字符串進行封裝,且包含了字符序列的處理操作。
②?for循環是編程語言中一種循環語句,而循環語句由循環體及循環的判定條件兩部分組成,其表達式為:for(單次表達式;條件表達式;末尾循環體){中間循環體;}。
B - Nice Grid
原題描述
題目大意
輸出下圖中第r行第c列的顏色(black或white)。
?
題目思路
方法1:找規律發現,max(abs(r-8),abs(c-8))%2為1時是black,反之是white。
方法2:手寫前8行,后面循環復制,第i行=第16-i行。
題目代碼
方法1:
C++ (GCC 9.2.1) 200 1392 Byte AC 5 ms 3664 KB Detail #include<bits/stdc++.h> using namespace std; int main(){cin.tie(0);ios::sync_with_stdio(0);int r,c; cin>>r>>c;if(max(abs(r-8),abs(c-8))%2) puts("black");else puts("white");return 0; } //ACplease!!!/* printf(" \n");printf(" \n");printf(" * * * * * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * * * * * * * * * * * * * * * * * * * * \n"); \n"); */方法2:
C++ (GCC 9.2.1) 200 1640 Byte AC 8 ms 3644 KB Detail #include<bits/stdc++.h> using namespace std; int main(){cin.tie(0);ios::sync_with_stdio(0);string s[30];s[1]="000000000000000";s[2]="011111111111110";s[3]="010000000000010";s[4]="010111111111010";s[5]="010100000001010";s[6]="010101111101010";s[7]="010101000101010";s[8]="010101010101010";for(int i=9;i<=15;i++) s[i]=s[16-i];int r,c; cin>>r>>c;if(s[r][c-1]=='1') puts("white");else puts("black");return 0; } //ACplease!!!/* printf(" \n");printf(" \n");printf(" * * * * * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * * * * * * * * * * * * * * * * * * * * \n"); \n"); */
相關知識
①?函數max函數用于求向量或者矩陣的最大元素,或幾個指定值中的最大值。MATLAB等高級編程語言中常用有三種形式:max(A)、max(A,B)、max(A,[],dim)。
②?puts()函數的功能是用于輸出一個字符串,其中括號內的參數是輸出字符串的起始地址。?用來向標準輸出設備(屏幕)寫字符串并換行, 其調用格式為: puts(s);
puts(s) 等效于printf("%s\n",s),前提 :s是C風格字符串,最后以'\0'結尾。
說明:(1). puts()函數只能輸出字符串, 不能輸出數值或進行格式變換。 (2). 可以將字符串直接寫入puts()函數中。如: puts("Hello, Turbo C2.0");
③?abs 函數是存在于多種編程語言(包括且不限于:C語言、C++、Fortran、Matlab、Pascal、Delphi、Visual Basic 和 VBA)中的一種用于求數據絕對值的函數。
C - Matrix Reducing
原題描述
題目大意
你有兩個矩陣:矩陣a(h1×w1),矩陣b(h2×w2)。問能否刪除一些行列(可以不刪除),將a變成b。
題目思路
遇到a的某行或列不包含任何b里的元素,則刪除該行或列。數據很小,時間很充裕,可以亂寫循環。
題目代碼
C++ (GCC 9.2.1) 300 3105 Byte AC 5 ms 3616 KB Detail #include<bits/stdc++.h> using namespace std; int main(){cin.tie(0);ios::sync_with_stdio(0);long long h1,r1,h2,r2,a[20][20],b[20][20]; cin>>h1>>r1;long long h1t=h1,r1t=r1;for(long long i=1;i<=h1;i++) for(long long j=1;j<=r1;j++) cin>>a[i][j];cin>>h2>>r2;for(long long i=1;i<=h2;i++) for(long long j=1;j<=r2;j++) cin>>b[i][j];for(long long i=1;i<=h1t;i++){bool flag=1;for(long long j=1;j<=r1t;j++){for(long long k=1;k<=h2;k++) for(long long l=1;l<=r2;l++) if(b[k][l]==a[i][j]){flag=0;break;} if(!flag) break;}if(flag){h1--;for(long long j=1;j<=r1;j++) a[i][j]=0;}}int y=0,z=1;for(long long i=1;i<=h1t;i++){bool flag=0;for(long long j=1;j<=r1t;j++){if(a[i][j]){y++;a[z][y]=a[i][j];flag=1;}}if(flag) z++;y=0;}h1t=h1; r1t=r1;//cout<<h1<<" "<<r1<<endl;for(long long i=1;i<=r1t;i++){bool flag=1;for(long long j=1;j<=h1t;j++){for(long long k=1;k<=h2;k++) for(long long l=1;l<=r2;l++) if(b[k][l]==a[j][i]){flag=0;break;} if(!flag) break;}if(flag){r1--;for(long long j=1;j<=h1;j++) a[j][i]=0;}}/*for(long long i=1;i<=h1t;i++){for(long long j=1;j<=r1t;j++){cout<<a[i][j]<<" ";}cout<<endl;}*/y=0,z=1;for(long long i=1;i<=h1t;i++){bool flag=0;for(long long j=1;j<=r1t;j++){if(a[i][j]){y++;a[z][y]=a[i][j];flag=1;}}if(flag) z++;y=0;}if(h1<h2||r1<r2) cout<<"No";else{/*for(long long i=1;i<=h1t;i++){for(long long j=1;j<=r1t;j++){cout<<a[i][j]<<" ";}cout<<endl;}*/for(long long i=1;i<=h2;i++) for(long long j=1;j<=r2;j++) if(a[i][j]!=b[i][j]){cout<<"No";return 0;}cout<<"Yes";}return 0; } //ACplease!!!/* printf(" \n");printf(" \n");printf(" * * * * * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * * * * * * * * * * * * * * * * * * * * \n"); \n"); */ps:博主不小心把w1和w2全寫成r1和r2了……
相關知識
①?數組(Array)是有序的元素序列。若將有限個類型相同的變量的集合命名,那么這個名稱為數組名。組成數組的各個變量稱為數組的分量,也稱為數組的元素,有時也稱為下標變量。用于區分數組的各個元素的數字編號稱為下標。數組是在程序設計中,為了處理方便, 把具有相同類型的若干元素按有序的形式組織起來的一種形式。?這些有序排列的同類數據元素的集合稱為數組。數組是用于儲存多個相同類型數據的集合。
②?break語句,是中斷當前循環,或和label一起使用,中斷相關聯的語句。
D - "redocta".swap(i,i+1)
原題描述
題目大意?
字符串s是“atcoder”的一種排列,交換相鄰兩字符的位置是一種操作,求至少需要多少次操作可以讓s變成“atcoder”。
題目思路
不需要貪心算法,只要按順序把每個字母歸位就是最少操作。
題目代碼
C++ (GCC 9.2.1) 400 2161 Byte AC 8 ms 3616 KB Detail #include<bits/stdc++.h> using namespace std; int main(){cin.tie(0);ios::sync_with_stdio(0);string s; cin>>s;int ans=0;for(int i=1;i<(int)s.size();i++){if(s[i]=='a'){for(int j=i;j>0;j--){swap(s[j],s[j-1]);ans++;}}}for(int i=2;i<(int)s.size();i++){if(s[i]=='t'){for(int j=i;j>1;j--){swap(s[j],s[j-1]);ans++;}}}for(int i=3;i<(int)s.size();i++){if(s[i]=='c'){for(int j=i;j>2;j--){swap(s[j],s[j-1]);ans++;}}}for(int i=4;i<(int)s.size();i++){if(s[i]=='o'){for(int j=i;j>3;j--){swap(s[j],s[j-1]);ans++;}}}for(int i=5;i<(int)s.size();i++){if(s[i]=='d'){for(int j=i;j>4;j--){swap(s[j],s[j-1]);ans++;}}}if(s[5]=='r'){swap(s[5],s[6]);ans++;}cout<<ans; return 0; } //ACplease!!!/* printf(" \n");printf(" \n");printf(" * * * * * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * \n");printf(" * * * * * * * * * * * * * * * * * * * * * * * * \n"); \n"); */
相關知識
① swap函數是計算機中的函數,在不同領域有不同的用法,但都是交換的意思。
比賽總結
這次比賽取得新的進步,博主挺滿意的,下次向E題邁進,繼續努力!
總結
以上是生活随笔為你收集整理的freee Programming Contest 2022(AtCoder Beginner Contest 264)A~D题详细讲解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: workflow java_workfl
- 下一篇: java excel sheet页_Ja