日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 综合教程 >内容正文

综合教程

freee Programming Contest 2022(AtCoder Beginner Contest 264)A~D题详细讲解

發(fā)布時(shí)間:2023/12/2 综合教程 35 生活家
生活随笔 收集整理的這篇文章主要介紹了 freee Programming Contest 2022(AtCoder Beginner Contest 264)A~D题详细讲解 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

目錄

博主賽情

網(wǎng)站鏈接

比賽簡(jiǎn)介

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

題目講解?

A - "atcoder".substr()

原題描述

題目大意

題目思路

題目代碼

相關(guān)知識(shí)

B - Nice Grid

原題描述

題目大意

題目思路

題目代碼

相關(guān)知識(shí)

C - Matrix Reducing

原題描述

題目大意

題目思路

題目代碼

相關(guān)知識(shí)

D - "redocta".swap(i,i+1)

原題描述

題目大意?

題目思路

題目代碼

相關(guān)知識(shí)

比賽總結(jié)


博主賽情

從244起,博主一直堅(jiān)持打ABC,今天終于上千分了,特此紀(jì)念!(碼齡僅一歲,勿噴!)

網(wǎng)站鏈接

freee Programming Contest 2022(AtCoder Beginner Contest 264) - AtCoder

比賽簡(jiǎn)介

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).

  • AtCoder top page
  • How to participate
  • Practice contest

題目講解?

A - "atcoder".substr()

原題描述

題目大意

打印字符串“atcoder”中的第l位到第r位之間的字符。

題目思路

從l循環(huán)到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");
*/    

相關(guān)知識(shí)

① string是C++、java、VB等編程語(yǔ)言中的字符串,字符串是一個(gè)特殊的對(duì)象,屬于引用類型。 在java、C#中,String類對(duì)象創(chuàng)建后,字符串一旦初始化就不能更改,因?yàn)閟tring類中所有字符串都是常量,數(shù)據(jù)是無(wú)法更改,由于string對(duì)象的不可變,所以可以共享。對(duì)String類的任何改變,都是返回一個(gè)新的String類對(duì)象。 C++標(biāo)準(zhǔn)庫(kù)中string類以類型的形式對(duì)字符串進(jìn)行封裝,且包含了字符序列的處理操作。

②?for循環(huán)是編程語(yǔ)言中一種循環(huán)語(yǔ)句,而循環(huán)語(yǔ)句由循環(huán)體及循環(huán)的判定條件兩部分組成,其表達(dá)式為:for(單次表達(dá)式;條件表達(dá)式;末尾循環(huán)體){中間循環(huán)體;}。

B - Nice Grid

原題描述

題目大意

輸出下圖中第r行第c列的顏色(black或white)。

?

題目思路

方法1:找規(guī)律發(fā)現(xiàn),max(abs(r-8),abs(c-8))%2為1時(shí)是black,反之是white。

方法2:手寫前8行,后面循環(huán)復(fù)制,第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");
*/    

相關(guān)知識(shí)

①?函數(shù)max函數(shù)用于求向量或者矩陣的最大元素,或幾個(gè)指定值中的最大值。MATLAB等高級(jí)編程語(yǔ)言中常用有三種形式:max(A)、max(A,B)、max(A,[],dim)。

②?puts()函數(shù)的功能是用于輸出一個(gè)字符串,其中括號(hào)內(nèi)的參數(shù)是輸出字符串的起始地址。?用來(lái)向標(biāo)準(zhǔn)輸出設(shè)備(屏幕)寫字符串并換行, 其調(diào)用格式為: puts(s);

puts(s) 等效于printf("%s\n",s),前提 :s是C風(fēng)格字符串,最后以'\0'結(jié)尾。

說(shuō)明:(1). puts()函數(shù)只能輸出字符串, 不能輸出數(shù)值或進(jìn)行格式變換。 (2). 可以將字符串直接寫入puts()函數(shù)中。如: puts("Hello, Turbo C2.0");

③?abs 函數(shù)是存在于多種編程語(yǔ)言(包括且不限于:C語(yǔ)言、C++、Fortran、Matlab、Pascal、Delphi、Visual Basic 和 VBA)中的一種用于求數(shù)據(jù)絕對(duì)值的函數(shù)。

C - Matrix Reducing

原題描述

題目大意

你有兩個(gè)矩陣:矩陣a(h1×w1),矩陣b(h2×w2)。問(wèn)能否刪除一些行列(可以不刪除),將a變成b。

題目思路

遇到a的某行或列不包含任何b里的元素,則刪除該行或列。數(shù)據(jù)很小,時(shí)間很充裕,可以亂寫循環(huán)。

題目代碼

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了……

相關(guān)知識(shí)

①?數(shù)組(Array)是有序的元素序列。若將有限個(gè)類型相同的變量的集合命名,那么這個(gè)名稱為數(shù)組名。組成數(shù)組的各個(gè)變量稱為數(shù)組的分量,也稱為數(shù)組的元素,有時(shí)也稱為下標(biāo)變量。用于區(qū)分?jǐn)?shù)組的各個(gè)元素的數(shù)字編號(hào)稱為下標(biāo)。數(shù)組是在程序設(shè)計(jì)中,為了處理方便, 把具有相同類型的若干元素按有序的形式組織起來(lái)的一種形式。?這些有序排列的同類數(shù)據(jù)元素的集合稱為數(shù)組。數(shù)組是用于儲(chǔ)存多個(gè)相同類型數(shù)據(jù)的集合。

②?break語(yǔ)句,是中斷當(dāng)前循環(huán),或和label一起使用,中斷相關(guān)聯(lián)的語(yǔ)句。

D - "redocta".swap(i,i+1)

原題描述

題目大意?

字符串s是“atcoder”的一種排列,交換相鄰兩字符的位置是一種操作,求至少需要多少次操作可以讓s變成“atcoder”。

題目思路

不需要貪心算法,只要按順序把每個(gè)字母歸位就是最少操作。

題目代碼

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");
*/    

相關(guān)知識(shí)

① swap函數(shù)是計(jì)算機(jī)中的函數(shù),在不同領(lǐng)域有不同的用法,但都是交換的意思。

比賽總結(jié)

這次比賽取得新的進(jìn)步,博主挺滿意的,下次向E題邁進(jìn),繼續(xù)努力!

總結(jié)

以上是生活随笔為你收集整理的freee Programming Contest 2022(AtCoder Beginner Contest 264)A~D题详细讲解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。